mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
refactor(config): dedupe model api definitions
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
resolveAgentModelFallbackValues,
|
||||
resolveAgentModelPrimaryValue,
|
||||
} from "../config/model-input.js";
|
||||
import type { ModelApi } from "../config/types.models.js";
|
||||
import {
|
||||
applyAuthProfileConfig,
|
||||
applyLitellmProviderConfig,
|
||||
@@ -45,7 +46,7 @@ import {
|
||||
|
||||
function createLegacyProviderConfig(params: {
|
||||
providerId: string;
|
||||
api: "anthropic-messages" | "openai-completions" | "openai-responses";
|
||||
api: ModelApi;
|
||||
modelId?: string;
|
||||
modelName?: string;
|
||||
baseUrl?: string;
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import type { SecretInput } from "./types.secrets.js";
|
||||
|
||||
export type ModelApi =
|
||||
| "openai-completions"
|
||||
| "openai-responses"
|
||||
| "openai-codex-responses"
|
||||
| "anthropic-messages"
|
||||
| "google-generative-ai"
|
||||
| "github-copilot"
|
||||
| "bedrock-converse-stream"
|
||||
| "ollama";
|
||||
export const MODEL_APIS = [
|
||||
"openai-completions",
|
||||
"openai-responses",
|
||||
"openai-codex-responses",
|
||||
"anthropic-messages",
|
||||
"google-generative-ai",
|
||||
"github-copilot",
|
||||
"bedrock-converse-stream",
|
||||
"ollama",
|
||||
] as const;
|
||||
|
||||
export type ModelApi = (typeof MODEL_APIS)[number];
|
||||
|
||||
export type ModelCompatConfig = {
|
||||
supportsStore?: boolean;
|
||||
|
||||
@@ -2,6 +2,7 @@ import path from "node:path";
|
||||
import { z } from "zod";
|
||||
import { isSafeExecutableValue } from "../infra/exec-safety.js";
|
||||
import { isValidFileSecretRefId } from "../secrets/ref-contract.js";
|
||||
import { MODEL_APIS } from "./types.models.js";
|
||||
import { createAllowDenyChannelRulesSchema } from "./zod-schema.allowdeny.js";
|
||||
import { sensitive } from "./zod-schema.sensitive.js";
|
||||
|
||||
@@ -179,16 +180,7 @@ export const SecretsConfigSchema = z
|
||||
.strict()
|
||||
.optional();
|
||||
|
||||
export const ModelApiSchema = z.union([
|
||||
z.literal("openai-completions"),
|
||||
z.literal("openai-responses"),
|
||||
z.literal("openai-codex-responses"),
|
||||
z.literal("anthropic-messages"),
|
||||
z.literal("google-generative-ai"),
|
||||
z.literal("github-copilot"),
|
||||
z.literal("bedrock-converse-stream"),
|
||||
z.literal("ollama"),
|
||||
]);
|
||||
export const ModelApiSchema = z.enum(MODEL_APIS);
|
||||
|
||||
export const ModelCompatSchema = z
|
||||
.object({
|
||||
|
||||
Reference in New Issue
Block a user