Skip to content

armgit / dspy

Public Imported from GitHub
0

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

Python

Merge pull request #1337 from stanfordnlp/format-inspect-history

arnavsinghvi1171fa56482479
diff --cc dsp/modules/lm.py
index 13ddfbffa,c14fd0a79..c0569852b
--- a/dsp/modules/lm.py
+++ b/dsp/modules/lm.py
@@@ -116,14 -101,17 +116,15 @@@ class LM(ABC)
text = choices[0].message.content
elif provider == "cloudflare":
text = choices[0]
- elif provider == "ibm" or provider == "premai":
- text = choices
else:
text = choices[0]["text"]
- printing_value += self.print_green(text, end="")
+ printing_value += self.print_green(text, end="") if color_format else text
if len(choices) > 1 and isinstance(choices, list):
+ choices_text = f" \t (and {len(choices)-1} other completions)"
printing_value += self.print_red(
- f" \t (and {len(choices)-1} other completions)", end="",
- )
+ choices_text, end="",
+ ) if color_format else choices_text
printing_value += "\n\n\n"