add baseurl
This commit is contained in:
parent
9c1936ec2c
commit
fb344e7442
2 changed files with 29 additions and 1 deletions
|
@ -18,6 +18,9 @@ interface Config {
|
|||
SEARXNG: string;
|
||||
OLLAMA: string;
|
||||
};
|
||||
BASE_URL: {
|
||||
OPENAI: string;
|
||||
};
|
||||
}
|
||||
|
||||
type RecursivePartial<T> = {
|
||||
|
@ -36,6 +39,8 @@ export const getSimilarityMeasure = () =>
|
|||
|
||||
export const getOpenaiApiKey = () => loadConfig().API_KEYS.OPENAI;
|
||||
|
||||
export const getOpenaiBaseUrl = () => loadConfig().BASE_URL.OPENAI;
|
||||
|
||||
export const getGroqApiKey = () => loadConfig().API_KEYS.GROQ;
|
||||
|
||||
export const getAnthropicApiKey = () => loadConfig().API_KEYS.ANTHROPIC;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { ChatOpenAI, OpenAIEmbeddings } from '@langchain/openai';
|
||||
import { getOpenaiApiKey } from '../../config';
|
||||
import { getOpenaiApiKey, getOpenaiBaseUrl } from '../../config';
|
||||
import logger from '../../utils/logger';
|
||||
|
||||
export const loadOpenAIChatModels = async () => {
|
||||
const openAIApiKey = getOpenaiApiKey();
|
||||
const openaibaseURL = getOpenaiBaseUrl();
|
||||
|
||||
if (!openAIApiKey) return {};
|
||||
|
||||
|
@ -11,26 +12,41 @@ export const loadOpenAIChatModels = async () => {
|
|||
const chatModels = {
|
||||
'GPT-3.5 turbo': new ChatOpenAI({
|
||||
openAIApiKey,
|
||||
configuration: {
|
||||
baseURL: openaibaseURL,
|
||||
},
|
||||
modelName: 'gpt-3.5-turbo',
|
||||
temperature: 0.7,
|
||||
}),
|
||||
'GPT-4': new ChatOpenAI({
|
||||
openAIApiKey,
|
||||
configuration: {
|
||||
baseURL: openaibaseURL,
|
||||
},
|
||||
modelName: 'gpt-4',
|
||||
temperature: 0.7,
|
||||
}),
|
||||
'GPT-4 turbo': new ChatOpenAI({
|
||||
openAIApiKey,
|
||||
configuration: {
|
||||
baseURL: openaibaseURL,
|
||||
},
|
||||
modelName: 'gpt-4-turbo',
|
||||
temperature: 0.7,
|
||||
}),
|
||||
'GPT-4 omni': new ChatOpenAI({
|
||||
openAIApiKey,
|
||||
configuration: {
|
||||
baseURL: openaibaseURL,
|
||||
},
|
||||
modelName: 'gpt-4o',
|
||||
temperature: 0.7,
|
||||
}),
|
||||
'GPT-4 omni mini': new ChatOpenAI({
|
||||
openAIApiKey,
|
||||
configuration: {
|
||||
baseURL: openaibaseURL,
|
||||
},
|
||||
modelName: 'gpt-4o-mini',
|
||||
temperature: 0.7,
|
||||
}),
|
||||
|
@ -45,6 +61,7 @@ export const loadOpenAIChatModels = async () => {
|
|||
|
||||
export const loadOpenAIEmbeddingsModels = async () => {
|
||||
const openAIApiKey = getOpenaiApiKey();
|
||||
const openaibaseURL = getOpenaiBaseUrl();
|
||||
|
||||
if (!openAIApiKey) return {};
|
||||
|
||||
|
@ -52,10 +69,16 @@ export const loadOpenAIEmbeddingsModels = async () => {
|
|||
const embeddingModels = {
|
||||
'Text embedding 3 small': new OpenAIEmbeddings({
|
||||
openAIApiKey,
|
||||
configuration: {
|
||||
baseURL: openaibaseURL,
|
||||
},
|
||||
modelName: 'text-embedding-3-small',
|
||||
}),
|
||||
'Text embedding 3 large': new OpenAIEmbeddings({
|
||||
openAIApiKey,
|
||||
configuration: {
|
||||
baseURL: openaibaseURL,
|
||||
},
|
||||
modelName: 'text-embedding-3-large',
|
||||
}),
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue