{"record":{"id":"5c7e0a7a95b07196","repo":"sigoden/aichat","slug":"no-available-embedding-model","errorCode":null,"errorMessage":"No available embedding model","messagePattern":"No available embedding model","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/rag/mod.rs","lineNumber":169,"sourceCode":"\n    pub fn create_config(config: &GlobalConfig) -> Result<(Model, usize, usize)> {\n        let (embedding_model_id, chunk_size, chunk_overlap) = {\n            let config = config.read();\n            (\n                config.rag_embedding_model.clone(),\n                config.rag_chunk_size,\n                config.rag_chunk_overlap,\n            )\n        };\n        let embedding_model_id = match embedding_model_id {\n            Some(value) => {\n                println!(\"Select embedding model: {value}\");\n                value\n            }\n            None => {\n                let models = list_models(&config.read(), ModelType::Embedding);\n                if models.is_empty() {\n                    bail!(\"No available embedding model\");\n                }\n                select_embedding_model(&models)?\n            }\n        };\n        let embedding_model =\n            Model::retrieve_model(&config.read(), &embedding_model_id, ModelType::Embedding)?;\n\n        let chunk_size = match chunk_size {\n            Some(value) => {\n                println!(\"Set chunk size: {value}\");\n                value\n            }\n            None => set_chunk_size(&embedding_model)?,\n        };\n        let chunk_overlap = match chunk_overlap {\n            Some(value) => {\n                println!(\"Set chunk overlay: {value}\");\n                value","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/rag/mod.rs#L151-L187","documentation":"`Rag::create_config` needs an embedding model; when none was selected/known it lists configured embedding models, and if that list is empty there is no valid choice, so it bails with 'No available embedding model'.","triggerScenarios":"`create_config` reaches the `None` branch of the interactive selection (no pre-selected embedding model) and `list_models(config, ModelType::Embedding)` returns empty.","commonSituations":"Config has no embedding-capable models defined (e.g. only chat models configured); provider credentials missing so model discovery returns nothing; typo in model type in the config.","solutions":["Add an embedding model to the config (e.g. an OpenAI/other provider embedding entry) and verify its API key","Select an embedding model interactively so the None branch isn't hit","Confirm the model is registered with ModelType::Embedding, not Chat","Run `list_models`/model listing command to verify discovery works"],"exampleFix":"// before: only a chat model configured\nmodels = [{ name = \"gpt-4o\", type = \"chat\" }]\n// after\nmodels = [\n  { name = \"gpt-4o\", type = \"chat\" },\n  { name = \"text-embedding-3-small\", type = \"embedding\", max_chunk_size = 1000 }\n]","handlingStrategy":"validation","validationCode":"let models = list_models(&config.read(), ModelType::Embedding);\nif models.is_empty() {\n    eprintln!(\"configure an embedding model before creating a RAG\");\n}","typeGuard":null,"tryCatchPattern":"match Rag::create_config(&config).await {\n    Err(e) if e.to_string() == \"No available embedding model\" => {\n        eprintln!(\"Add an embedding model (and API key) to your config\");\n    }\n    other => other?,\n}","preventionTips":["Define at least one embedding-type model in config with a valid API key","Run a model-listing command to verify discovery before RAG init","Ensure provider credentials are set so embedding models are enumerated"],"tags":["rag","embedding","config"],"backgroundTag":"missing-required-config-field","analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}