@@ -15,6 +15,8 @@ import (
1515// 模型管理
1616// ---------------------------------------------------------------------------
1717
18+ const maxSystemPromptChars = 20000
19+
1820// ListModelsInput 定义模型列表筛选排序条件。
1921type ListModelsInput struct {
2022 Query string
@@ -220,13 +222,18 @@ func (s *Service) CreateModel(ctx context.Context, input CreateModelInput) (*Mod
220222 if err := validateOptionalJSON (strings .TrimSpace (input .CapabilitiesJSON )); err != nil {
221223 return nil , ErrInvalidJSONConfig
222224 }
225+ systemPrompt := strings .TrimSpace (input .SystemPrompt )
226+ if len ([]rune (systemPrompt )) > maxSystemPromptChars {
227+ return nil , ErrSystemPromptTooLong
228+ }
223229
224230 item := & domainchannel.PlatformModel {
225231 PlatformModelName : platformModelName ,
226232 Vendor : normalizeModelVendor (input .Vendor , platformModelName ),
227233 KindsJSON : kindsJSON ,
228234 Icon : normalizeModelIcon (input .Icon , input .Vendor , platformModelName ),
229235 CapabilitiesJSON : strings .TrimSpace (input .CapabilitiesJSON ),
236+ SystemPrompt : systemPrompt ,
230237 Status : normalizeStatus (input .Status ),
231238 Description : strings .TrimSpace (input .Description ),
232239 }
@@ -281,6 +288,13 @@ func (s *Service) UpdateModel(ctx context.Context, modelID uint, input UpdateMod
281288 }
282289 update .CapabilitiesJSON = & normalized
283290 }
291+ if input .SystemPrompt != nil {
292+ systemPrompt := strings .TrimSpace (* input .SystemPrompt )
293+ if len ([]rune (systemPrompt )) > maxSystemPromptChars {
294+ return nil , ErrSystemPromptTooLong
295+ }
296+ update .SystemPrompt = & systemPrompt
297+ }
284298 if input .Status != nil {
285299 status := normalizeStatus (* input .Status )
286300 update .Status = & status
0 commit comments