mirror of
https://github.com/ollama/ollama-python.git
synced 2026-07-21 09:05:23 -04:00
ollama._types.ResponseError ResponseError(e.response.text, e.response.status_code) from None #190
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Siki-cloud on GitHub (Dec 28, 2024).
when i ran the following code, I got the error
ollama._types.ResponseError, I don't why this happened, can anyone help me ? thanks in advance.code
here are the downloaded LLM:
Error:
@immmor commented on GitHub (Jan 2, 2025):
Got the same error for Win10.
@Rakshitha7989 commented on GitHub (Jan 3, 2025):
getting the same error
raise ResponseError(e.response.text, e.response.status_code) from None
ollama._types.ResponseError: pull model manifest: file does not exist
@ParthSareen commented on GitHub (Jan 10, 2025):
@Siki-cloud what's the text returned in the response error?
@Rakshitha7989 - are you able to run from CLI?
ollama run <model>@Zyg187 commented on GitHub (Jan 15, 2025):
I also encountered the same error in win10. I modified the location of the ollama model. Is it related to this reason?
**from ollama import chat
from ollama import ChatResponse
response: ChatResponse = chat(model='glm4:latest', messages=[
{
'role': 'user',
'content': 'Why is the sky blue?',
},
])
print(response['message']['content'])
or access fields directly from the response object
print(response.message.content)**
C:\Users\Administrator>ollama list
NAME ID SIZE MODIFIED
glm4:latest 5b699761eca5 5.5 GB 33 minutes ago
bge-m3:latest 790764642607 1.2 GB 4 weeks ago
EntropyYue/chatglm3:6b 8f6f34227356 3.6 GB 4 weeks ago
**D:\anaconda\envs\stu\python.exe D:\aaproject\learn-langchain\3.py
Traceback (most recent call last):
File "D:\aaproject\learn-langchain\3.py", line 4, in
response: ChatResponse = chat(model='glm4:latest', messages=[
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\anaconda\envs\stu\Lib\site-packages\ollama_client.py", line 332, in chat
return self._request(
^^^^^^^^^^^^^^
File "D:\anaconda\envs\stu\Lib\site-packages\ollama_client.py", line 177, in _request
return cls(**self._request_raw(*args, kwargs).json())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\anaconda\envs\stu\Lib\site-packages\ollama_client.py", line 122, in _request_raw
raise ResponseError(e.response.text, e.response.status_code) from None
ollama._types.ResponseError
@Zyg187 commented on GitHub (Jan 15, 2025):
But I can load the model using from langchain_community.llms import Ollama. This method does not report an error, why is this?
`# 使用本地ollama调用模型,简单实现一个链式回答
from langchain_core.prompts import ChatPromptTemplate
from langchain_community.llms import Ollama
from langchain_core.output_parsers import StrOutputParser
model = Ollama(model="glm4:latest", temperature=0.7) # 调用模型
output_parser = StrOutputParser() # 解析格式
模板
template = """
你是一个乐于助人的AI,擅长于解决回答各种问题。
问题:{question}
"""
prompt = ChatPromptTemplate.from_template(template)
chain = prompt | model | output_parser
print(chain.invoke({"question": "你比GPT4厉害吗?"}))`
@ParthSareen commented on GitHub (Jan 17, 2025):
Rolling out a change with some better error messaging. Until then could all of you make sure that
ollama run <model> <prompt>is working?@Zyg187 commented on GitHub (Jan 20, 2025):
Yes, I was able to use ollama in cmd, and I was able to use ollama via langchain's from langchain_community.llms import Ollama, but I get an error when I use the ollama-python library. I will provide more information but need guidance on what to do
@ParthSareen commented on GitHub (Jan 20, 2025):
@Zyg187 could you try passing in the url when instantiating the ollama client under
host?@Zyg187 commented on GitHub (Jan 21, 2025):
@ParthSareen Sorry to keep you waiting. I'm a novice who is new to contact, I don't quite understand what you mean, can you provide a simple piece of code for me to test?
@Zyg187 commented on GitHub (Jan 22, 2025):
@ParthSareen I understand what you mean, and I have found the cause of the problem. Because I opened a proxy, I can't access it locally.The code runs successfully after turning off the proxy. I am curious about why the method "from langchain_community.llms import Ollama" can be used normally when using a proxy. How can I use the ollama-python official library normally when opening a proxy? Can you give me some suggestions?
from ollama import Client client = Client( host='http://localhost:11434', headers={'x-some-header': 'some-value'} ) response = client.chat(model='llama3.2', messages=[ { 'role': 'user', 'content': 'Why is the sky blue?', }, ])@ParthSareen commented on GitHub (Jan 22, 2025):
Yeah unsure why langchain works - I wonder if it's not the proxied instance. Could you check this out and see if it helps? https://github.com/ollama/ollama/blob/main/docs/faq.md#how-do-i-use-ollama-behind-a-proxy
@ParthSareen commented on GitHub (Feb 13, 2025):
Going to close for now, feel free to ping if you're still running into this!