Open strukturedkaos opened 3 months ago
Thanks, @strukturedkaos. Have you seen this occur @swombat ?
Any chance of this being fixed in the next few days? We can't use the streaming api right now.
Also getting this error
@redders123 will see if I can fix this
@alexrudall Anything I can help with? Are you able to reproduce the issue?
In case it helps:
ruby 3.2.2 Rails 6.1.7.3
Hey @strukturedkaos -- struggling to find the time to look at this - but I'm very open to a PR if you're able to figure out a fix! If not I will get to it when I can.
I ran into this as well, it's because the streaming proc method signature changed in Faraday 2.5.0, and any older version only provides the first two arguments to the proc (see 6799f58).
So you could update the gemspec to require ~> 2.5.0 of Faraday, although that wouldn't work for me as I have other gems that require < 2.0 of Faraday that I'm not able to easily upgrade.
The other option is to update Anthropic::HTTP#handle_faraday_error
to accomodate the case where env
isn't provided as a third argument. At first glance I don't see any way to get the http request status in order to check if there is an error with an older version of Faraday, so you might just have to assume the streaming request is successful on older versions of Faraday?
@alexrudall if you have any suggestions about how you'd like to handle older versions of Faraday and I can put together a PR.
I created a PR that makes it functional for anyone using Faraday < 2.5.0: https://github.com/alexrudall/anthropic/pull/21
Let me know if you have suggested changes on that one since it skips out on handling errors while receiving streaming results if Faraday < 2.5.0.
@geeosh your fix worked for me. Thank you. Hopefully we can get the PR merged soon.
Line 154 in http.rb on
env
isnil
on valid requests. This causesmerge
to error on line 157Example: