mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-05-05 17:56:56 +00:00
Stop shipping a default Gemini OAuth client secret and require it to come from the environment instead. Also tighten proxy fetch typing to avoid any-based undici calls and move db setup utilities under scripts while removing generated debug and scratch artifacts.
38 lines
1 KiB
TypeScript
38 lines
1 KiB
TypeScript
import { QoderExecutor } from "./open-sse/executors/qoder.ts";
|
|
import fs from "fs";
|
|
import os from "os";
|
|
|
|
async function run() {
|
|
const credsPath = os.homedir() + "/.qwen/oauth_creds.json";
|
|
const creds = JSON.parse(fs.readFileSync(credsPath, "utf8"));
|
|
|
|
const executor = new QoderExecutor();
|
|
const result = await executor.execute({
|
|
model: "coder-model",
|
|
body: {
|
|
messages: [{ role: "user", content: "hello test" }],
|
|
stream: true,
|
|
max_tokens: 10,
|
|
},
|
|
credentials: {
|
|
accessToken: creds.access_token,
|
|
resourceUrl: creds.resource_url,
|
|
},
|
|
signal: new AbortController().signal,
|
|
});
|
|
|
|
console.log("Status:", result.response.status);
|
|
|
|
if (result.response.body) {
|
|
// If it's a web stream, readable stream
|
|
const reader = result.response.body.getReader();
|
|
const decoder = new TextDecoder("utf-8");
|
|
while (true) {
|
|
const { done, value } = await reader.read();
|
|
if (done) break;
|
|
console.log(decoder.decode(value));
|
|
}
|
|
}
|
|
}
|
|
|
|
run().catch(console.error);
|