mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
feat: add global LLM config schemas with proper structure
This commit is contained in:
parent
1d2d8d8b74
commit
47efd9c45d
1 changed files with 22 additions and 3 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
// LiteLLM Provider enum matching backend
|
|
||||||
export const liteLLMProviderEnum = z.enum([
|
export const liteLLMProviderEnum = z.enum([
|
||||||
"OPENAI",
|
"OPENAI",
|
||||||
"ANTHROPIC",
|
"ANTHROPIC",
|
||||||
|
|
@ -34,7 +33,6 @@ export const liteLLMProviderEnum = z.enum([
|
||||||
"CUSTOM",
|
"CUSTOM",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Base LLM Config schema
|
|
||||||
export const llmConfig = z.object({
|
export const llmConfig = z.object({
|
||||||
id: z.number(),
|
id: z.number(),
|
||||||
name: z.string().max(100),
|
name: z.string().max(100),
|
||||||
|
|
@ -50,6 +48,27 @@ export const llmConfig = z.object({
|
||||||
updated_at: z.string(),
|
updated_at: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Inferred types
|
export const globalLLMConfig = llmConfig
|
||||||
|
.pick({
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
custom_provider: true,
|
||||||
|
model_name: true,
|
||||||
|
api_base: true,
|
||||||
|
language: true,
|
||||||
|
litellm_params: true,
|
||||||
|
})
|
||||||
|
.extend({
|
||||||
|
provider: z.string(),
|
||||||
|
is_global: z.literal(true),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get global LLM configs
|
||||||
|
*/
|
||||||
|
export const getGlobalLLMConfigsResponse = z.array(globalLLMConfig);
|
||||||
|
|
||||||
export type LLMConfig = z.infer<typeof llmConfig>;
|
export type LLMConfig = z.infer<typeof llmConfig>;
|
||||||
export type LiteLLMProvider = z.infer<typeof liteLLMProviderEnum>;
|
export type LiteLLMProvider = z.infer<typeof liteLLMProviderEnum>;
|
||||||
|
export type GlobalLLMConfig = z.infer<typeof globalLLMConfig>;
|
||||||
|
export type GetGlobalLLMConfigsResponse = z.infer<typeof getGlobalLLMConfigsResponse>;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue