Transcribe through OpenRouter when OPENROUTER_API_KEY is set
A Claude subscription can't be used by the app, so let it use any cheap
vision model on OpenRouter instead (default google/gemini-3.1-flash-lite,
OPENROUTER_MODEL to change). The Anthropic API stays available as the
second choice. Both providers share the prompt and live behind one
{ name, model, transcribe } interface in server/providers.mjs; OpenRouter
retries 408/429/5xx and network errors and turns 401/402/404 into
messages the editor can show.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HA82gVRDXpoukzgMFumoJt
This commit is contained in:
parent
46aa1236ed
commit
f353c14619
11 changed files with 258 additions and 91 deletions
|
|
@ -10,16 +10,16 @@ import { createStore } from "../server/store.mjs";
|
|||
const PASS = "tajne-heslo";
|
||||
const JPEG = Buffer.from([0xff, 0xd8, 0xff, 0xe0, 1, 2, 3]);
|
||||
const replies = ["=-1-\n~JEDNÁNÍ PRVNÍ\n@LÍDA\nDobrý den.", "=2\nještě já.\n@Mise\nAno."];
|
||||
const client = { messages: { create: async (p) => ({ stop_reason: "end_turn", content: [{ type: "text", text: replies.shift() }], usage: {} }) } };
|
||||
const provider = { name: "stub", model: "stub-model", transcribe: async () => replies.shift() };
|
||||
|
||||
let dir, server, base;
|
||||
test.before(async () => {
|
||||
dir = await mkdtemp(path.join(tmpdir(), "tr-"));
|
||||
Object.assign(config, { dataDir: dir, password: PASS, apiKey: "test", dailyPageLimit: 3 });
|
||||
Object.assign(config, { dataDir: dir, password: PASS, dailyPageLimit: 3 });
|
||||
const store = createStore(dir);
|
||||
await store.init();
|
||||
await store.seed(config.seedDir);
|
||||
server = createServer(store, client).listen(0);
|
||||
server = createServer(store, provider).listen(0);
|
||||
base = `http://127.0.0.1:${server.address().port}`;
|
||||
});
|
||||
test.after(async () => { server.close(); await rm(dir, { recursive: true, force: true }); });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue