1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// import Openai from "./src/openai";
import Claude from "./src/claude";
import Gemini from "./src/gemini";
import Generic from "./src/generic";
import type { AIModelAPI, LLMChoice } from "./src/types";
export type * from "./src/types";
export * as NLP from "./src/nlp";
export default function (choice: LLMChoice): AIModelAPI {
const api =
"gemini" in choice
? new Gemini(choice.gemini)
: "claude" in choice
? new Claude(choice.claude)
: "chatgpt" in choice
? new Generic({
baseURL: "https://api.openai.com/v1",
apiKey: Bun.env.OPENAI_API_KEY,
model: choice.chatgpt || "o4-mini",
})
: "deepseek" in choice
? new Generic({
baseURL: "https://api.deepseek.com",
apiKey: Bun.env.DEEPSEEK_API_KEY,
model: "deepseek-reasoner",
})
: "kimi" in choice
? new Generic({
baseURL: "https://api.moonshot.ai/v1",
apiKey: Bun.env.MOONSHOT_API_KEY,
model: "kimi-k2-0711-preview", // "kimi-latest"?
})
: "grok" in choice
? new Generic({
baseURL: "https://api.x.ai/v1",
apiKey: Bun.env.XAI_API_KEY,
model: "grok-4", // "kimi-latest"?
})
: new Generic({
baseURL: choice.openai.url,
apiKey: choice.openai.apiKey,
model: choice.openai.model,
});
// "" in choice
// ? new Generic(choice.other)
// : choice.name === "deepseek"
// ? new Generic({
// baseURL: "https://api.deepseek.com",
// apiKey: Bun.env.DEEPSEEK_API_KEY!,
// model: "deepseek-chat",
// })
// : choice.name === "grok"
// ? new Generic({
// baseURL: "https://api.x.ai/v1",
// apiKey: Bun.env.GROK_API_KEY!,
// model: "grok-2-latest",
// })
// : choice.name === "chatgpt"
// ? new Generic({
// baseURL: "https://api.openai.com/v1",
// apiKey: Bun.env.OPENAI_API_KEY!,
// model: "gpt-4o",
// })
// : choice.name === "claude"
// ? new Claude()
// : new Gemini();
return api;
}
|