-
Notifications
You must be signed in to change notification settings - Fork 657
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
client: improve error messaging on connection failure #398
Conversation
2d717e6
to
efe8e57
Compare
def __str__(self) -> str: | ||
return f'{self.error} (status code: {self.status_code})' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status code does not get printed currently - this exposes it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does it currently output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
efe8e57
to
db25d87
Compare
cd62955
to
03e494e
Compare
03e494e
to
1eb18ec
Compare
def __str__(self) -> str: | ||
return f'{self.error} (status code: {self.status_code})' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does it currently output?
tests/test_client.py
Outdated
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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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'}]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - didn't know of this pattern this is cool
73e207a
to
0c343dd
Compare
*iImprove error messaging on connection failure
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