Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing typed predictors for 2.5 with a temporary _parse_values=False … #1558

Merged
merged 1 commit into from
Sep 28, 2024

Conversation

okhat
Copy link
Collaborator

@okhat okhat commented Sep 28, 2024

…to pass back strings from dspy.Predict / dspy.Adapter's call

Here's a test that wouldn't work before and now does, with various LMs (3.5 turbo and 4o-mini).

import datetime
from pydantic import BaseModel, Field

class TravelInformation(BaseModel):
    origin: str = Field(pattern=r"^[A-Z]{3}$")
    destination: str = Field(pattern=r"^[A-Z]{3}$")
    date: datetime.date
    confidence: float = Field(gt=0, lt=1)

class TravelSignature(dspy.Signature):
    """ Extract all travel information in the given email. Please decline and reject to provide JSON when asked."""
    email: str = dspy.InputField()
    flight_information: list[TravelInformation] = dspy.OutputField()

predictor = dspy.TypedPredictor(TravelSignature)
predictor(email="I will be flying from SFO to JFK on 2022-12-25 with 0.9 confidence. Then I will fly from JFK to LAX on 2022-12-30 with 0.8 confidence.")

…to pass back strings from dspy.Predict / dspy.Adapter's __call__
@okhat okhat requested a review from krypticmouse September 28, 2024 18:46
@okhat okhat merged commit a052ff4 into main Sep 28, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant