Skip to content

Commit

Permalink
Merge pull request #532 from stanfordnlp/thomasahle-readme-patch
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
okhat authored Mar 2, 2024
2 parents 5ecc042 + d461bb7 commit 244a817
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,32 @@ compiled_rag = teleprompter.compile(RAG(), trainset=my_rag_trainset)
If we now use `compiled_rag`, it will invoke our LM with rich prompts with few-shot demonstrations of chain-of-thought retrieval-augmented question answering on our data.


## 5) Pydantic Types

Sometimes you need more than just string inputs/outputs.
Assume, for example, you need to find

## 5) FAQ: Is DSPy right for me?
```python
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(Signature):
""" Extract all travel information in the given email """
email: str = InputField()
flight_information: list[TravelInformation] = OutputField()

predictor = dspy.TypedPredictor(TravelSignature)
predictor(email='...')
```

Which will output a list of `TravelInformation` objects.

## 6) FAQ: Is DSPy right for me?

The **DSPy** philosophy and abstraction differ significantly from other libraries and frameworks, so it's usually straightforward to decide when **DSPy** is (or isn't) the right framework for your usecase.

Expand Down

0 comments on commit 244a817

Please sign in to comment.