client: improve error messaging on connection failure#398
Merged
ParthSareen merged 5 commits intomainfrom Jan 16, 2025
Merged
Conversation
2d717e6 to
efe8e57
Compare
ParthSareen
commented
Dec 29, 2024
Comment on lines
+528
to
+540
| def __str__(self) -> str: | ||
| return f'{self.error} (status code: {self.status_code})' |
Member
Author
There was a problem hiding this comment.
status code does not get printed currently - this exposes it
Collaborator
There was a problem hiding this comment.
What does it currently output?
Member
Author
efe8e57 to
db25d87
Compare
jmorganca
reviewed
Dec 29, 2024
This was referenced Jan 3, 2025
cd62955 to
03e494e
Compare
03e494e to
1eb18ec
Compare
mxyng
approved these changes
Jan 16, 2025
Comment on lines
+528
to
+540
| def __str__(self) -> str: | ||
| return f'{self.error} (status code: {self.status_code})' |
Collaborator
There was a problem hiding this comment.
What does it currently output?
tests/test_client.py
Outdated
Comment on lines
+1119
to
+1121
| with pytest.raises(ConnectionError) as exc_info: | ||
| client.chat('model', messages=[{'role': 'user', 'content': 'prompt'}]) | ||
| assert str(exc_info.value) == 'Failed to connect to Ollama. Please check that Ollama is downloaded, running and accessible. https://ollama.com/download' |
Collaborator
There was a problem hiding this comment.
Suggested change
| with pytest.raises(ConnectionError) as exc_info: | |
| client.chat('model', messages=[{'role': 'user', 'content': 'prompt'}]) | |
| assert str(exc_info.value) == 'Failed to connect to Ollama. Please check that Ollama is downloaded, running and accessible. https://ollama.com/download' | |
| with pytest.raises(ConnectionError, match='Failed to connect to Ollama. Please check that Ollama is downloaded, running and accessible. https://ollama.com/download'): | |
| client.chat('model', messages=[{'role': 'user', 'content': 'prompt'}]) |
Member
Author
There was a problem hiding this comment.
Nice - didn't know of this pattern this is cool
73e207a to
0c343dd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Error messaging is unclear - especially on connection error
Also exposed the status code coming down but I'm not sure if we want that behavior