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

Add Tests for extend generation logic #1184

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
feat(dsp): clarify what is generated in each generation
  • Loading branch information
JONEMI19 committed Jun 20, 2024
commit bcab220171d5f02fbc2833bce649f296519cf3bb
129 changes: 15 additions & 114 deletions tests/predict/test_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,77 +254,44 @@ def test_extend_generation(SandwichIdea):
dspy.settings.configure(lm=lm)

prediction = Predict(SandwichIdea)(meal="lunch", dietary_requiements="N/A")

# The logged conversation:
# The logged conversation (additional newlines removed, [..] indicates the generation):
# === DummyLM ===
# Based on the meal and dietary requirements, suggest a sandwich idea.

# ---

# Follow the following format.

# Meal: ${meal}

# Dietary Requiements: ${dietary_requiements}

# Bread: ${bread}

# Protein: ${protein}

# Fat: ${fat}

# Garnish: ${garnish}

# Sauce: ${sauce}

# ---

# Meal: lunch

# Dietary Requiements: N/A

# Bread: whole wheat

# Bread: [whole wheat
# Protein: turkey

# Fat: avocado
# Fat: avocado]
# ===
# === DummyLM ===
# Based on the meal and dietary requirements, suggest a sandwich idea.

# ---

# Follow the following format.

# Meal: ${meal}

# Dietary Requiements: ${dietary_requiements}

# Bread: ${bread}

# Protein: ${protein}

# Fat: ${fat}

# Garnish: ${garnish}

# Sauce: ${sauce}

# ---

# Meal: lunch

# Dietary Requiements: N/A

# Bread: whole wheat

# Protein: turkey

# Fat: avocado

# Garnish: tomato

# Sauce: mustard
# Garnish: [tomato
# Sauce: mustard]
# ===

assert prediction.bread == "whole wheat"
Expand All @@ -342,79 +309,45 @@ def test_extend_generation_rolled_back_when_field_is_skipped(SandwichIdea):
]
)
dspy.settings.configure(lm=lm)

# The logged conversation:
# The logged conversation (additional newlines removed, [..] indicates the generation):
# === DummyLM ===
# Based on the meal and dietary requirements, suggest a sandwich idea.

# ---

# Follow the following format.

# Meal: ${meal}

# Dietary Requiements: ${dietary_requiements}

# Bread: ${bread}

# Protein: ${protein}

# Fat: ${fat}

# Garnish: ${garnish}

# Sauce: ${sauce}

# ---

# Meal: lunch

# Dietary Requiements: N/A

# Bread: white

# Bread:[ white
# Fat: butter

# Garnish: lettuce

# Sauce: mayo
# Sauce: mayo]
# ===
# === DummyLM ===
# Based on the meal and dietary requirements, suggest a sandwich idea.

# ---

# Follow the following format.

# Meal: ${meal}

# Dietary Requiements: ${dietary_requiements}

# Bread: ${bread}

# Protein: ${protein}

# Fat: ${fat}

# Garnish: ${garnish}

# Sauce: ${sauce}

# ---

# Meal: lunch

# Dietary Requiements: N/A

# Bread: white Fat: butter Garnish: lettuce Sauce: mayo

# Protein: ham

# Protein:[ ham
# Fat: butter

# Garnish: lettuce

# Sauce: mayo
# Sauce: mayo]
# ===

predictor = Predict(SandwichIdea)(meal="lunch", dietary_requiements="N/A")
Expand All @@ -433,76 +366,44 @@ def test_extend_generation_with_empty_field(SandwichIdea):
]
)
dspy.settings.configure(lm=lm)
# The logged conversation:
# The logged conversation (additional newlines removed, [..] indicates the generation):
# === DummyLM ===
# Based on the meal and dietary requirements, suggest a sandwich idea.

# ---

# Follow the following format.

# Meal: ${meal}

# Dietary Requiements: ${dietary_requiements}

# Bread: ${bread}

# Protein: ${protein}

# Fat: ${fat}

# Garnish: ${garnish}

# Sauce: ${sauce}

# ---

# Meal: lunch

# Dietary Requiements: N/A

# Bread: white

# Bread:[ white
# Protein:

# Fat: butter

# Garnish: lettuce
# Garnish: lettuce]
# ===
# === DummyLM ===
# Based on the meal and dietary requirements, suggest a sandwich idea.

# ---

# Follow the following format.

# Meal: ${meal}

# Dietary Requiements: ${dietary_requiements}

# Bread: ${bread}

# Protein: ${protein}

# Fat: ${fat}

# Garnish: ${garnish}

# Sauce: ${sauce}

# ---

# Meal: lunch

# Dietary Requiements: N/A

# Bread: white

# Protein: Fat: butter Garnish: lettuce

# Fat: lettuce

# Sauce: mayo
# Fat:[ lettuce
# Sauce: mayo]
# ===

predictor = Predict(SandwichIdea)(meal="lunch", dietary_requiements="N/A")
Expand Down
Loading