stanfordnlp / dspy

DSPy: The framework for programming—not prompting—language models
https://dspy.ai
MIT License
19.22k stars 1.46k forks source link

Unable to run o1-mini (azure, dspy==2.5.34) #1847

Open denisergashbaev opened 2 days ago

denisergashbaev commented 2 days ago

Hello! I am getting the following error when trying to run o1-mini with DSPy==2.5.34 with this config:

dspy.configure(experimental=True)
lm = dspy.LM(model="azure/gpt-o1-mini", ...)

error:

{'error': {'message': "Unsupported value: 'message...support 'system' with this model."

Any ideas?

okhat commented 2 days ago

Hey @denisergashbaev !

I think via OpenAI, the o1 model works, but perhaps not via Azure?

Anyway if the issue is that it Azure o1 can't handle "system" roles, the easiest fix (it's 3-4 lines) is to build an adapter that inherits from ChatAdapter and just switches the "system" role to a "user" role.

class ChatAdapterO1(dspy.adapters.ChatAdapter):
  def format(...):
     ... # call super()'s format and replace the role

dspy.configure(adapter=ChatAdapterO1)