summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-07-23 07:25:56 +0700
committerpolwex <polwex@sortug.com>2025-07-23 07:25:56 +0700
commitde917196d3602197a90e9eaa7cf7f8b5d0c7718e (patch)
tree2bd3bf4de9c9e2fc910bfd04868330f3f78fe0a7
parente1e01fe1c702e33509a276eb1da6efc720c21164 (diff)
m
-rw-r--r--.gitignore2
-rw-r--r--src/generic.ts1
-rw-r--r--tests/index.test.ts61
-rw-r--r--tests/test.ts25
4 files changed, 87 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 9b1ee42..1a56d8a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,7 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
# Logs
-
+runtest.sh
logs
_.log
npm-debug.log_
diff --git a/src/generic.ts b/src/generic.ts
index 50b19c3..3690dc6 100644
--- a/src/generic.ts
+++ b/src/generic.ts
@@ -30,7 +30,6 @@ export default class OpenAIAPI implements AIModelAPI {
this.apiKey = props.apiKey;
this.baseURL = props.baseURL;
this.api = new OpenAI({ baseURL: this.baseURL, apiKey: this.apiKey });
- console.log(this.api);
this.model = props.model || "";
if (props.maxTokens) this.maxTokens = props.maxTokens;
if (props.tokenizer) this.tokenizer = props.tokenizer;
diff --git a/tests/index.test.ts b/tests/index.test.ts
new file mode 100644
index 0000000..1c328fa
--- /dev/null
+++ b/tests/index.test.ts
@@ -0,0 +1,61 @@
+import { describe, expect, test } from "bun:test";
+import selectModel from "../index";
+
+describe("Model selector smoke tests", () => {
+ // test("chatgpt model instantiates correctly and basic send works", async () => {
+ // const api = selectModel({ chatgpt: "" });
+ // expect(api).toBeDefined();
+ // expect(typeof api.send).toBe("function");
+ // expect(typeof api.stream).toBe("function");
+ // expect(typeof api.setModel).toBe("function");
+ // expect(typeof api.tokenizer).toBe("function");
+ // expect(typeof api.maxTokens).toBe("number");
+ // const res = await api.send("hello");
+ // expect(res).toBeTruthy();
+ // expect(typeof (res.ok ?? res.error)).toBe("string");
+ // });
+ // test("gemini model instantiates correctly and basic send works", async () => {
+ // const api = selectModel({ gemini: "" });
+ // expect(api).toBeDefined();
+ // expect(typeof api.send).toBe("function");
+ // expect(typeof api.stream).toBe("function");
+ // const res = await api.send("hello");
+ // console.log({ res });
+ // });
+ // test("claude model instantiates correctly and basic send works", async () => {
+ // const api = selectModel({ claude: "" });
+ // expect(api).toBeDefined();
+ // expect(typeof api.send).toBe("function");
+ // expect(typeof api.stream).toBe("function");
+ // const res = await api.send("hello");
+ // expect(res).toBeTruthy();
+ // expect(typeof (res.ok ?? res.error)).toBe("string");
+ // });
+ // test("deepseek model instantiates correctly and basic send works", async () => {
+ // const api = selectModel({ deepseek: "" });
+ // expect(api).toBeDefined();
+ // expect(typeof api.send).toBe("function");
+ // expect(typeof api.stream).toBe("function");
+ // const res = await api.send("hello");
+ // expect(res).toBeTruthy();
+ // expect(typeof (res.ok ?? res.error)).toBe("string");
+ // });
+ // test("kimi model instantiates correctly and basic send works", async () => {
+ // const api = selectModel({ kimi: "" });
+ // expect(api).toBeDefined();
+ // expect(typeof api.send).toBe("function");
+ // expect(typeof api.stream).toBe("function");
+ // const res = await api.send("hello");
+ // expect(res).toBeTruthy();
+ // expect(typeof (res.ok ?? res.error)).toBe("string");
+ // });
+ // test("grok model instantiates correctly and basic send works", async () => {
+ // const api = selectModel({ grok: "" });
+ // expect(api).toBeDefined();
+ // expect(typeof api.send).toBe("function");
+ // expect(typeof api.stream).toBe("function");
+ // const res = await api.send("hello");
+ // expect(res).toBeTruthy();
+ // expect(typeof (res.ok ?? res.error)).toBe("string");
+ // });
+});
diff --git a/tests/test.ts b/tests/test.ts
new file mode 100644
index 0000000..0b311f6
--- /dev/null
+++ b/tests/test.ts
@@ -0,0 +1,25 @@
+import Router from ".";
+import OpenAI from "openai";
+
+async function run() {
+ // const api = Router({ claude: "" });
+ const api = new OpenAI({
+ baseURL: "https://api.moonshot.ai/v1",
+ apiKey: Bun.env.MOONSHOT_API_KEY,
+ });
+ const model = "kimi-k2-0711-preview";
+ // const api = new OpenAI();
+ // const model = "o4-mini";
+ const res = await api.responses.create({ model, input: "Hello!" });
+ // const res = await api.chat.completions.create({
+ // model,
+ // messages: [{ role: "user", content: "Hello there" }],
+ // });
+ // const res = await api.send("henlo");
+ console.log({ res });
+}
+run();
+
+// gemini works
+// claude works too.
+// it's the openai API thingy