Skip to content
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

Better handling of parameter errors #17

Open
swombat opened this issue May 13, 2024 · 1 comment
Open

Better handling of parameter errors #17

swombat opened this issue May 13, 2024 · 1 comment

Comments

@swombat
Copy link
Contributor

swombat commented May 13, 2024

As I tested the new streaming functionality, I found that when the parameters are not quite right it semi-silently fails:

3.3.0 :044 > params
 => 
{:model=>"claude-3-haiku-20240307",
 :temperature=>0.9,
 :max_tokens=>4096,
 :messages=>
  [{:role=>"user",
    :content=>
     "Some kind of preamble that doesn't have arguments.\n\nSample Script Contents 1\n\nAnother section yay\n\nSample Script Contents 1 and Input Item in Special Instruction\n\nThis section has a lot of lines\nIt is here to test the lines.\n\nLet's have some more text:\n\nThis will prevent RuboCop from checking the Sample Script Contents 2 syntax style throughout your entire codebase. Make sure to place this under the correct hierarchy in your .rubocop.yml file, typically at the root level or under a specific target if you have Sample Script Contents 1 configurations for different parts of your project."}],
 :stream=>true,
 :preprocess_stream=>:text} 
3.3.0 :045 > @client.messages(parameters:params)
 => {"type"=>"error", "error"=>{"type"=>"invalid_request_error", "message"=>"preprocess_stream: Extra inputs are not permitted"}} 

I wonder if these kinds of errors (invalid requests in particular) should actually result in an Anthropic::Error being raised.

I can add this code if you think it makes sense.

@swombat
Copy link
Contributor Author

swombat commented May 13, 2024

To be clear this would also happen with other weird mistakes like passing system: nil in the params, which is an easy mistake to make and not a bug in the anthropic gem like the preprocess_stream issue above (which is now fixed in the latest code in my fork).

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

No branches or pull requests

1 participant