-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add anthropic provider and refactor api field of publishJSON #205
Conversation
27f324b
to
3fa2ec1
Compare
}; | ||
|
||
export type ApiKind = "llm" | "email"; | ||
export type Owner = EmailOwner | LLMOwner; |
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 feel like Owner
is not the correct keyword here, because EmailOwner
or LLMOwner
feels like referring to a user, not a company. I was thinking of Provider
at first, but we already use that for classes. Can we think of sth else?
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 took the owner from the old api. It's not the best name but I couldn't think of a better alternative. Something like ProviderOwner
would be too much I think
src/client/api/llm.ts
Outdated
const headerValue = this.owner === "anthropic" ? this.token : `Bearer ${this.token}`; | ||
|
||
const headers = { [header]: headerValue }; | ||
if (this.organization) { |
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.
Can we check if the owner is openai?
src/client/api/llm.ts
Outdated
|
||
// UTILS | ||
|
||
function updateWithAnalytics( |
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.
Can we seperate the utilties?
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.
you mean different files right?
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.
yup
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.
moved them to utils.ts
Anthropic Provider
You can now publish requests to Anthropic API with
Refactor
This PR is mainly concerned with how we handle the api field in publishJSON, batchJSON and enqueue:
Previously, the providers (
upstash
,openai
,custom
) returned the following object:resend
provider returned:The publish request would be updated with this provider in a series of methods. Now there is a single method.
Now, the providers return
LLMProvider
andEmailProvider
classes which extendBaseProvider
.BaseProvider
has some methods we utilize ingetProviderInfo
method.getProviderInfo
transform theapi
field ofPublishRequest
intoProviderInfo
which is similar to the originalProviderReturnType
:Notive the
appendHeaders
. Now, the headers are created in theBaseProvider
and it's subclasses, instead ofappendLLMOptionsIfNeeded
andappendAPIOptions
.