mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-05-27 12:10:25 -04:00
feat: In-app AI Provider Configuration (#7650)
This commit is contained in:
27
frontend/app/lib/api/admin/admin-ai-providers.ts
Normal file
27
frontend/app/lib/api/admin/admin-ai-providers.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { BaseAPI } from "../base/base-clients";
|
||||
import type { AIProviderCreate, AIProviderOut, AIProviderUpdate } from "~/lib/api/types/group";
|
||||
|
||||
const prefix = "/api/admin";
|
||||
|
||||
const routes = {
|
||||
providers: (groupId: string) => `${prefix}/groups/${groupId}/ai-providers/providers`,
|
||||
providersId: (groupId: string, providerId: string) => `${prefix}/groups/${groupId}/ai-providers/providers/${providerId}`,
|
||||
};
|
||||
|
||||
export class AdminAIProvidersApi extends BaseAPI {
|
||||
async createProvider(groupId: string, payload: AIProviderCreate) {
|
||||
return await this.requests.post<AIProviderOut>(routes.providers(groupId), payload);
|
||||
}
|
||||
|
||||
async getProvider(groupId: string, providerId: string) {
|
||||
return await this.requests.get<AIProviderOut>(routes.providersId(groupId, providerId));
|
||||
}
|
||||
|
||||
async updateProvider(groupId: string, providerId: string, payload: AIProviderUpdate) {
|
||||
return await this.requests.put<AIProviderOut>(routes.providersId(groupId, providerId), payload);
|
||||
}
|
||||
|
||||
async deleteProvider(groupId: string, providerId: string) {
|
||||
return await this.requests.delete<AIProviderOut>(routes.providersId(groupId, providerId));
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,11 @@ import type { DebugResponse } from "~/lib/api/types/admin";
|
||||
const prefix = "/api";
|
||||
|
||||
const routes = {
|
||||
openai: `${prefix}/admin/debug/openai`,
|
||||
openai: providerId => `${prefix}/admin/debug/openai/${providerId}`,
|
||||
};
|
||||
|
||||
export class AdminDebugAPI extends BaseAPI {
|
||||
async debugOpenAI(fileObject: Blob | File | undefined = undefined, fileName = "") {
|
||||
async debugOpenAI(providerId: string, fileObject: Blob | File | undefined = undefined, fileName = "") {
|
||||
let formData: FormData | null = null;
|
||||
if (fileObject) {
|
||||
formData = new FormData();
|
||||
@@ -16,6 +16,6 @@ export class AdminDebugAPI extends BaseAPI {
|
||||
formData.append("extension", fileName.split(".").pop() ?? "");
|
||||
}
|
||||
|
||||
return await this.requests.post<DebugResponse>(routes.openai, formData);
|
||||
return await this.requests.post<DebugResponse>(routes.openai(providerId), formData);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user