Skip to content

Conversation

@ParthSareen
Copy link
Member

@ParthSareen ParthSareen commented Dec 29, 2024

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

  • Tests

@ParthSareen ParthSareen changed the title Improve error messaging on connection failure client: Improve error messaging on connection failure Dec 29, 2024
@ParthSareen ParthSareen force-pushed the parth/qol-improve-connection-error-message branch from 2d717e6 to efe8e57 Compare December 29, 2024 22:52
Comment on lines +528 to +540
def __str__(self) -> str:
return f'{self.error} (status code: {self.status_code})'
Copy link
Member Author

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

Copy link
Collaborator

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No code, just the message from the server:
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vs with the change:
image

@ParthSareen ParthSareen marked this pull request as ready for review December 29, 2024 22:55
@ParthSareen ParthSareen force-pushed the parth/qol-improve-connection-error-message branch from efe8e57 to db25d87 Compare December 29, 2024 23:02
@ParthSareen ParthSareen force-pushed the parth/qol-improve-connection-error-message branch 2 times, most recently from cd62955 to 03e494e Compare January 7, 2025 18:50
@ParthSareen ParthSareen force-pushed the parth/qol-improve-connection-error-message branch from 03e494e to 1eb18ec Compare January 15, 2025 19:42
@ParthSareen ParthSareen changed the title client: Improve error messaging on connection failure client: improve error messaging on connection failure Jan 15, 2025
Comment on lines +528 to +540
def __str__(self) -> str:
return f'{self.error} (status code: {self.status_code})'
Copy link
Collaborator

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?

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'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

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

@ParthSareen ParthSareen force-pushed the parth/qol-improve-connection-error-message branch from 73e207a to 0c343dd Compare January 16, 2025 21:41
@ParthSareen ParthSareen merged commit 967fd65 into main Jan 16, 2025
7 checks passed
@ParthSareen ParthSareen deleted the parth/qol-improve-connection-error-message branch January 16, 2025 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants