Lint and fix recent changes from main

This commit is contained in:
Oliver Jägle 2024-11-22 17:48:46 +01:00
parent f63474ec9a
commit 5bd4541abf
No known key found for this signature in database
GPG Key ID: 866E2BD1777473E9

View File

@ -11,18 +11,19 @@ import { createOpenRouter } from '@openrouter/ai-sdk-provider';
import { createMistral } from '@ai-sdk/mistral'; import { createMistral } from '@ai-sdk/mistral';
import { createCohere } from '@ai-sdk/cohere'; import { createCohere } from '@ai-sdk/cohere';
export const DEFAULT_NUM_CTX = process.env.DEFAULT_NUM_CTX ? export const DEFAULT_NUM_CTX = process.env.DEFAULT_NUM_CTX ? parseInt(process.env.DEFAULT_NUM_CTX, 10) : 32768;
parseInt(process.env.DEFAULT_NUM_CTX, 10) :
32768;
export function getAnthropicModel(apiKey: string, model: string) { export function getAnthropicModel(apiKey: OptionalApiKey, model: string) {
const anthropic = createAnthropic({ const anthropic = createAnthropic({
apiKey, apiKey,
}); });
return anthropic(model); return anthropic(model);
} }
export function getOpenAILikeModel(baseURL: string, apiKey: string | undefined, model: string) {
type OptionalApiKey = string | undefined;
export function getOpenAILikeModel(baseURL: string, apiKey: OptionalApiKey, model: string) {
const openai = createOpenAI({ const openai = createOpenAI({
baseURL, baseURL,
apiKey, apiKey,
@ -31,7 +32,7 @@ export function getOpenAILikeModel(baseURL: string, apiKey: string | undefined,
return openai(model); return openai(model);
} }
export function getCohereAIModel(apiKey: string | undefined, model: string) { export function getCohereAIModel(apiKey: OptionalApiKey, model: string) {
const cohere = createCohere({ const cohere = createCohere({
apiKey, apiKey,
}); });
@ -39,7 +40,7 @@ export function getCohereAIModel(apiKey: string | undefined, model: string) {
return cohere(model); return cohere(model);
} }
export function getOpenAIModel(apiKey: string | undefined, model: string) { export function getOpenAIModel(apiKey: OptionalApiKey, model: string) {
const openai = createOpenAI({ const openai = createOpenAI({
apiKey, apiKey,
}); });
@ -47,7 +48,7 @@ export function getOpenAIModel(apiKey: string | undefined, model: string) {
return openai(model); return openai(model);
} }
export function getMistralModel(apiKey: string | undefined, model: string) { export function getMistralModel(apiKey: OptionalApiKey, model: string) {
const mistral = createMistral({ const mistral = createMistral({
apiKey, apiKey,
}); });
@ -55,7 +56,7 @@ export function getMistralModel(apiKey: string | undefined, model: string) {
return mistral(model); return mistral(model);
} }
export function getGoogleModel(apiKey: string | undefined, model: string) { export function getGoogleModel(apiKey: OptionalApiKey, model: string) {
const google = createGoogleGenerativeAI({ const google = createGoogleGenerativeAI({
apiKey, apiKey,
}); });
@ -63,7 +64,7 @@ export function getGoogleModel(apiKey: string | undefined, model: string) {
return google(model); return google(model);
} }
export function getGroqModel(apiKey: string | undefined, model: string) { export function getGroqModel(apiKey: OptionalApiKey, model: string) {
const openai = createOpenAI({ const openai = createOpenAI({
baseURL: 'https://api.groq.com/openai/v1', baseURL: 'https://api.groq.com/openai/v1',
apiKey, apiKey,
@ -72,7 +73,7 @@ export function getGroqModel(apiKey: string | undefined, model: string) {
return openai(model); return openai(model);
} }
export function getHuggingFaceModel(apiKey: string, model: string) { export function getHuggingFaceModel(apiKey: OptionalApiKey, model: string) {
const openai = createOpenAI({ const openai = createOpenAI({
baseURL: 'https://api-inference.huggingface.co/v1/', baseURL: 'https://api-inference.huggingface.co/v1/',
apiKey, apiKey,
@ -82,7 +83,7 @@ export function getHuggingFaceModel(apiKey: string, model: string) {
} }
export function getOllamaModel(baseURL: string, model: string) { export function getOllamaModel(baseURL: string, model: string) {
let Ollama = ollama(model, { const ollamaInstance = ollama(model, {
numCtx: DEFAULT_NUM_CTX, numCtx: DEFAULT_NUM_CTX,
}); });
@ -91,7 +92,7 @@ export function getOllamaModel(baseURL: string, model: string) {
return ollamaInstance; return ollamaInstance;
} }
export function getDeepseekModel(apiKey: string | undefined, model: string) { export function getDeepseekModel(apiKey: OptionalApiKey, model: string) {
const openai = createOpenAI({ const openai = createOpenAI({
baseURL: 'https://api.deepseek.com/beta', baseURL: 'https://api.deepseek.com/beta',
apiKey, apiKey,
@ -100,7 +101,7 @@ export function getDeepseekModel(apiKey: string | undefined, model: string) {
return openai(model); return openai(model);
} }
export function getOpenRouterModel(apiKey: string | undefined, model: string) { export function getOpenRouterModel(apiKey: OptionalApiKey, model: string) {
const openRouter = createOpenRouter({ const openRouter = createOpenRouter({
apiKey, apiKey,
}); });
@ -117,7 +118,7 @@ export function getLMStudioModel(baseURL: string, model: string) {
return lmstudio(model); return lmstudio(model);
} }
export function getXAIModel(apiKey: string | undefined, model: string) { export function getXAIModel(apiKey: OptionalApiKey, model: string) {
const openai = createOpenAI({ const openai = createOpenAI({
baseURL: 'https://api.x.ai/v1', baseURL: 'https://api.x.ai/v1',
apiKey, apiKey,