From ddba7c12b9e6d780a6a2b7cb51dd8ed33e85c1c8 Mon Sep 17 00:00:00 2001 From: ogzhanolguncu Date: Tue, 27 Aug 2024 17:03:26 +0300 Subject: [PATCH] feat: add anthropic model --- bun.lockb | Bin 241361 -> 243125 bytes package.json | 3 ++- src/models.ts | 8 ++++++++ src/types.ts | 3 ++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bun.lockb b/bun.lockb index 49b04180aaa5ec749bb47d3c042ca56a16af7578..01789b7864b9a3b0e15e8b9968ad095b34042092 100755 GIT binary patch delta 14805 zcmeHO2Xs}%y54(IAk+ZSBotE+NPq;A5JCxrh=NE*5(pOpp@m3K0-*#?Xd*?58yF(J z!v&;73_(STG?6NZNcVzX6y6h*dIjG1o%82$^akEtcP)Kyy_H${_Ba1G|J1$DK67R! z$IqAA`eUh?p}`-wU3&Wcv3I@tG+EI9>&*vR{M^3srqLIRy4^c5wR_s^j0aV=x)=-z zvpV^e8`eSD4acR7VPs98HMv^AK&T~Q#Dl%TNogYo^@7ht(=a?>ADeaDuS}*GDanHd zr}i<7A(m-A_81K}FSvBIJXDk!XT_@K<_v4Hs%F-=Hscy=ol&*SAj`vLV?bLsM>Q{l zizAOG*oW1nINHlY$*xmHX8Cl}7OPS)*h_JYZ=ipe_rC<-L=&)U;JU%`trlZm zuo9}pczEN6wMN0Fl@t_Z_O{L-Wv=BL6ytUlDUJ24&1QskEX>2o4vH~bT4!*bVEG2e znA>s^f}74P+6;NoHpA+%tfu8zwW!-N^r)G2zClBezav)1Ui9VQD36NhStB}ImtTqU zNPyK4R#|Il%_xtBVi{IIc$E4&&nmyYv4_`o!)O2(S1TYi%B>BordFlshHA}r>znNj zY=NkhKr4+Z00Y?-2&RGH%($0Eb%0z0U?3|Xga!hc>7g_bocUGQ!|ke_Z3dnvgAXJ# zWCAScO@P6f*`RTD)xm7=M1c9;5}izave;ynHx-~h9bh0c-weY>lMzQC<0&`Z6Wf`Y zVLm`!0I=Xi02{VU>=j_9uLRtIb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ot zH2$T*nx3Vbt59oe7HW(}H{h2+PPH9}i*|kAP+==0+4?R^KdZW0-NtK22)`xp z8z-khr%qcx`SPu{yR?Kzx%KX}`r*izYO+fi%lN*!G1Yxwb8K8=_+=32WGp||}m z`B+`Eb*(xTeBF&G@p)##s^2#s6Ugpr(G1r$*w@O-)=#Qv>rgf>UZyKylK#6=eXWQb zeNK&X`RD4P70T?!f@!*^oThbsn*N*gl(M^GzNEM|%+U2z$eowrb_<7C|2Y!C%d{Jt5Sh(>8^95O1B*77WJa#KMPb~ zH6|^wMy%A$LyFN?0VwE5-lDYkF0{GGo`{QShRbMo=I82bt6-H5)|Y%-lU~z3yj54% z&2_p+S^013`l_#M&6_aLFGDSzsP8&2++Mh^c*EJZO-gAmgw50KbZG}AyRsMPVG3y> z%XP3zFVf#CRnzs|VjbnJI=dit@%>NlkmI;TJp00-T^n5bnd&%?%DeQfD(>qR=n6fm zrw2m(-8Z_MQm0%$ozwe$F+_ZJ5zk0XSC{YfIB%V`$$IdL&e3CvtT|V7T&1qxyGOOA ym#m{#bbD8=tNM(pG~kk3O;~N|>w1oB^>w}8$I37Cs<^SISK~t0g7sd(`hNgT;CI>p diff --git a/package.json b/package.json index 663183c..7ff16ac 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,7 @@ }, "optionalDependencies": { "langsmith": "^0.1.41", - "@langchain/mistralai": "^0.0.28" + "@langchain/mistralai": "^0.0.28", + "@langchain/anthropic": "^0.2.15" } } diff --git a/src/models.ts b/src/models.ts index d48abfa..db12e9e 100644 --- a/src/models.ts +++ b/src/models.ts @@ -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: @@ -263,3 +264,10 @@ export const mistralai = (model: string, options?: Omit ...options, }); }; + +export const antrophic = (model: string, options?: Omit) => { + return new ChatAnthropic({ + model, + ...options, + }); +}; diff --git a/src/types.ts b/src/types.ts index 48ecac8..14455f7 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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 = { [__brand]: B }; @@ -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({