-
Couldn't load subscription status.
- Fork 2.1k
Improve error messaging for short output token lengths #1790
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
base: main
Are you sure you want to change the base?
Changes from 7 commits
46cac66
e99af03
33ceea0
0e072b8
78475f2
4dfca23
4e630bf
a835763
01fe39a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,6 +143,19 @@ def test_multiple_code_blobs(self): | |
| assert result == "Foo\n\ncode_a\n\ncode_b" | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "raw_text", | ||
| [ | ||
| "This is just some conversational text.", | ||
| "Here is an invalid code snippet `x = 10", | ||
| ], | ||
| ) | ||
| def test_parse_code_blobs_without_valid_code(raw_text): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added some simple tests to check the exact string. If the error message is changed in |
||
| # Note: If the exact string is changed a parsing warning needs to be modified in agents.py | ||
| with pytest.raises(ValueError, match="Make sure to include code with the correct pattern"): | ||
| parse_code_blobs(raw_text, ("<code>", "</code>")) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="function") | ||
| def ipython_shell(): | ||
| """Reset IPython shell before and after each test.""" | ||
|
|
@@ -486,6 +499,21 @@ def test_parse_json_blob_with_invalid_json(raw_json): | |
| parse_json_blob(raw_json) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "raw_json", | ||
| [ | ||
| "this string has no json blob", | ||
| "this string has an opening brace { but no closing one", | ||
| "", | ||
| "some text {", | ||
| ], | ||
| ) | ||
| def test_parse_json_blob_without_json_blob(raw_json): | ||
| # Note: If the exact string is changed a parsing warning needs to be modified in agents.py | ||
| with pytest.raises(ValueError, match="The model output does not contain any JSON blob."): | ||
| parse_json_blob(raw_json) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "name,expected", | ||
| [ | ||
|
|
||
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.
Warnings will look like the following

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.
@suryabdev did you try just logging it using
logger.warn? This would help break the flow of agent messages and show to the user that this message is directed towards them!Uh oh!
There was an error while loading. Please reload this page.
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.
Hi @aymeric-roucher, it would be a good user experience to break the flow.
But I thought it would be better to allow the LLM to retry in this case, since I'm not sure the error message is solely due to an insufficient token config.
For example,
<code>tags.What do you think?