Oliver Jägle
commited on
Lint and fix recent changes from main
Browse files- app/lib/.server/llm/model.ts +16 -15
app/lib/.server/llm/model.ts
CHANGED
@@ -11,18 +11,19 @@ import { createOpenRouter } from '@openrouter/ai-sdk-provider';
|
|
11 |
import { createMistral } from '@ai-sdk/mistral';
|
12 |
import { createCohere } from '@ai-sdk/cohere';
|
13 |
|
14 |
-
export const DEFAULT_NUM_CTX = process.env.DEFAULT_NUM_CTX ?
|
15 |
-
parseInt(process.env.DEFAULT_NUM_CTX, 10) :
|
16 |
-
32768;
|
17 |
|
18 |
-
export function getAnthropicModel(apiKey:
|
19 |
const anthropic = createAnthropic({
|
20 |
apiKey,
|
21 |
});
|
22 |
|
23 |
return anthropic(model);
|
24 |
}
|
25 |
-
|
|
|
|
|
|
|
26 |
const openai = createOpenAI({
|
27 |
baseURL,
|
28 |
apiKey,
|
@@ -31,7 +32,7 @@ export function getOpenAILikeModel(baseURL: string, apiKey: string | undefined,
|
|
31 |
return openai(model);
|
32 |
}
|
33 |
|
34 |
-
export function getCohereAIModel(apiKey:
|
35 |
const cohere = createCohere({
|
36 |
apiKey,
|
37 |
});
|
@@ -39,7 +40,7 @@ export function getCohereAIModel(apiKey: string | undefined, model: string) {
|
|
39 |
return cohere(model);
|
40 |
}
|
41 |
|
42 |
-
export function getOpenAIModel(apiKey:
|
43 |
const openai = createOpenAI({
|
44 |
apiKey,
|
45 |
});
|
@@ -47,7 +48,7 @@ export function getOpenAIModel(apiKey: string | undefined, model: string) {
|
|
47 |
return openai(model);
|
48 |
}
|
49 |
|
50 |
-
export function getMistralModel(apiKey:
|
51 |
const mistral = createMistral({
|
52 |
apiKey,
|
53 |
});
|
@@ -55,7 +56,7 @@ export function getMistralModel(apiKey: string | undefined, model: string) {
|
|
55 |
return mistral(model);
|
56 |
}
|
57 |
|
58 |
-
export function getGoogleModel(apiKey:
|
59 |
const google = createGoogleGenerativeAI({
|
60 |
apiKey,
|
61 |
});
|
@@ -63,7 +64,7 @@ export function getGoogleModel(apiKey: string | undefined, model: string) {
|
|
63 |
return google(model);
|
64 |
}
|
65 |
|
66 |
-
export function getGroqModel(apiKey:
|
67 |
const openai = createOpenAI({
|
68 |
baseURL: 'https://api.groq.com/openai/v1',
|
69 |
apiKey,
|
@@ -72,7 +73,7 @@ export function getGroqModel(apiKey: string | undefined, model: string) {
|
|
72 |
return openai(model);
|
73 |
}
|
74 |
|
75 |
-
export function getHuggingFaceModel(apiKey:
|
76 |
const openai = createOpenAI({
|
77 |
baseURL: 'https://api-inference.huggingface.co/v1/',
|
78 |
apiKey,
|
@@ -82,7 +83,7 @@ export function getHuggingFaceModel(apiKey: string, model: string) {
|
|
82 |
}
|
83 |
|
84 |
export function getOllamaModel(baseURL: string, model: string) {
|
85 |
-
|
86 |
numCtx: DEFAULT_NUM_CTX,
|
87 |
});
|
88 |
|
@@ -91,7 +92,7 @@ export function getOllamaModel(baseURL: string, model: string) {
|
|
91 |
return ollamaInstance;
|
92 |
}
|
93 |
|
94 |
-
export function getDeepseekModel(apiKey:
|
95 |
const openai = createOpenAI({
|
96 |
baseURL: 'https://api.deepseek.com/beta',
|
97 |
apiKey,
|
@@ -100,7 +101,7 @@ export function getDeepseekModel(apiKey: string | undefined, model: string) {
|
|
100 |
return openai(model);
|
101 |
}
|
102 |
|
103 |
-
export function getOpenRouterModel(apiKey:
|
104 |
const openRouter = createOpenRouter({
|
105 |
apiKey,
|
106 |
});
|
@@ -117,7 +118,7 @@ export function getLMStudioModel(baseURL: string, model: string) {
|
|
117 |
return lmstudio(model);
|
118 |
}
|
119 |
|
120 |
-
export function getXAIModel(apiKey:
|
121 |
const openai = createOpenAI({
|
122 |
baseURL: 'https://api.x.ai/v1',
|
123 |
apiKey,
|
|
|
11 |
import { createMistral } from '@ai-sdk/mistral';
|
12 |
import { createCohere } from '@ai-sdk/cohere';
|
13 |
|
14 |
+
export const DEFAULT_NUM_CTX = process.env.DEFAULT_NUM_CTX ? parseInt(process.env.DEFAULT_NUM_CTX, 10) : 32768;
|
|
|
|
|
15 |
|
16 |
+
export function getAnthropicModel(apiKey: OptionalApiKey, model: string) {
|
17 |
const anthropic = createAnthropic({
|
18 |
apiKey,
|
19 |
});
|
20 |
|
21 |
return anthropic(model);
|
22 |
}
|
23 |
+
|
24 |
+
type OptionalApiKey = string | undefined;
|
25 |
+
|
26 |
+
export function getOpenAILikeModel(baseURL: string, apiKey: OptionalApiKey, model: string) {
|
27 |
const openai = createOpenAI({
|
28 |
baseURL,
|
29 |
apiKey,
|
|
|
32 |
return openai(model);
|
33 |
}
|
34 |
|
35 |
+
export function getCohereAIModel(apiKey: OptionalApiKey, model: string) {
|
36 |
const cohere = createCohere({
|
37 |
apiKey,
|
38 |
});
|
|
|
40 |
return cohere(model);
|
41 |
}
|
42 |
|
43 |
+
export function getOpenAIModel(apiKey: OptionalApiKey, model: string) {
|
44 |
const openai = createOpenAI({
|
45 |
apiKey,
|
46 |
});
|
|
|
48 |
return openai(model);
|
49 |
}
|
50 |
|
51 |
+
export function getMistralModel(apiKey: OptionalApiKey, model: string) {
|
52 |
const mistral = createMistral({
|
53 |
apiKey,
|
54 |
});
|
|
|
56 |
return mistral(model);
|
57 |
}
|
58 |
|
59 |
+
export function getGoogleModel(apiKey: OptionalApiKey, model: string) {
|
60 |
const google = createGoogleGenerativeAI({
|
61 |
apiKey,
|
62 |
});
|
|
|
64 |
return google(model);
|
65 |
}
|
66 |
|
67 |
+
export function getGroqModel(apiKey: OptionalApiKey, model: string) {
|
68 |
const openai = createOpenAI({
|
69 |
baseURL: 'https://api.groq.com/openai/v1',
|
70 |
apiKey,
|
|
|
73 |
return openai(model);
|
74 |
}
|
75 |
|
76 |
+
export function getHuggingFaceModel(apiKey: OptionalApiKey, model: string) {
|
77 |
const openai = createOpenAI({
|
78 |
baseURL: 'https://api-inference.huggingface.co/v1/',
|
79 |
apiKey,
|
|
|
83 |
}
|
84 |
|
85 |
export function getOllamaModel(baseURL: string, model: string) {
|
86 |
+
const ollamaInstance = ollama(model, {
|
87 |
numCtx: DEFAULT_NUM_CTX,
|
88 |
});
|
89 |
|
|
|
92 |
return ollamaInstance;
|
93 |
}
|
94 |
|
95 |
+
export function getDeepseekModel(apiKey: OptionalApiKey, model: string) {
|
96 |
const openai = createOpenAI({
|
97 |
baseURL: 'https://api.deepseek.com/beta',
|
98 |
apiKey,
|
|
|
101 |
return openai(model);
|
102 |
}
|
103 |
|
104 |
+
export function getOpenRouterModel(apiKey: OptionalApiKey, model: string) {
|
105 |
const openRouter = createOpenRouter({
|
106 |
apiKey,
|
107 |
});
|
|
|
118 |
return lmstudio(model);
|
119 |
}
|
120 |
|
121 |
+
export function getXAIModel(apiKey: OptionalApiKey, model: string) {
|
122 |
const openai = createOpenAI({
|
123 |
baseURL: 'https://api.x.ai/v1',
|
124 |
apiKey,
|