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

fix: anthropic typo and add helicone to it #67

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ type Providers =
| "groq"
| "togetherai"
| "openrouter"
| "mistral";
| "mistral"
| "anthropic";
type AnalyticsConfig =
| { name: "helicone"; token: string }
| { name: "langsmith"; token: string; apiUrl?: string }
Expand Down Expand Up @@ -108,6 +109,15 @@ const setupAnalytics = (
},
};
}
case "anthropic": {
return {
baseURL: "https://anthropic.helicone.ai",
defaultHeaders: {
"Helicone-Auth": `Bearer ${analytics.token}`,
Authorization: `Bearer ${providerApiKey}`,
},
};
}
case "upstash": {
return {
baseURL: "https://qstash.helicone.ai/llm/v1",
Expand Down Expand Up @@ -266,9 +276,20 @@ export const mistralai = (model: string, options?: Omit<ModelOptions, "baseUrl">
});
};

export const antrophic = (model: string, options?: Omit<ModelOptions, "baseUrl">) => {
export const anthropic = (model: string, options?: Omit<ModelOptions, "baseUrl">) => {
if (!options?.apiKey) {
throw new Error("Failed to create Anthropic client: Anthropic key not found.");
}
const analyticsSetup = options.analytics
? setupAnalytics(options.analytics, options.apiKey, undefined, "anthropic")
: undefined;

return new ChatAnthropic({
model,
...options,
clientOptions: {
baseURL: analyticsSetup?.baseURL,
defaultHeaders: analyticsSetup?.defaultHeaders,
},
});
};
Loading