mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
style: simplify LLM model terminology in UI
This commit is contained in:
parent
d2cf3fb3b7
commit
000c2d9b5b
18 changed files with 32 additions and 32 deletions
|
|
@ -24,7 +24,7 @@ SurfSense 现已支持以下国产 LLM:
|
||||||
|
|
||||||
1. 登录 SurfSense Dashboard
|
1. 登录 SurfSense Dashboard
|
||||||
2. 进入 **Settings** → **API Keys** (或 **LLM Configurations**)
|
2. 进入 **Settings** → **API Keys** (或 **LLM Configurations**)
|
||||||
3. 点击 **Add LLM Model**
|
3. 点击 **Add Model**
|
||||||
4. 从 **Provider** 下拉菜单中选择你的国产 LLM 提供商
|
4. 从 **Provider** 下拉菜单中选择你的国产 LLM 提供商
|
||||||
5. 填写必填字段(见下方各提供商详细配置)
|
5. 填写必填字段(见下方各提供商详细配置)
|
||||||
6. 点击 **Save**
|
6. 点击 **Save**
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@ depends_on: str | Sequence[str] | None = None
|
||||||
|
|
||||||
def upgrade() -> None:
|
def upgrade() -> None:
|
||||||
"""
|
"""
|
||||||
Add the new_llm_configs table that combines LLM model settings with prompt configuration.
|
Add the new_llm_configs table that combines model settings with prompt configuration.
|
||||||
|
|
||||||
This table includes:
|
This table includes:
|
||||||
- LLM model configuration (provider, model_name, api_key, etc.)
|
- Model configuration (provider, model_name, api_key, etc.)
|
||||||
- Configurable system instructions
|
- Configurable system instructions
|
||||||
- Citation toggle
|
- Citation toggle
|
||||||
"""
|
"""
|
||||||
|
|
@ -41,7 +41,7 @@ def upgrade() -> None:
|
||||||
name VARCHAR(100) NOT NULL,
|
name VARCHAR(100) NOT NULL,
|
||||||
description VARCHAR(500),
|
description VARCHAR(500),
|
||||||
|
|
||||||
-- LLM Model Configuration (same as llm_configs, excluding language)
|
-- Model Configuration (same as llm_configs, excluding language)
|
||||||
provider litellmprovider NOT NULL,
|
provider litellmprovider NOT NULL,
|
||||||
custom_provider VARCHAR(100),
|
custom_provider VARCHAR(100),
|
||||||
model_name VARCHAR(100) NOT NULL,
|
model_name VARCHAR(100) NOT NULL,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# - Configure router_settings below to customize the load balancing behavior
|
# - Configure router_settings below to customize the load balancing behavior
|
||||||
#
|
#
|
||||||
# Structure matches NewLLMConfig:
|
# Structure matches NewLLMConfig:
|
||||||
# - LLM model configuration (provider, model_name, api_key, etc.)
|
# - Model configuration (provider, model_name, api_key, etc.)
|
||||||
# - Prompt configuration (system_instructions, citations_enabled)
|
# - Prompt configuration (system_instructions, citations_enabled)
|
||||||
|
|
||||||
# Router Settings for Auto Mode
|
# Router Settings for Auto Mode
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class PipelineMessages:
|
||||||
|
|
||||||
LLM_AUTH = "LLM authentication failed. Check your API key."
|
LLM_AUTH = "LLM authentication failed. Check your API key."
|
||||||
LLM_PERMISSION = "LLM request denied. Check your account permissions."
|
LLM_PERMISSION = "LLM request denied. Check your account permissions."
|
||||||
LLM_NOT_FOUND = "LLM model not found. Check your model configuration."
|
LLM_NOT_FOUND = "Model not found. Check your model configuration."
|
||||||
LLM_BAD_REQUEST = "LLM rejected the request. Document content may be invalid."
|
LLM_BAD_REQUEST = "LLM rejected the request. Document content may be invalid."
|
||||||
LLM_UNPROCESSABLE = (
|
LLM_UNPROCESSABLE = (
|
||||||
"Document exceeds the LLM context window even after optimization."
|
"Document exceeds the LLM context window even after optimization."
|
||||||
|
|
@ -67,7 +67,7 @@ class PipelineMessages:
|
||||||
LLM_RESPONSE = "LLM returned an invalid response."
|
LLM_RESPONSE = "LLM returned an invalid response."
|
||||||
LLM_AUTH = "LLM authentication failed. Check your API key."
|
LLM_AUTH = "LLM authentication failed. Check your API key."
|
||||||
LLM_PERMISSION = "LLM request denied. Check your account permissions."
|
LLM_PERMISSION = "LLM request denied. Check your account permissions."
|
||||||
LLM_NOT_FOUND = "LLM model not found. Check your model configuration."
|
LLM_NOT_FOUND = "Model not found. Check your model configuration."
|
||||||
LLM_BAD_REQUEST = "LLM rejected the request. Document content may be invalid."
|
LLM_BAD_REQUEST = "LLM rejected the request. Document content may be invalid."
|
||||||
LLM_UNPROCESSABLE = (
|
LLM_UNPROCESSABLE = (
|
||||||
"Document exceeds the LLM context window even after optimization."
|
"Document exceeds the LLM context window even after optimization."
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ router.include_router(confluence_add_connector_router)
|
||||||
router.include_router(clickup_add_connector_router)
|
router.include_router(clickup_add_connector_router)
|
||||||
router.include_router(dropbox_add_connector_router)
|
router.include_router(dropbox_add_connector_router)
|
||||||
router.include_router(new_llm_config_router) # LLM configs with prompt configuration
|
router.include_router(new_llm_config_router) # LLM configs with prompt configuration
|
||||||
router.include_router(model_list_router) # Dynamic LLM model catalogue from OpenRouter
|
router.include_router(model_list_router) # Dynamic model catalogue from OpenRouter
|
||||||
router.include_router(logs_router)
|
router.include_router(logs_router)
|
||||||
router.include_router(circleback_webhook_router) # Circleback meeting webhooks
|
router.include_router(circleback_webhook_router) # Circleback meeting webhooks
|
||||||
router.include_router(surfsense_docs_router) # Surfsense documentation for citations
|
router.include_router(surfsense_docs_router) # Surfsense documentation for citations
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
API route for fetching the available LLM models catalogue.
|
API route for fetching the available models catalogue.
|
||||||
|
|
||||||
Serves a dynamically-updated list sourced from the OpenRouter public API,
|
Serves a dynamically-updated list sourced from the OpenRouter public API,
|
||||||
with a local JSON fallback when the API is unreachable.
|
with a local JSON fallback when the API is unreachable.
|
||||||
|
|
@ -30,7 +30,7 @@ async def list_available_models(
|
||||||
user: User = Depends(current_active_user),
|
user: User = Depends(current_active_user),
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Return all available LLM models grouped by provider.
|
Return all available models grouped by provider.
|
||||||
|
|
||||||
The list is sourced from the OpenRouter public API and cached for 1 hour.
|
The list is sourced from the OpenRouter public API and cached for 1 hour.
|
||||||
If the API is unreachable, a local fallback file is used instead.
|
If the API is unreachable, a local fallback file is used instead.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"""
|
"""
|
||||||
API routes for NewLLMConfig CRUD operations.
|
API routes for NewLLMConfig CRUD operations.
|
||||||
|
|
||||||
NewLLMConfig combines LLM model settings with prompt configuration:
|
NewLLMConfig combines model settings with prompt configuration:
|
||||||
- LLM provider, model, API key, etc.
|
- LLM provider, model, API key, etc.
|
||||||
- Configurable system instructions
|
- Configurable system instructions
|
||||||
- Citation toggle
|
- Citation toggle
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Pydantic schemas for the NewLLMConfig API.
|
Pydantic schemas for the NewLLMConfig API.
|
||||||
|
|
||||||
NewLLMConfig combines LLM model settings with prompt configuration:
|
NewLLMConfig combines model settings with prompt configuration:
|
||||||
- LLM provider, model, API key, etc.
|
- LLM provider, model, API key, etc.
|
||||||
- Configurable system instructions
|
- Configurable system instructions
|
||||||
- Citation toggle
|
- Citation toggle
|
||||||
|
|
@ -26,7 +26,7 @@ class NewLLMConfigBase(BaseModel):
|
||||||
None, max_length=500, description="Optional description"
|
None, max_length=500, description="Optional description"
|
||||||
)
|
)
|
||||||
|
|
||||||
# LLM Model Configuration
|
# Model Configuration
|
||||||
provider: LiteLLMProvider = Field(..., description="LiteLLM provider type")
|
provider: LiteLLMProvider = Field(..., description="LiteLLM provider type")
|
||||||
custom_provider: str | None = Field(
|
custom_provider: str | None = Field(
|
||||||
None, max_length=100, description="Custom provider name when provider is CUSTOM"
|
None, max_length=100, description="Custom provider name when provider is CUSTOM"
|
||||||
|
|
@ -71,7 +71,7 @@ class NewLLMConfigUpdate(BaseModel):
|
||||||
name: str | None = Field(None, max_length=100)
|
name: str | None = Field(None, max_length=100)
|
||||||
description: str | None = Field(None, max_length=500)
|
description: str | None = Field(None, max_length=500)
|
||||||
|
|
||||||
# LLM Model Configuration
|
# Model Configuration
|
||||||
provider: LiteLLMProvider | None = None
|
provider: LiteLLMProvider | None = None
|
||||||
custom_provider: str | None = Field(None, max_length=100)
|
custom_provider: str | None = Field(None, max_length=100)
|
||||||
model_name: str | None = Field(None, max_length=100)
|
model_name: str | None = Field(None, max_length=100)
|
||||||
|
|
@ -106,7 +106,7 @@ class NewLLMConfigPublic(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
description: str | None = None
|
description: str | None = None
|
||||||
|
|
||||||
# LLM Model Configuration (no api_key)
|
# Model Configuration (no api_key)
|
||||||
provider: LiteLLMProvider
|
provider: LiteLLMProvider
|
||||||
custom_provider: str | None = None
|
custom_provider: str | None = None
|
||||||
model_name: str
|
model_name: str
|
||||||
|
|
@ -149,7 +149,7 @@ class GlobalNewLLMConfigRead(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
description: str | None = None
|
description: str | None = None
|
||||||
|
|
||||||
# LLM Model Configuration (no api_key)
|
# Model Configuration (no api_key)
|
||||||
provider: str # String because YAML doesn't enforce enum, "AUTO" for Auto mode
|
provider: str # String because YAML doesn't enforce enum, "AUTO" for Auto mode
|
||||||
custom_provider: str | None = None
|
custom_provider: str | None = None
|
||||||
model_name: str
|
model_name: str
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
Service for fetching and caching the available LLM model list.
|
Service for fetching and caching the available model list.
|
||||||
|
|
||||||
Uses the OpenRouter public API as the primary source, with a local
|
Uses the OpenRouter public API as the primary source, with a local
|
||||||
fallback JSON file when the API is unreachable.
|
fallback JSON file when the API is unreachable.
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ export const createNewLLMConfigMutationAtom = atomWithMutation((get) => {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onError: (error: Error) => {
|
onError: (error: Error) => {
|
||||||
toast.error(error.message || "Failed to create LLM model");
|
toast.error(error.message || "Failed to create model");
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ export const defaultSystemInstructionsAtom = atomWithQuery(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query atom for the dynamic LLM model catalogue.
|
* Query atom for the dynamic model catalogue.
|
||||||
* Fetched from the backend (which proxies OpenRouter's public API).
|
* Fetched from the backend (which proxies OpenRouter's public API).
|
||||||
* Falls back to the static hardcoded list on error.
|
* Falls back to the static hardcoded list on error.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -498,7 +498,7 @@ export function ModelSelector({
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Plus className="size-4 text-primary" />
|
<Plus className="size-4 text-primary" />
|
||||||
<span className="text-sm font-medium">Add LLM Model</span>
|
<span className="text-sm font-medium">Add Model</span>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</CommandList>
|
</CommandList>
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ export function ModelConfigManager({ searchSpaceId }: ModelConfigManagerProps) {
|
||||||
onClick={openNewDialog}
|
onClick={openNewDialog}
|
||||||
className="gap-2 bg-white text-black hover:bg-neutral-100 dark:bg-white dark:text-black dark:hover:bg-neutral-200"
|
className="gap-2 bg-white text-black hover:bg-neutral-100 dark:bg-white dark:text-black dark:hover:bg-neutral-200"
|
||||||
>
|
>
|
||||||
Add LLM Model
|
Add Model
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -252,11 +252,11 @@ export function ModelConfigManager({ searchSpaceId }: ModelConfigManagerProps) {
|
||||||
<div>
|
<div>
|
||||||
<Card className="border-0 bg-transparent shadow-none">
|
<Card className="border-0 bg-transparent shadow-none">
|
||||||
<CardContent className="flex flex-col items-center justify-center py-10 md:py-16 text-center">
|
<CardContent className="flex flex-col items-center justify-center py-10 md:py-16 text-center">
|
||||||
<h3 className="text-sm md:text-base font-semibold mb-2">No LLM Models Yet</h3>
|
<h3 className="text-sm md:text-base font-semibold mb-2">No Models Yet</h3>
|
||||||
<p className="text-[11px] md:text-xs text-muted-foreground max-w-sm mb-4">
|
<p className="text-[11px] md:text-xs text-muted-foreground max-w-sm mb-4">
|
||||||
{canCreate
|
{canCreate
|
||||||
? "Add your first LLM model to power document summarization, chat, and other agent capabilities"
|
? "Add your first model to power document summarization, chat, and other agent capabilities"
|
||||||
: "No LLM models have been added to this space yet. Contact a space owner to add one"}
|
: "No models have been added to this space yet. Contact a space owner to add one"}
|
||||||
</p>
|
</p>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
@ -420,7 +420,7 @@ export function ModelConfigManager({ searchSpaceId }: ModelConfigManagerProps) {
|
||||||
>
|
>
|
||||||
<AlertDialogContent className="select-none">
|
<AlertDialogContent className="select-none">
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>Delete LLM Model</AlertDialogTitle>
|
<AlertDialogTitle>Delete Model</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
Are you sure you want to delete{" "}
|
Are you sure you want to delete{" "}
|
||||||
<span className="font-semibold text-foreground">{configToDelete?.name}</span>? This
|
<span className="font-semibold text-foreground">{configToDelete?.name}</span>? This
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ SurfSense uses [pytest](https://docs.pytest.org/) with two test layers: **unit**
|
||||||
|
|
||||||
- **PostgreSQL + pgvector** running locally (database `surfsense_test` will be used)
|
- **PostgreSQL + pgvector** running locally (database `surfsense_test` will be used)
|
||||||
- **`REGISTRATION_ENABLED=TRUE`** in your `.env` (this is the default)
|
- **`REGISTRATION_ENABLED=TRUE`** in your `.env` (this is the default)
|
||||||
- A working LLM model with a valid API key in `global_llm_config.yaml` (for integration tests)
|
- A working model with a valid API key in `global_llm_config.yaml` (for integration tests)
|
||||||
|
|
||||||
No Redis or Celery is required — integration tests use an inline task dispatcher.
|
No Redis or Celery is required — integration tests use an inline task dispatcher.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ export interface LLMModel {
|
||||||
contextWindow?: string;
|
contextWindow?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprehensive LLM models database organized by provider
|
// Comprehensive models database organized by provider
|
||||||
export const LLM_MODELS: LLMModel[] = [
|
export const LLM_MODELS: LLMModel[] = [
|
||||||
// OpenAI
|
// OpenAI
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,14 @@ export const liteLLMProviderEnum = z.enum([
|
||||||
export type LiteLLMProvider = z.infer<typeof liteLLMProviderEnum>;
|
export type LiteLLMProvider = z.infer<typeof liteLLMProviderEnum>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NewLLMConfig - combines LLM model settings with prompt configuration
|
* NewLLMConfig - combines model settings with prompt configuration
|
||||||
*/
|
*/
|
||||||
export const newLLMConfig = z.object({
|
export const newLLMConfig = z.object({
|
||||||
id: z.number(),
|
id: z.number(),
|
||||||
name: z.string().max(100),
|
name: z.string().max(100),
|
||||||
description: z.string().max(500).nullable().optional(),
|
description: z.string().max(500).nullable().optional(),
|
||||||
|
|
||||||
// LLM Model Configuration
|
// Model Configuration
|
||||||
provider: liteLLMProviderEnum,
|
provider: liteLLMProviderEnum,
|
||||||
custom_provider: z.string().max(100).nullable().optional(),
|
custom_provider: z.string().max(100).nullable().optional(),
|
||||||
model_name: z.string().max(100),
|
model_name: z.string().max(100),
|
||||||
|
|
@ -148,7 +148,7 @@ export const globalNewLLMConfig = z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
description: z.string().nullable().optional(),
|
description: z.string().nullable().optional(),
|
||||||
|
|
||||||
// LLM Model Configuration (no api_key)
|
// Model Configuration (no api_key)
|
||||||
provider: z.string(), // String because YAML doesn't enforce enum, "AUTO" for Auto mode
|
provider: z.string(), // String because YAML doesn't enforce enum, "AUTO" for Auto mode
|
||||||
custom_provider: z.string().nullable().optional(),
|
custom_provider: z.string().nullable().optional(),
|
||||||
model_name: z.string(),
|
model_name: z.string(),
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ class NewLLMConfigApiService {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the dynamic LLM model catalogue (sourced from OpenRouter API)
|
* Get the dynamic model catalogue (sourced from OpenRouter API)
|
||||||
*/
|
*/
|
||||||
getModels = async () => {
|
getModels = async () => {
|
||||||
return baseApiService.get(`/api/v1/models`, getModelListResponse);
|
return baseApiService.get(`/api/v1/models`, getModelListResponse);
|
||||||
|
|
|
||||||
|
|
@ -737,7 +737,7 @@
|
||||||
"nav_general": "General",
|
"nav_general": "General",
|
||||||
"nav_general_desc": "Name, description & basic info",
|
"nav_general_desc": "Name, description & basic info",
|
||||||
"nav_agent_configs": "Agent Configs",
|
"nav_agent_configs": "Agent Configs",
|
||||||
"nav_agent_configs_desc": "LLM models with prompts & citations",
|
"nav_agent_configs_desc": "Models with prompts & citations",
|
||||||
"nav_role_assignments": "Role Assignments",
|
"nav_role_assignments": "Role Assignments",
|
||||||
"nav_role_assignments_desc": "Assign configs to agent roles",
|
"nav_role_assignments_desc": "Assign configs to agent roles",
|
||||||
"nav_image_models": "Image Models",
|
"nav_image_models": "Image Models",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue