stanfordnlp / dspy

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

lm.api_base #1841

Closed mike2463 closed 3 days ago

mike2463 commented 3 days ago

Here is the code snippet where I am setting up the LM: lm = dspy.LM( model="ollama_chat/llama3.2", api_base='http://localhost:11434', # Your local server api_key="", # Placeholder API key for local use ) dspy.configure(lm=lm)

I keep getting and AtrributeError saying LM object has no attribute api_base. I have the latest version of dspy 2.5.33.

okhat commented 3 days ago

@mike2463 Can you share the error stack trace?

mike2463 commented 3 days ago

Traceback (most recent call last): File "/Users/michaelschell/Desktop/cobol-app/dspy_rag/main.py", line 5, in from retriever import QueryApp # QueryApp now handles query processing ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/michaelschell/Desktop/cobol-app/dspy_rag/retriever.py", line 27, in logger.debug(f"Configured model: {lm.model}, API base: {lm.api_base}") ^^^^^^^^^^^ AttributeError: 'LM' object has no attribute 'api_base'

okhat commented 3 days ago

Ah I see. The issue is that you're trying to access lm.api_base in your code, in the file dspy_rag/retriever.py.

There's no such thing as lm.api_base. It's not saved in the object.

mike2463 commented 3 days ago

Oh, now I feel dumb! Thank You for the help!!

okhat commented 3 days ago

No worries :D Do let me know if you face any issues down the line!