feat(agents): support local LLMs

This commit is contained in:
ItzCrazyKns 2024-04-20 11:18:52 +05:30
parent 28a7175afc
commit d37a1a8020
No known key found for this signature in database
GPG key ID: 8162927C7CCE3065
15 changed files with 135 additions and 100 deletions

View file

@ -1,6 +1,6 @@
import fs from 'fs';
import path from 'path';
import toml, { JsonMap } from '@iarna/toml';
import toml from '@iarna/toml';
const configFileName = 'config.toml';
@ -8,18 +8,21 @@ interface Config {
GENERAL: {
PORT: number;
SIMILARITY_MEASURE: string;
CHAT_MODEL_PROVIDER: string;
CHAT_MODEL: string;
};
API_KEYS: {
OPENAI: string;
};
API_ENDPOINTS: {
SEARXNG: string;
OLLAMA: string;
};
}
const loadConfig = () =>
toml.parse(
fs.readFileSync(path.join(process.cwd(), `${configFileName}`), 'utf-8'),
fs.readFileSync(path.join(__dirname, `../${configFileName}`), 'utf-8'),
) as any as Config;
export const getPort = () => loadConfig().GENERAL.PORT;
@ -27,6 +30,13 @@ export const getPort = () => loadConfig().GENERAL.PORT;
export const getSimilarityMeasure = () =>
loadConfig().GENERAL.SIMILARITY_MEASURE;
export const getChatModelProvider = () =>
loadConfig().GENERAL.CHAT_MODEL_PROVIDER;
export const getChatModel = () => loadConfig().GENERAL.CHAT_MODEL;
export const getOpenaiApiKey = () => loadConfig().API_KEYS.OPENAI;
export const getSearxngApiEndpoint = () => loadConfig().API_ENDPOINTS.SEARXNG;
export const getOllamaApiEndpoint = () => loadConfig().API_ENDPOINTS.OLLAMA;