mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-30 21:59:46 +02:00
Merge remote-tracking branch 'upstream/dev' into fix/documents
This commit is contained in:
commit
0fdd194d92
60 changed files with 5086 additions and 248 deletions
105
surfsense_web/contracts/enums/image-gen-providers.ts
Normal file
105
surfsense_web/contracts/enums/image-gen-providers.ts
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
export interface ImageGenProvider {
|
||||
value: string;
|
||||
label: string;
|
||||
example: string;
|
||||
description: string;
|
||||
apiBase?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Image generation providers supported by LiteLLM.
|
||||
* See: https://docs.litellm.ai/docs/image_generation#supported-providers
|
||||
*/
|
||||
export const IMAGE_GEN_PROVIDERS: ImageGenProvider[] = [
|
||||
{
|
||||
value: "OPENAI",
|
||||
label: "OpenAI",
|
||||
example: "dall-e-3, gpt-image-1, dall-e-2",
|
||||
description: "DALL-E and GPT Image models",
|
||||
},
|
||||
{
|
||||
value: "AZURE_OPENAI",
|
||||
label: "Azure OpenAI",
|
||||
example: "azure/dall-e-3, azure/gpt-image-1",
|
||||
description: "OpenAI image models on Azure",
|
||||
},
|
||||
{
|
||||
value: "GOOGLE",
|
||||
label: "Google AI Studio",
|
||||
example: "gemini/imagen-3.0-generate-002",
|
||||
description: "Google AI Studio image generation",
|
||||
},
|
||||
{
|
||||
value: "VERTEX_AI",
|
||||
label: "Google Vertex AI",
|
||||
example: "vertex_ai/imagegeneration@006",
|
||||
description: "Vertex AI image generation models",
|
||||
},
|
||||
{
|
||||
value: "BEDROCK",
|
||||
label: "AWS Bedrock",
|
||||
example: "bedrock/stability.stable-diffusion-xl-v0",
|
||||
description: "Stable Diffusion on AWS Bedrock",
|
||||
},
|
||||
{
|
||||
value: "RECRAFT",
|
||||
label: "Recraft",
|
||||
example: "recraft/recraftv3",
|
||||
description: "AI-powered design and image generation",
|
||||
},
|
||||
{
|
||||
value: "OPENROUTER",
|
||||
label: "OpenRouter",
|
||||
example: "openrouter/google/gemini-2.5-flash-image",
|
||||
description: "Image generation via OpenRouter",
|
||||
},
|
||||
{
|
||||
value: "XINFERENCE",
|
||||
label: "Xinference",
|
||||
example: "xinference/stable-diffusion-xl",
|
||||
description: "Self-hosted Stable Diffusion models",
|
||||
},
|
||||
{
|
||||
value: "NSCALE",
|
||||
label: "Nscale",
|
||||
example: "nscale/flux.1-schnell",
|
||||
description: "Nscale image generation",
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Image generation models organized by provider.
|
||||
*/
|
||||
export interface ImageGenModel {
|
||||
value: string;
|
||||
label: string;
|
||||
provider: string;
|
||||
}
|
||||
|
||||
export const IMAGE_GEN_MODELS: ImageGenModel[] = [
|
||||
// OpenAI
|
||||
{ value: "gpt-image-1", label: "GPT Image 1", provider: "OPENAI" },
|
||||
{ value: "dall-e-3", label: "DALL-E 3", provider: "OPENAI" },
|
||||
{ value: "dall-e-2", label: "DALL-E 2", provider: "OPENAI" },
|
||||
// Azure OpenAI
|
||||
{ value: "azure/dall-e-3", label: "DALL-E 3 (Azure)", provider: "AZURE_OPENAI" },
|
||||
{ value: "azure/gpt-image-1", label: "GPT Image 1 (Azure)", provider: "AZURE_OPENAI" },
|
||||
// Recraft
|
||||
{ value: "recraft/recraftv3", label: "Recraft V3", provider: "RECRAFT" },
|
||||
// Bedrock
|
||||
{
|
||||
value: "bedrock/stability.stable-diffusion-xl-v0",
|
||||
label: "Stable Diffusion XL",
|
||||
provider: "BEDROCK",
|
||||
},
|
||||
// Vertex AI
|
||||
{
|
||||
value: "vertex_ai/imagegeneration@006",
|
||||
label: "Imagen 3",
|
||||
provider: "VERTEX_AI",
|
||||
},
|
||||
];
|
||||
|
||||
export function getImageGenModelsByProvider(provider: string): ImageGenModel[] {
|
||||
return IMAGE_GEN_MODELS.filter((m) => m.provider === provider);
|
||||
}
|
||||
|
|
@ -161,19 +161,105 @@ export const globalNewLLMConfig = z.object({
|
|||
|
||||
export const getGlobalNewLLMConfigsResponse = z.array(globalNewLLMConfig);
|
||||
|
||||
// =============================================================================
|
||||
// Image Generation Config (separate table from NewLLMConfig)
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* ImageGenProvider enum - only providers that support image generation
|
||||
* See: https://docs.litellm.ai/docs/image_generation#supported-providers
|
||||
*/
|
||||
export const imageGenProviderEnum = z.enum([
|
||||
"OPENAI",
|
||||
"AZURE_OPENAI",
|
||||
"GOOGLE",
|
||||
"VERTEX_AI",
|
||||
"BEDROCK",
|
||||
"RECRAFT",
|
||||
"OPENROUTER",
|
||||
"XINFERENCE",
|
||||
"NSCALE",
|
||||
]);
|
||||
|
||||
export type ImageGenProvider = z.infer<typeof imageGenProviderEnum>;
|
||||
|
||||
/**
|
||||
* ImageGenerationConfig - user-created image gen model configs
|
||||
* Separate from NewLLMConfig: no system_instructions, no citations_enabled.
|
||||
*/
|
||||
export const imageGenerationConfig = z.object({
|
||||
id: z.number(),
|
||||
name: z.string().max(100),
|
||||
description: z.string().max(500).nullable().optional(),
|
||||
provider: imageGenProviderEnum,
|
||||
custom_provider: z.string().max(100).nullable().optional(),
|
||||
model_name: z.string().max(100),
|
||||
api_key: z.string(),
|
||||
api_base: z.string().max(500).nullable().optional(),
|
||||
api_version: z.string().max(50).nullable().optional(),
|
||||
litellm_params: z.record(z.string(), z.any()).nullable().optional(),
|
||||
created_at: z.string(),
|
||||
search_space_id: z.number(),
|
||||
});
|
||||
|
||||
export const createImageGenConfigRequest = imageGenerationConfig.omit({
|
||||
id: true,
|
||||
created_at: true,
|
||||
});
|
||||
|
||||
export const createImageGenConfigResponse = imageGenerationConfig;
|
||||
|
||||
export const getImageGenConfigsResponse = z.array(imageGenerationConfig);
|
||||
|
||||
export const updateImageGenConfigRequest = z.object({
|
||||
id: z.number(),
|
||||
data: imageGenerationConfig
|
||||
.omit({ id: true, created_at: true, search_space_id: true })
|
||||
.partial(),
|
||||
});
|
||||
|
||||
export const updateImageGenConfigResponse = imageGenerationConfig;
|
||||
|
||||
export const deleteImageGenConfigResponse = z.object({
|
||||
message: z.string(),
|
||||
id: z.number(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Global Image Generation Config - from YAML, has negative IDs
|
||||
* ID 0 is reserved for "Auto" mode (LiteLLM Router load balancing)
|
||||
*/
|
||||
export const globalImageGenConfig = z.object({
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
description: z.string().nullable().optional(),
|
||||
provider: z.string(),
|
||||
custom_provider: z.string().nullable().optional(),
|
||||
model_name: z.string(),
|
||||
api_base: z.string().nullable().optional(),
|
||||
api_version: z.string().nullable().optional(),
|
||||
litellm_params: z.record(z.string(), z.any()).nullable().optional(),
|
||||
is_global: z.literal(true),
|
||||
is_auto_mode: z.boolean().optional().default(false),
|
||||
});
|
||||
|
||||
export const getGlobalImageGenConfigsResponse = z.array(globalImageGenConfig);
|
||||
|
||||
// =============================================================================
|
||||
// LLM Preferences (Role Assignments)
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* LLM Preferences schemas - for role assignments
|
||||
* The agent_llm and document_summary_llm fields contain the full NewLLMConfig objects
|
||||
* image_generation uses image_generation_config_id (not llm_id)
|
||||
*/
|
||||
export const llmPreferences = z.object({
|
||||
agent_llm_id: z.union([z.number(), z.null()]).optional(),
|
||||
document_summary_llm_id: z.union([z.number(), z.null()]).optional(),
|
||||
image_generation_config_id: z.union([z.number(), z.null()]).optional(),
|
||||
agent_llm: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
|
||||
document_summary_llm: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
|
||||
image_generation_config: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
@ -193,6 +279,7 @@ export const updateLLMPreferencesRequest = z.object({
|
|||
data: llmPreferences.pick({
|
||||
agent_llm_id: true,
|
||||
document_summary_llm_id: true,
|
||||
image_generation_config_id: true,
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
@ -219,6 +306,15 @@ export type GetDefaultSystemInstructionsResponse = z.infer<
|
|||
>;
|
||||
export type GlobalNewLLMConfig = z.infer<typeof globalNewLLMConfig>;
|
||||
export type GetGlobalNewLLMConfigsResponse = z.infer<typeof getGlobalNewLLMConfigsResponse>;
|
||||
export type ImageGenerationConfig = z.infer<typeof imageGenerationConfig>;
|
||||
export type CreateImageGenConfigRequest = z.infer<typeof createImageGenConfigRequest>;
|
||||
export type CreateImageGenConfigResponse = z.infer<typeof createImageGenConfigResponse>;
|
||||
export type GetImageGenConfigsResponse = z.infer<typeof getImageGenConfigsResponse>;
|
||||
export type UpdateImageGenConfigRequest = z.infer<typeof updateImageGenConfigRequest>;
|
||||
export type UpdateImageGenConfigResponse = z.infer<typeof updateImageGenConfigResponse>;
|
||||
export type DeleteImageGenConfigResponse = z.infer<typeof deleteImageGenConfigResponse>;
|
||||
export type GlobalImageGenConfig = z.infer<typeof globalImageGenConfig>;
|
||||
export type GetGlobalImageGenConfigsResponse = z.infer<typeof getGlobalImageGenConfigsResponse>;
|
||||
export type LLMPreferences = z.infer<typeof llmPreferences>;
|
||||
export type GetLLMPreferencesRequest = z.infer<typeof getLLMPreferencesRequest>;
|
||||
export type GetLLMPreferencesResponse = z.infer<typeof getLLMPreferencesResponse>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue