Skip to content

Commit

Permalink
Merge pull request #64 from upstash/add-anthropic-model
Browse files Browse the repository at this point in the history
feat: add anthropic model
  • Loading branch information
ogzhanolguncu authored Aug 27, 2024
2 parents abd1c56 + ddba7c1 commit 36277cb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
Binary file modified bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
},
"optionalDependencies": {
"langsmith": "^0.1.41",
"@langchain/mistralai": "^0.0.28"
"@langchain/mistralai": "^0.0.28",
"@langchain/anthropic": "^0.2.15"
}
}
8 changes: 8 additions & 0 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ChatOpenAI } from "@langchain/openai";
import { Client as LangsmithClient } from "langsmith";
import type { OLLAMA_MODELS } from "./constants";
import { ChatMistralAI } from "@langchain/mistralai";
import { ChatAnthropic } from "@langchain/anthropic";

// Initialize global Langsmith tracer
// We use a global variable because:
Expand Down Expand Up @@ -263,3 +264,10 @@ export const mistralai = (model: string, options?: Omit<ModelOptions, "baseUrl">
...options,
});
};

export const antrophic = (model: string, options?: Omit<ModelOptions, "baseUrl">) => {
return new ChatAnthropic({
model,
...options,
});
};
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Redis } from "@upstash/redis";
import type { Index } from "@upstash/vector";
import type { CustomPrompt } from "./rag-chat";
import type { ChatMistralAI } from "@langchain/mistralai";
import type { ChatAnthropic } from "@langchain/anthropic";

declare const __brand: unique symbol;
type Brand<B> = { [__brand]: B };
Expand Down Expand Up @@ -96,7 +97,7 @@ export type RAGChatConfig = {
*/

// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
model?: ChatOpenAI | ChatMistralAI | OpenAIChatLanguageModel;
model?: ChatOpenAI | ChatMistralAI | ChatAnthropic | OpenAIChatLanguageModel;
/**
* Ratelimit instance
* @example new Ratelimit({
Expand Down

0 comments on commit 36277cb

Please sign in to comment.