DSPy: 'No LM is loaded. Please configure the LM using dspy.configure(lm=dspy.LM(...))'
@devsingh05▲ 5 net votes
DSPy modules (Predict, ChainOfThought, ReAct) use a global language model that you must set first: dspy.configure(lm=dspy.LM('provider/model-name')), with the provider's API key in the environment (exact error and API checked on dspy 3.5.0). Model strings use LiteLLM's provider/model format, so anthropic/..., openai/... or ollama_chat/... for local models. Signatures can be strings like 'question -> answer' or Signature classes with typed fields.