Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dspy watsonx #1829

Open
shashanka300 opened this issue Nov 20, 2024 · 4 comments
Open

dspy watsonx #1829

shashanka300 opened this issue Nov 20, 2024 · 4 comments

Comments

@shashanka300
Copy link


NameError Traceback (most recent call last)
Cell In[20], line 2
1 import dspy
----> 2 lm = dspy.Watsonx(model="mistralai/mixtral-8x7b-instruct-v01", project_id = PROJECT_ID,
3 credentials = CREDENTIALS)
4 dspy.configure(lm=lm)

File ~/Documents/Assets/Dspytest/dsp/lib/python3.11/site-packages/dsp/modules/watsonx.py:65, in Watsonx.init(self, model, credentials, project_id, **kwargs)
53 self.model_type = "instruct"
54 self.kwargs = {
55 "temperature": 0,
56 "decoding_method": "greedy",
(...)
62 **kwargs,
63 }
---> 65 self.client = Model(
66 model_id=self.model,
67 params=self.kwargs,
68 credentials=self.credentials,
69 project_id=self.project_id,
70 )
72 self.history: list[dict[str, Any]] = []

NameError: name 'Model' is not defined

I get this error enven after installing ibm-watsonx-ai

@arnavsinghvi11
Copy link
Collaborator

Hi @shashanka300

Can you try running the import locally from the Watson module's import logic? This should be working locally for the module to work.

import ibm_watsonx_ai  # noqa: F401
from ibm_watsonx_ai.foundation_models import Model

Also, I recommend using the latest dspy.LM client over dspy.Watsonx (which will be deprecated in upcoming DSPy releases). dspy.LM uses LiteLLM which supports WatsonX so you can just do something like dspy.LM(model="watsonx/...", other_watsonX_params..... Feel free to check out the migration notebook for more details!

@shashanka300
Copy link
Author

hi @arnavsinghvi11
Have tried this before i posted the bug report.
Unfortunately that dosen't work either.

@shashanka300
Copy link
Author

currently i am using it with litellm backend

@okhat
Copy link
Collaborator

okhat commented Nov 20, 2024

Yes please use dspy.LM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants