Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Merge branch 'main' into return-inspect-value

arnavsinghvi112844eb508f38
diff --cc dsp/modules/lm.py
index 7df87dd90,f109a7fbb..557b03a63
--- a/dsp/modules/lm.py
+++ b/dsp/modules/lm.py
@@@ -82,20 -74,20 +77,24 @@@ class LM(ABC)
if provider == "cohere":
text = choices[0].text
elif provider == "openai" or provider == "ollama":
- text = ' ' + self._get_choice_text(choices[0]).strip()
+ text = " " + self._get_choice_text(choices[0]).strip()
elif provider == "clarifai":
- text=choices
+ text = choices
+ elif provider == "google":
+ text = choices[0].parts[0].text
+ elif provider == "mistral":
+ text = choices[0].message.content
else:
text = choices[0]["text"]
- self.print_green(text, end="")
+ printing_value += self.print_green(text, end="")
if len(choices) > 1:
- self.print_red(f" \t (and {len(choices)-1} other completions)", end="")
- print("\n\n\n")
+ printing_value += self.print_red(f" \t (and {len(choices)-1} other completions)", end="")
+
+ printing_value += "\n\n\n"
+
+ print(printing_value)
+ return printing_value
@abstractmethod
def __call__(self, prompt, only_completed=True, return_sorted=False, **kwargs):