* llm migration * orchestrator runer * Decompose runPipeline steps * dedupe * refactor(settings): unify settings conversion metadata and round-trip tests * refactor(llm): extract shared provider strategy factory * refactor(settings-ui): add reusable numeric setting section * test(orchestrator): stabilize usePipelineSources localStorage setup * comments
29 lines
837 B
TypeScript
29 lines
837 B
TypeScript
import { buildHeaders, joinUrl } from "../utils/http";
|
|
import {
|
|
buildChatCompletionsBody,
|
|
createProviderStrategy,
|
|
extractChatCompletionsText,
|
|
} from "./factory";
|
|
|
|
export const openRouterStrategy = createProviderStrategy({
|
|
provider: "openrouter",
|
|
defaultBaseUrl: "https://openrouter.ai",
|
|
requiresApiKey: true,
|
|
modes: ["json_schema", "none"],
|
|
validationPaths: ["/api/v1/key"],
|
|
buildRequest: ({ mode, baseUrl, apiKey, model, messages, jsonSchema }) => {
|
|
return {
|
|
url: joinUrl(baseUrl, "/api/v1/chat/completions"),
|
|
headers: buildHeaders({ apiKey, provider: "openrouter" }),
|
|
body: buildChatCompletionsBody({
|
|
mode,
|
|
model,
|
|
messages,
|
|
jsonSchema,
|
|
extra: { plugins: [{ id: "response-healing" }] },
|
|
}),
|
|
};
|
|
},
|
|
extractText: extractChatCompletionsText,
|
|
});
|