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

using local llm with openai error #1651

Open
SoulProficiency opened this issue Mar 1, 2025 · 1 comment
Open

using local llm with openai error #1651

SoulProficiency opened this issue Mar 1, 2025 · 1 comment

Comments

@SoulProficiency
Copy link

here is my code:
`import pandas as pd
from pandasai import SmartDataframe
from pandasai.llm.local_llm import LocalLLM

ollama_llm = LocalLLM(api_base="http://192.168.10.170:11434", model="codeqwen", api_key="codeqwen")
df = pd.DataFrame({
"country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia",
"Japan", "China"],
"gdp": [19294482071552, 2891615567872, 2411255037952, 3435817336832, 1745433788416, 1181205135360, 1607402389504,
1490967855104, 4380756541440, 14631844184064],
"happiness_index": [6.94, 7.16, 6.66, 7.07, 6.38, 6.4, 7.23, 7.22, 5.87, 5.12]
})
df = SmartDataframe(df, config={"llm": ollama_llm,"enable_cache": False})
print(df)
res = df.chat('Which are the top 5 countries by sales?')
print(res)i try local LLM model,but it return openai error:Traceback (most recent call last):
File "D:\anaconda\envs\pai_2\lib\site-packages\pandasai\pipelines\chat\generate_chat_pipeline.py", line 335, in run
).run(input)
File "D:\anaconda\envs\pai_2\lib\site-packages\pandasai\pipelines\pipeline.py", line 137, in run
raise e
File "D:\anaconda\envs\pai_2\lib\site-packages\pandasai\pipelines\pipeline.py", line 101, in run
step_output = logic.execute(
File "D:\anaconda\envs\pai_2\lib\site-packages\pandasai\pipelines\chat\code_generator.py", line 33, in execute
code = pipeline_context.config.llm.generate_code(input, pipeline_context)
File "D:\anaconda\envs\pai_2\lib\site-packages\pandasai\llm\base.py", line 201, in generate_code
response = self.call(instruction, context)
File "D:\anaconda\envs\pai_2\lib\site-packages\pandasai\llm\local_llm.py", line 47, in call
return self.chat_completion(self.last_prompt, memory)
File "D:\anaconda\envs\pai_2\lib\site-packages\pandasai\llm\local_llm.py", line 37, in chat_completion
response = self.client.create(**params)
File "D:\anaconda\envs\pai_2\lib\site-packages\openai_utils_utils.py", line 279, in wrapper
return func(*args, **kwargs)
File "D:\anaconda\envs\pai_2\lib\site-packages\openai\resources\chat\completions\completions.py", line 879, in create
return self._post(
File "D:\anaconda\envs\pai_2\lib\site-packages\openai_base_client.py", line 1296, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
File "D:\anaconda\envs\pai_2\lib\site-packages\openai_base_client.py", line 973, in request
return self._request(
File "D:\anaconda\envs\pai_2\lib\site-packages\openai_base_client.py", line 1077, in _request
raise self._make_status_error_from_response(err.response) from None
openai.NotFoundError: 404 page not found
Unfortunately, I was not able to answer your question, because of the following error:

404 page not found
`
how can i fix it?

@Alan-zhong
Copy link

Did you solve the problem? I also encountered the same issue.

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

2 participants