-
-
Notifications
You must be signed in to change notification settings - Fork 696
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
llms/anthropic: adds full support for messages api #707
Conversation
I updated this to remove the fatals from the stream processing. I think it's better to pass the errors back instead of crashing and just letting the user handle them. This is different than the other LLM implementations like OpenAI which I used as a guideline. |
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.
Great contribution! some nits but they're for the internal client.
|
||
usage, ok := event["usage"].(map[string]interface{}) | ||
if !ok { | ||
return response, errors.New("invalid usage field type") |
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.
while an internal package, generally it's better to define these errors up top so calling code can use errors.Is checks.
llms/anthropic/anthropicllm.go
Outdated
token: os.Getenv(tokenEnvVarName), | ||
baseURL: anthropicclient.DefaultBaseURL, | ||
httpClient: http.DefaultClient, | ||
useCompletionsAPI: true, |
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.
I'd actually like to default to the messages API
PR Checklist
memory: add interfaces for X, Y
orutil: add whizzbang helpers
).Fixes #123
).golangci-lint
checks.This adds full support for the new messages API including streaming.
It backwards compatible with client option flag for using message api.
It also updates the default model to 1.3 as 1.0 isn't supported by either completions or messages API.
Closes #695