{"record":{"id":"a64c3156762bd1ea","repo":"siyuan-note/siyuan","slug":"no-ai-editing-model-configured","errorCode":null,"errorMessage":"no AI editing model configured","messagePattern":"no AI editing model configured","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/ai.go","lineNumber":162,"sourceCode":"\t\terr = errors.New(\"AI editor stream idle timeout\")\n\t}\n\treturn\n}\n\nfunc (stream *AIEditorChatStream) Close() {\n\tstream.cancel()\n\tstream.stream.Close()\n}\n\n// NewAIEditorChatStream 创建绑定到编辑器请求生命周期的模型流。\nfunc NewAIEditorChatStream(ctx context.Context, ids []string, input, action string, history []AIEditorMessage) (*AIEditorChatStream, error) {\n\tif !Conf.AI.HasAnyProvider() {\n\t\treturn nil, errors.New(\"no AI provider configured\")\n\t}\n\n\tprov, m := Conf.AI.GetEditingModel()\n\tif nil == prov || nil == m {\n\t\treturn nil, errors.New(\"no AI editing model configured\")\n\t}\n\tediting := Conf.AI.Editing\n\tif nil == editing {\n\t\treturn nil, errors.New(\"no AI editing config\")\n\t}\n\n\tif \"\" == input && 0 < len(ids) {\n\t\tinput = getBlocksContent(ids)\n\t}\n\tprompt := BuildAIEditorPrompt(input, action)\n\tif \"\" == strings.TrimSpace(prompt) {\n\t\treturn nil, errors.New(\"AI editor input is empty\")\n\t}\n\n\tmessages := buildAIEditorMessages(prompt, history, editing.MaxHistoryMessages)\n\n\treq := openai.ChatCompletionRequest{\n\t\tModel:               m.Name,","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/ai.go#L144-L180","documentation":"After confirming a provider exists, NewAIEditorChatStream resolves the editing model via Conf.AI.GetEditingModel(); if either the provider or the model is nil, it returns \"no AI editing model configured\". The editor AI chat specifically requires an editing-capable model to be selected, distinct from merely having any provider.","triggerScenarios":"Calling the aiEditorChat contract endpoint when providers exist but the editing model (and/or its provider) is not selected in AI settings, or the selected model references a deleted provider.","commonSituations":"Provider added but no editing model chosen, editing model pointing to a removed/renamed provider entry after config edits, sync merging configs where the model selection was lost, upgrading with new config schema.","solutions":["Open Settings - AI and select an editing model (and its provider) for the editor chat feature","Verify Conf.AI.GetEditingModel() resolves both provider and model — re-select the model if it points at a deleted provider","Re-save AI settings to rebuild the provider/model references after config edits","Check for config schema/version mismatch after upgrading if selection keeps getting lost"],"exampleFix":"// before\nstream, err := model.NewAIEditorChatStream(ctx, ids, input, action, history) // fails: no editing model\n// after\nprov, m := conf.AI.GetEditingModel()\nif prov == nil || m == nil {\n    return errors.New(\"select an AI editing model in Settings - AI first\")\n}\nstream, err := model.NewAIEditorChatStream(ctx, ids, input, action, history)","handlingStrategy":"validation","validationCode":"prov, m := conf.AI.GetEditingModel()\nif prov == nil || m == nil {\n    return errors.New(\"no AI editing model selected; set one in Settings - AI\")\n}","typeGuard":"null","tryCatchPattern":"stream, err := model.NewAIEditorChatStream(ctx, ids, input, action, history)\nif err != nil {\n    if strings.Contains(err.Error(), \"no AI editing model configured\") {\n        return promptUserToSelectEditingModel()\n    }\n    return err\n}","preventionTips":["Select an editing model after adding any provider","After editing config manually or syncing, verify the editing model still resolves to an existing provider","Prompt users to pick a model instead of assuming defaults exist","Re-save AI settings after upgrades that change provider/model schema"],"tags":["ai","configuration","model-selection"],"backgroundTag":"missing-required-config-field","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}