ollama._types.ResponseError ResponseError(e.response.text, e.response.status_code) from None #190

Closed
opened 2026-02-15 16:28:35 -05:00 by yindo · 12 comments
Owner

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

def test():
    resp = ollama.chat(
        model='llama3.1:8b', messages=[{'role': 'user', 'content': 'output the number from 1 to 5'}])  
    print(resp)

test()

here are the downloaded LLM:

/code/gencf# ollama list
NAME               ID              SIZE      MODIFIED
llama3.1:8b        46e0c10c039e    4.9 GB    53 minutes ago
llama3.1:latest    46e0c10c039e    4.9 GB    55 minutes ago
mistral:latest     f974a74358d6    4.1 GB    9 hours ago

Error:

Traceback (most recent call last):
  File "/code/gencf/multi_gpu_proc_generate.py", line 270, in <module>
    test()
  File "/code/gencf/multi_gpu_proc_generate.py", line 228, in test
    resp = ollama.chat(
  File "/root/anaconda3/envs/llmxq12/lib/python3.10/site-packages/ollama/_client.py", line 332, in chat
    return self._request(
  File "/root/anaconda3/envs/llmxq12/lib/python3.10/site-packages/ollama/_client.py", line 177, in _request
    return cls(**self._request_raw(*args, **kwargs).json())
  File "/root/anaconda3/envs/llmxq12/lib/python3.10/site-packages/ollama/_client.py", line 122, in _request_raw
    raise ResponseError(e.response.text, e.response.status_code) from None
ollama._types.ResponseError

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 ``` def test(): resp = ollama.chat( model='llama3.1:8b', messages=[{'role': 'user', 'content': 'output the number from 1 to 5'}]) print(resp) test() ``` here are the downloaded LLM: ``` /code/gencf# ollama list NAME ID SIZE MODIFIED llama3.1:8b 46e0c10c039e 4.9 GB 53 minutes ago llama3.1:latest 46e0c10c039e 4.9 GB 55 minutes ago mistral:latest f974a74358d6 4.1 GB 9 hours ago ``` ## Error: ``` Traceback (most recent call last): File "/code/gencf/multi_gpu_proc_generate.py", line 270, in <module> test() File "/code/gencf/multi_gpu_proc_generate.py", line 228, in test resp = ollama.chat( File "/root/anaconda3/envs/llmxq12/lib/python3.10/site-packages/ollama/_client.py", line 332, in chat return self._request( File "/root/anaconda3/envs/llmxq12/lib/python3.10/site-packages/ollama/_client.py", line 177, in _request return cls(**self._request_raw(*args, **kwargs).json()) File "/root/anaconda3/envs/llmxq12/lib/python3.10/site-packages/ollama/_client.py", line 122, in _request_raw raise ResponseError(e.response.text, e.response.status_code) from None ollama._types.ResponseError ```
yindo closed this issue 2026-02-15 16:28:35 -05:00
Author
Owner

@immmor commented on GitHub (Jan 2, 2025):

Got the same error for Win10.

@immmor commented on GitHub (Jan 2, 2025): Got the same error for Win10.
Author
Owner

@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

@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
Author
Owner

@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>

@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>`
Author
Owner

@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): 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 <module> 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**
Author
Owner

@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厉害吗?"}))`

Image

@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厉害吗?"}))` ![Image](https://github.com/user-attachments/assets/4e805af0-82a6-41dd-91cd-4f5381e6ba0e)
Author
Owner

@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?

@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?
Author
Owner

@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

@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
Author
Owner

@ParthSareen commented on GitHub (Jan 20, 2025):

@Zyg187 could you try passing in the url when instantiating the ollama client under host?

@ParthSareen commented on GitHub (Jan 20, 2025): @Zyg187 could you try passing in the url when instantiating the ollama client under `host`?
Author
Owner

@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 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?
Author
Owner

@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?', }, ])

@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?', }, ])`
Author
Owner

@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 (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
Author
Owner

@ParthSareen commented on GitHub (Feb 13, 2025):

Going to close for now, feel free to ping if you're still running into this!

@ParthSareen commented on GitHub (Feb 13, 2025): Going to close for now, feel free to ping if you're still running into this!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#190