DSPy: The framework for programming—not prompting—language models
Python
fix: handle dict response with text key in RLM (#9219)
Darin441eb5fd132e
diff --git a/dspy/predict/rlm.py b/dspy/predict/rlm.pyindex 48fef4da4..7dc99bdf7 100644--- a/dspy/predict/rlm.py+++ b/dspy/predict/rlm.py@@ -210,7 +210,12 @@ class RLM(Module):if target_lm is None:raise RuntimeError("No LM configured. Use dspy.configure(lm=...) or pass sub_lm to RLM.")response = target_lm(prompt)- return response[0] if isinstance(response, list) and response else str(response)+ if isinstance(response, list) and response:+ item = response[0]+ if isinstance(item, dict) and "text" in item:+ return item["text"]+ return item+ return str(response)def llm_query(prompt: str) -> str:"""Query the LLM with a prompt string."""