Shaheer Sarfaraz 82b261c7bc
Refactor LLM service into modular adapters and policies (#83)
* 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
2026-02-04 21:48:28 +00:00

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,
});