Skip to content

Commit

Permalink
Merge pull request #67 from upstash/fix-anthropic-model
Browse files Browse the repository at this point in the history
fix: anthropic typo and add helicone to it
  • Loading branch information
ogzhanolguncu authored Aug 29, 2024
2 parents 28ed03d + 6a10bb1 commit 4353873
Showing 1 changed file with 23 additions and 2 deletions.
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,
},
});
};

0 comments on commit 4353873

Please sign in to comment.