Skip to content

armgit / dspy

Public Imported from GitHub
0

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

Python

fix(dsp): indicate other completions only if choices is list, not string

sysid5d3d7b304f0a
diff --git a/dsp/modules/lm.py b/dsp/modules/lm.py
index cfe8b88d0..025acfca2 100644
--- a/dsp/modules/lm.py
+++ b/dsp/modules/lm.py
@@ -76,8 +76,8 @@ class LM(ABC):
text = choices
elif provider == "openai" or provider == "ollama":
text = ' ' + self._get_choice_text(choices[0]).strip()
- elif provider == "clarifai" or provider == "claude" :
- text=choices
+ elif provider == "clarifai" or provider == "claude":
+ text = choices
elif provider == "groq":
text = ' ' + choices
elif provider == "google":
@@ -88,7 +88,7 @@ class LM(ABC):
text = choices[0]["text"]
printing_value += self.print_green(text, end="")
- if len(choices) > 1:
+ if len(choices) > 1 and isinstance(choices, list):
printing_value += self.print_red(f" \t (and {len(choices)-1} other completions)", end="")
printing_value += "\n\n\n"