ResponseError(without error information) when running with python
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.5k
- Forks
- 1.2k
- Avg merge
- 4m
- Merged PRs (30d)
- 1
Description
simple codes like below
ollama.chat(model='mistral:instruct', messages=[{'role': 'user', 'content': 'Why is the sky blue?'}])
OR
import ollama
response = ollama.chat(model='mistral:instruct', messages=[
{
'role': 'user',
'content': 'Why is the sky blue?',
},
])
print(response['message']['content'])`
An error is being thrown, but there is no specific issue being printed.
"It works perfectly fine in the command-line interface (CLI) when I run ollama run mistral:instruct
Here is the error
ResponseError Traceback (most recent call last)
Cell In[2], [line 1](vscode-notebook-cell:?execution_count=2&line=1)
----> [1](vscode-notebook-cell:?execution_count=2&line=1) ollama.chat(model='mistral:instruct', messages=[{'role': 'user', 'content': 'Why is the sky blue?'}])
File [~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:177](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:177), in Client.chat(self, model, messages, stream, format, options, keep_alive)
[174](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:174) if images := message.get('images'):
[175](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:175) message['images'] = [_encode_image(image) for image in images]
--> [177](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:177) return self._request_stream(
[178](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:178) 'POST',
[179](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:179) '[/api/chat](https://file+.vscode-resource.vscode-cdn.net/api/chat)',
[180](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:180) json={
[181](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:181) 'model': model,
[182](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:182) 'messages': messages,
[183](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:183) 'stream': stream,
[184](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:184) 'format': format,
[185](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:185) 'options': options or {},
[186](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:186) 'keep_alive': keep_alive,
[187](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:187) },
[188](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:188) stream=stream,
[189](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:189) )
File [~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:97](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:97), in Client._request_stream(self, stream, *args, **kwargs)
[91](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:91) def _request_stream(
[92](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:92) self,
[93](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:93) *args,
[94](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:94) stream: bool = False,
[95](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:95) **kwargs,
[96](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:96) ) -> Union[Mapping[str, Any], Iterator[Mapping[str, Any]]]:
---> [97](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:97) return self._stream(*args, **kwargs) if stream else self._request(*args, **kwargs).json()
File [~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:73](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:73), in Client._request(self, method, url, **kwargs)
[71](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:71) response.raise_for_status()
[72](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:72) except httpx.HTTPStatusError as e:
---> [73](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:73) raise ResponseError(e.response.text, e.response.status_code) from None
[75](https://file+.vscode-resource.vscode-cdn.net/Users/kaleemullahqasim/Documents/GitHub/upwork_Sentiment_job/~/Documents/GitHub/upwork_Sentiment_job/.venv/lib/python3.12/site-packages/ollama/_client.py:75) return response
ResponseError:`
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in ollama/_client.py at Client._request, especially the handling around response.raise_for_status() and ResponseError(e.response.text, e.response.status_code). Reproduce the provided ollama.chat example, inspect the HTTP response body, and verify that failures expose useful error information instead of an empty message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100