feat: remove legacy chat provider tables (#25416)

This commit is contained in:
Michael Suchacz
2026-05-22 09:50:01 +02:00
committed by GitHub
parent ddec110b0e
commit ca1f6b19a2
46 changed files with 1270 additions and 3505 deletions
-9
View File
@@ -284,11 +284,6 @@ describe("api.ts", () => {
providers: [],
},
],
[
"/api/experimental/chats/providers",
() => API.experimental.getChatProviderConfigs(),
[],
],
[
"/api/experimental/chats/model-configs",
() => API.experimental.getChatModelConfigs(),
@@ -310,10 +305,6 @@ describe("api.ts", () => {
"/api/experimental/chats/models",
() => API.experimental.getChatModels(),
],
[
"/api/experimental/chats/providers",
() => API.experimental.getChatProviderConfigs(),
],
[
"/api/experimental/chats/model-configs",
() => API.experimental.getChatModelConfigs(),
-67
View File
@@ -407,11 +407,8 @@ export type DeploymentConfig = Readonly<{
options: TypesGen.SerpentOption[];
}>;
const chatProviderConfigsPath = "/api/experimental/chats/providers";
const aiProviderConfigsPath = "/api/v2/ai/providers";
const chatModelConfigsPath = "/api/experimental/chats/model-configs";
const userChatProviderConfigsPath =
"/api/experimental/chats/user-provider-configs";
const userSkillsPath = (user: string) =>
`/api/experimental/users/${encodeURIComponent(user)}/skills`;
const userSkillPath = (user: string, name: string) =>
@@ -3731,42 +3728,6 @@ class ExperimentalApiMethods {
);
};
getChatProviderConfigs = async (): Promise<TypesGen.ChatProviderConfig[]> => {
const response = await this.axios.get<TypesGen.ChatProviderConfig[]>(
chatProviderConfigsPath,
);
return response.data;
};
createChatProviderConfig = async (
req: TypesGen.CreateChatProviderConfigRequest,
): Promise<TypesGen.ChatProviderConfig> => {
const response = await this.axios.post<TypesGen.ChatProviderConfig>(
chatProviderConfigsPath,
req,
);
return response.data;
};
updateChatProviderConfig = async (
providerConfigId: string,
req: TypesGen.UpdateChatProviderConfigRequest,
): Promise<TypesGen.ChatProviderConfig> => {
const response = await this.axios.patch<TypesGen.ChatProviderConfig>(
`${chatProviderConfigsPath}/${encodeURIComponent(providerConfigId)}`,
req,
);
return response.data;
};
deleteChatProviderConfig = async (
providerConfigId: string,
): Promise<void> => {
await this.axios.delete(
`${chatProviderConfigsPath}/${encodeURIComponent(providerConfigId)}`,
);
};
getChatModelConfigs = async (): Promise<TypesGen.ChatModelConfig[]> => {
const response =
await this.axios.get<TypesGen.ChatModelConfig[]>(chatModelConfigsPath);
@@ -3800,34 +3761,6 @@ class ExperimentalApiMethods {
);
};
getUserChatProviderConfigs = async (): Promise<
TypesGen.UserChatProviderConfig[]
> => {
const response = await this.axios.get<TypesGen.UserChatProviderConfig[]>(
userChatProviderConfigsPath,
);
return response.data;
};
upsertUserChatProviderKey = async (
providerConfigId: string,
req: TypesGen.CreateUserChatProviderKeyRequest,
): Promise<TypesGen.UserChatProviderConfig> => {
const response = await this.axios.put<TypesGen.UserChatProviderConfig>(
`${userChatProviderConfigsPath}/${encodeURIComponent(providerConfigId)}`,
req,
);
return response.data;
};
deleteUserChatProviderKey = async (
providerConfigId: string,
): Promise<void> => {
await this.axios.delete(
`${userChatProviderConfigsPath}/${encodeURIComponent(providerConfigId)}`,
);
};
getMCPServerConfigs = async (): Promise<TypesGen.MCPServerConfig[]> => {
const response =
await this.axios.get<TypesGen.MCPServerConfig[]>(mcpServerConfigsPath);
@@ -39,12 +39,36 @@ const createProviderConfig = (
updated_at: overrides.updated_at ?? now,
});
const createProviderKey = (providerId: string): TypesGen.AIProviderKey => ({
id: `key-${providerId}`,
masked: "sk-...test",
created_at: now,
});
const toAIProvider = (
providerConfig: TypesGen.ChatProviderConfig,
): TypesGen.AIProvider => ({
id: providerConfig.id,
type: providerConfig.provider as TypesGen.AIProviderType,
name: providerConfig.provider,
display_name: providerConfig.display_name,
enabled: providerConfig.enabled,
base_url: providerConfig.base_url ?? "",
api_keys: providerConfig.has_api_key
? [createProviderKey(providerConfig.id)]
: [],
settings: {},
created_at: providerConfig.created_at ?? now,
updated_at: providerConfig.updated_at ?? now,
});
const createModelConfig = (
overrides: Partial<TypesGen.ChatModelConfig> &
Pick<TypesGen.ChatModelConfig, "id" | "provider" | "model">,
): TypesGen.ChatModelConfig => ({
id: overrides.id,
provider: overrides.provider,
ai_provider_id: overrides.ai_provider_id,
model: overrides.model,
display_name: overrides.display_name ?? overrides.model,
enabled: overrides.enabled ?? true,
@@ -68,11 +92,9 @@ const setupChatSpies = (state: {
modelConfigs: TypesGen.ChatModelConfig[];
modelCatalog: TypesGen.ChatModelsResponse;
}) => {
spyOn(API.experimental, "getChatProviderConfigs").mockImplementation(
async () => {
return state.providerConfigs;
},
);
spyOn(API.experimental, "listAIProviders").mockImplementation(async () => {
return state.providerConfigs.map(toAIProvider);
});
spyOn(API.experimental, "getChatModelConfigs").mockImplementation(
async () => {
return state.modelConfigs;
@@ -82,31 +104,26 @@ const setupChatSpies = (state: {
return state.modelCatalog;
});
spyOn(API.experimental, "createChatProviderConfig").mockImplementation(
spyOn(API.experimental, "createAIProvider").mockImplementation(
async (req) => {
const created = createProviderConfig({
id: `provider-${Date.now()}`,
provider: req.provider ?? "",
provider: req.type ?? "openai",
display_name: req.display_name ?? "",
has_api_key: (req.api_key ?? "").trim().length > 0,
central_api_key_enabled: req.central_api_key_enabled ?? true,
allow_user_api_key: req.allow_user_api_key ?? false,
allow_central_api_key_fallback:
req.allow_central_api_key_fallback ?? false,
has_api_key:
req.api_keys?.some((apiKey) => apiKey.trim().length > 0) ?? false,
base_url: req.base_url ?? "",
enabled: req.enabled ?? true,
source: "database",
});
state.providerConfigs = [
...state.providerConfigs.filter(
(p) => !(p.id === nilProviderConfigID && p.provider === req.provider),
),
...state.providerConfigs.filter((p) => p.id !== created.id),
created,
];
return created;
return toAIProvider(created);
},
);
spyOn(API.experimental, "updateChatProviderConfig").mockImplementation(
spyOn(API.experimental, "updateAIProvider").mockImplementation(
async (providerConfigId, req) => {
const idx = state.providerConfigs.findIndex(
(p) => p.id === providerConfigId,
@@ -122,29 +139,30 @@ const setupChatSpies = (state: {
? req.display_name
: current.display_name,
has_api_key:
typeof req.api_key === "string"
? req.api_key.trim().length > 0
: current.has_api_key,
central_api_key_enabled:
typeof req.central_api_key_enabled === "boolean"
? req.central_api_key_enabled
: current.central_api_key_enabled,
allow_user_api_key:
typeof req.allow_user_api_key === "boolean"
? req.allow_user_api_key
: current.allow_user_api_key,
allow_central_api_key_fallback:
typeof req.allow_central_api_key_fallback === "boolean"
? req.allow_central_api_key_fallback
: current.allow_central_api_key_fallback,
req.api_keys === undefined
? current.has_api_key
: req.api_keys.some((apiKey) =>
apiKey.api_key !== undefined
? apiKey.api_key.trim().length > 0
: apiKey.id !== undefined,
),
base_url:
typeof req.base_url === "string" ? req.base_url : current.base_url,
enabled:
typeof req.enabled === "boolean" ? req.enabled : current.enabled,
updated_at: now,
};
state.providerConfigs = state.providerConfigs.map((p, i) =>
i === idx ? updated : p,
);
return updated;
return toAIProvider(updated);
},
);
spyOn(API.experimental, "deleteAIProvider").mockImplementation(
async (providerConfigId) => {
state.providerConfigs = state.providerConfigs.filter(
(p) => p.id !== providerConfigId,
);
},
);
@@ -154,6 +172,7 @@ const setupChatSpies = (state: {
id: `model-${state.modelConfigs.length + 1}`,
provider: req.provider ?? "",
model: req.model,
ai_provider_id: req.ai_provider_id,
display_name: req.display_name || req.model,
enabled: req.enabled ?? true,
context_limit:
@@ -181,10 +200,6 @@ const setupChatSpies = (state: {
},
);
// Unused but mock to avoid errors.
spyOn(API.experimental, "deleteChatProviderConfig").mockResolvedValue(
undefined,
);
spyOn(API.experimental, "updateChatModelConfig").mockImplementation(
async (modelConfigId, req) => {
const idx = state.modelConfigs.findIndex((m) => m.id === modelConfigId);