feat: Enhance Kol Generation Service with web search and knowledge group support

- Added `EnableWebSearch` and `KnowledgeGroupIDs` fields to `KolGenerationSubmitRequest`.
- Updated `Submit` method in `KolGenerationService` to handle new request fields.
- Integrated web search and knowledge group validation based on card configuration.
- Introduced caching mechanisms in `KolPackageService`, `KolPromptService`, and `KolSubscriptionAdminService` to improve performance.
- Implemented knowledge context resolution in `KolGenerationWorker` to enrich prompts with relevant knowledge snippets.
- Added utility functions for handling card configuration in both backend and frontend.
- Created tests for knowledge extraction and rendering to ensure accuracy and reliability.
This commit is contained in:
2026-04-18 13:47:32 +08:00
parent 3ef0807456
commit b2605abd6a
27 changed files with 2051 additions and 171 deletions
+11 -3
View File
@@ -228,6 +228,7 @@ export interface ArticleListParams {
source_type?: string;
generation_mode?: string;
template_id?: number;
kol_prompt_id?: number;
prompt_rule_id?: number;
keyword?: string;
created_from?: string;
@@ -1251,7 +1252,7 @@ export interface KolPromptDetail {
published_revision_no: number | null;
draft_revision_no: number | null;
latest_schema_json: KolSchemaJson | null;
latest_card_config_json: Record<string, unknown> | null;
latest_card_config_json: KolCardConfig | null;
latest_prompt_content: string | null;
created_at: string;
updated_at: string;
@@ -1285,11 +1286,18 @@ export interface KolSubscriptionPromptSchema {
package_name: string;
platform_hint: string | null;
schema_json: KolSchemaJson;
card_config_json: Record<string, unknown>;
card_config_json: KolCardConfig;
}
export type KolCardConfig = Record<string, unknown> & {
allow_web_search?: boolean;
allow_user_knowledge?: boolean;
};
export interface KolGenerateRequest {
variables: Record<string, string | number | boolean | string[]>;
enable_web_search?: boolean;
knowledge_group_ids?: number[];
}
export interface KolGenerateResponse {
@@ -1364,5 +1372,5 @@ export interface UpdateKolPromptRequest {
export interface PublishKolPromptRequest extends UpdateKolPromptRequest {
content: string;
schema: KolSchemaJson;
card_config: Record<string, unknown>;
card_config: KolCardConfig;
}