summaryrefslogtreecommitdiff
path: root/index.ts
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-19 12:54:25 +0700
committerpolwex <polwex@sortug.com>2025-10-19 12:54:25 +0700
commit8815d3c1d40550470c5bc972bc16bd4966735154 (patch)
tree92ef606b568035b9e88d89286be3330f4b84af1e /index.ts
parentba16ebcbe36c1a1cbdb1d1379cb3f9c3a086acdf (diff)
new openai responses api and some claude made testsHEADmaster
Diffstat (limited to 'index.ts')
-rw-r--r--index.ts114
1 files changed, 60 insertions, 54 deletions
diff --git a/index.ts b/index.ts
index 9dcae26..d2fc090 100644
--- a/index.ts
+++ b/index.ts
@@ -2,69 +2,75 @@
import Claude from "./src/claude";
import Gemini from "./src/gemini";
import Generic from "./src/generic";
+import OpenAIResponses from "./src/openai-responses";
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",
+ try {
+ const api =
+ "gemini" in choice
+ ? new Gemini(choice.gemini)
+ : "claude" in choice
+ ? new Claude(choice.claude)
+ : "chatgpt" in choice
+ ? new OpenAIResponses({
+ baseURL: "https://api.openai.com/v1",
+ apiKey: Bun.env.OPENAI_API_KEY!,
+ model: choice.chatgpt || "gpt-5-nano",
})
- : "kimi" in choice
+ : "deepseek" in choice
? new Generic({
- baseURL: "https://api.moonshot.ai/v1",
- apiKey: Bun.env.MOONSHOT_API_KEY!,
- model: "kimi-k2-0711-preview", // "kimi-latest"?
+ baseURL: "https://api.deepseek.com",
+ apiKey: Bun.env.DEEPSEEK_API_KEY!,
+ model: "deepseek-reasoner",
})
- : "grok" in choice
+ : "kimi" in choice
? new Generic({
- baseURL: "https://api.x.ai/v1",
- apiKey: Bun.env.XAI_API_KEY!,
- model: "grok-4", // "kimi-latest"?
+ baseURL: "https://api.moonshot.ai/v1",
+ apiKey: Bun.env.MOONSHOT_API_KEY!,
+ model: "kimi-k2-0905-preview", // "kimi-latest"?
})
- : new Generic({
- baseURL: choice.openai.url,
- apiKey: choice.openai.apiKey,
- model: choice.openai.model,
- allowBrowser: choice.openai.allowBrowser,
- });
- // "" 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;
+ : "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,
+ allowBrowser: choice.openai.allowBrowser,
+ });
+ // "" 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;
+ } catch (e) {
+ // TODO
+ console.error("couldnt start API", e);
+ }
}