( provider: string, modelName: string, temperature: number, otherFields?: any )
| 9 | import { Replicate } from "@langchain/community/llms/replicate"; |
| 10 | |
| 11 | export const chatModelProvider = ( |
| 12 | provider: string, |
| 13 | modelName: string, |
| 14 | temperature: number, |
| 15 | otherFields?: any |
| 16 | ) => { |
| 17 | modelName = modelName.replace("-dbase", ""); |
| 18 | modelName = modelName.replace(/_dialoqbase_[0-9]+$/, ""); |
| 19 | |
| 20 | switch (provider.toLowerCase()) { |
| 21 | case "openai": |
| 22 | return new ChatOpenAI({ |
| 23 | modelName: modelName, |
| 24 | temperature: temperature, |
| 25 | ...otherFields, |
| 26 | configuration: { |
| 27 | ...otherFields.configuration, |
| 28 | baseURL: process.env.OPENAI_API_URL, |
| 29 | }, |
| 30 | }); |
| 31 | case "anthropic": |
| 32 | return new ChatAnthropic({ |
| 33 | modelName: modelName, |
| 34 | temperature: temperature, |
| 35 | ...otherFields, |
| 36 | }) as any; |
| 37 | case "google-bison": |
| 38 | return new ChatGooglePaLM({ |
| 39 | temperature: temperature, |
| 40 | apiKey: process.env.GOOGLE_API_KEY, |
| 41 | ...otherFields, |
| 42 | }); |
| 43 | case "huggingface-api": |
| 44 | return new HuggingFaceInference({ |
| 45 | modelName: modelName, |
| 46 | temperature: temperature, |
| 47 | ...otherFields, |
| 48 | }); |
| 49 | case "fireworks": |
| 50 | return new DialoqbaseFireworksModel({ |
| 51 | model: modelName, |
| 52 | temperature: temperature, |
| 53 | is_chat: !notChatModels.includes(modelName), |
| 54 | ...otherFields, |
| 55 | }); |
| 56 | case "openai-instruct": |
| 57 | return new OpenAI({ |
| 58 | modelName: modelName, |
| 59 | temperature: temperature, |
| 60 | ...otherFields, |
| 61 | configuration: { |
| 62 | baseURL: process.env.OPENAI_API_URL, |
| 63 | }, |
| 64 | }); |
| 65 | case "local": |
| 66 | return new ChatOpenAI({ |
| 67 | modelName: modelName, |
| 68 | temperature: temperature, |
no outgoing calls
no test coverage detected