mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
Add frontend vision LLM config types, API, atoms, and role manager wiring
This commit is contained in:
parent
4a675b64f4
commit
3369b8a832
7 changed files with 421 additions and 20 deletions
58
surfsense_web/lib/apis/vision-llm-config-api.service.ts
Normal file
58
surfsense_web/lib/apis/vision-llm-config-api.service.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import {
|
||||
type CreateVisionLLMConfigRequest,
|
||||
createVisionLLMConfigRequest,
|
||||
createVisionLLMConfigResponse,
|
||||
deleteVisionLLMConfigResponse,
|
||||
getGlobalVisionLLMConfigsResponse,
|
||||
getVisionLLMConfigsResponse,
|
||||
type UpdateVisionLLMConfigRequest,
|
||||
updateVisionLLMConfigRequest,
|
||||
updateVisionLLMConfigResponse,
|
||||
} from "@/contracts/types/new-llm-config.types";
|
||||
import { ValidationError } from "../error";
|
||||
import { baseApiService } from "./base-api.service";
|
||||
|
||||
class VisionLLMConfigApiService {
|
||||
getGlobalConfigs = async () => {
|
||||
return baseApiService.get(
|
||||
`/api/v1/global-vision-llm-configs`,
|
||||
getGlobalVisionLLMConfigsResponse
|
||||
);
|
||||
};
|
||||
|
||||
createConfig = async (request: CreateVisionLLMConfigRequest) => {
|
||||
const parsed = createVisionLLMConfigRequest.safeParse(request);
|
||||
if (!parsed.success) {
|
||||
const msg = parsed.error.issues.map((i) => i.message).join(", ");
|
||||
throw new ValidationError(`Invalid request: ${msg}`);
|
||||
}
|
||||
return baseApiService.post(`/api/v1/vision-llm-configs`, createVisionLLMConfigResponse, {
|
||||
body: parsed.data,
|
||||
});
|
||||
};
|
||||
|
||||
getConfigs = async (searchSpaceId: number) => {
|
||||
const params = new URLSearchParams({
|
||||
search_space_id: String(searchSpaceId),
|
||||
}).toString();
|
||||
return baseApiService.get(`/api/v1/vision-llm-configs?${params}`, getVisionLLMConfigsResponse);
|
||||
};
|
||||
|
||||
updateConfig = async (request: UpdateVisionLLMConfigRequest) => {
|
||||
const parsed = updateVisionLLMConfigRequest.safeParse(request);
|
||||
if (!parsed.success) {
|
||||
const msg = parsed.error.issues.map((i) => i.message).join(", ");
|
||||
throw new ValidationError(`Invalid request: ${msg}`);
|
||||
}
|
||||
const { id, data } = parsed.data;
|
||||
return baseApiService.put(`/api/v1/vision-llm-configs/${id}`, updateVisionLLMConfigResponse, {
|
||||
body: data,
|
||||
});
|
||||
};
|
||||
|
||||
deleteConfig = async (id: number) => {
|
||||
return baseApiService.delete(`/api/v1/vision-llm-configs/${id}`, deleteVisionLLMConfigResponse);
|
||||
};
|
||||
}
|
||||
|
||||
export const visionLLMConfigApiService = new VisionLLMConfigApiService();
|
||||
|
|
@ -39,6 +39,11 @@ export const cacheKeys = {
|
|||
byId: (configId: number) => ["image-gen-configs", "detail", configId] as const,
|
||||
global: () => ["image-gen-configs", "global"] as const,
|
||||
},
|
||||
visionLLMConfigs: {
|
||||
all: (searchSpaceId: number) => ["vision-llm-configs", searchSpaceId] as const,
|
||||
byId: (configId: number) => ["vision-llm-configs", "detail", configId] as const,
|
||||
global: () => ["vision-llm-configs", "global"] as const,
|
||||
},
|
||||
auth: {
|
||||
user: ["auth", "user"] as const,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue