MCPcopy Create free account
hub / github.com/diegosouzapw/OmniRoute / buildOpenCodeProviderConfig

Function buildOpenCodeProviderConfig

src/shared/services/opencodeConfig.ts:41–76  ·  view source on GitHub ↗
({
  baseUrl,
  apiKey,
  model,
  models,
  modelLabels,
}: OpenCodeConfigInput)

Source from the content-addressed store, hash-verified

39 labels[modelId] || modelId;
40
41export const buildOpenCodeProviderConfig = ({
42 baseUrl,
43 apiKey,
44 model,
45 models,
46 modelLabels,
47}: OpenCodeConfigInput): Record<string, any> => {
48 const normalizedBaseUrl = String(baseUrl || "")
49 .trim()
50 .replace(/\/+$/, "");
51 const normalizedModel = normalizeValue(model);
52 const normalizedModels = normalizeModels(models);
53 const normalizedLabels = normalizeModelLabels(modelLabels);
54
55 const uniqueModels =
56 normalizedModels.length > 0
57 ? normalizedModels
58 : [...new Set([normalizedModel, ...OPENCODE_DEFAULT_MODELS].filter(Boolean))];
59
60 const modelsRecord: Record<string, { name: string }> = {};
61 for (const m of uniqueModels) {
62 if (m) {
63 modelsRecord[m] = { name: getModelEntryName(m, normalizedLabels) };
64 }
65 }
66
67 return {
68 npm: "@ai-sdk/openai-compatible",
69 name: "OmniRoute",
70 options: {
71 baseURL: normalizedBaseUrl,
72 apiKey: apiKey || "sk_omniroute",
73 },
74 models: modelsRecord,
75 };
76};
77
78export const buildOpenCodeConfigDocument = (input: OpenCodeConfigInput) => ({
79 $schema: "https://opencode.ai/config.json",

Calls 5

normalizeValueFunction · 0.85
normalizeModelsFunction · 0.85
normalizeModelLabelsFunction · 0.85
getModelEntryNameFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected