dspy icon indicating copy to clipboard operation
dspy copied to clipboard

Multi-line input incorrectly handled as single line

Open Shangyint opened this issue 9 months ago • 1 comments

import dspy

turbo = dspy.OpenAI(model="gpt-3.5-turbo", max_tokens=500)
dspy.settings.configure(lm=turbo, trace=[], temperature=0.7)

class GenerateQuestion(dspy.Signature):
    question = dspy.InputField()
    answer = dspy.OutputField()


prog = dspy.Predict(GenerateQuestion)

question = """
This is a dummy
multi-line
question.
"""

prog(question=question)

turbo.inspect_history(n=1)
Given the fields `question`, produce the fields `answer`.

---

Follow the following format.

Question: ${question}
Answer: ${answer}

---

Question: This is a dummy multi-line question.
Answer: This is a dummy multi-line answer.

Here is a small reproducer. To solve this problem, now we would need to write question = dspy.InputField(format=str), which is not ergonomic.

Shangyint avatar May 02 '24 03:05 Shangyint

+1 same issue

whisper-bye avatar Aug 09 '24 08:08 whisper-bye

Thanks for opening this! We released DSPy 2.5 yesterday. I think the new dspy.LM and the underlying dspy.ChatAdapter will probably resolve this problem.

Here's the (very short) migration guide, it should typically take you 2-3 minutes to change the LM definition and you should be good to go: https://github.com/stanfordnlp/dspy/blob/main/examples/migration.ipynb

Please let us know if this resolves your issue. I will close for now but please feel free to re-open if the problem persists.

okhat avatar Sep 24 '24 17:09 okhat