{"record":{"id":"9c626562d8e0c379","repo":"infiniflow/ragflow","slug":"cannot-search-across-datasets-where-some-have-embe","errorCode":null,"errorMessage":"Cannot search across datasets where some have embedding models and others do not.","messagePattern":"Cannot search across datasets where some have embedding models and others do not\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"api/db/services/dialog_service.py","lineNumber":359,"sourceCode":"                yield {\"answer\": \"\", \"reference\": {}, \"audio_binary\": None, \"prompt\": \"\", \"created_at\": time.time(), \"final\": False, **flags}\n                continue\n            yield {\"answer\": value, \"reference\": {}, \"audio_binary\": tts(tts_mdl, value), \"prompt\": \"\", \"created_at\": time.time(), \"final\": False}\n    else:\n        if model_config[\"model_type\"] == \"chat\":\n            answer = await chat_mdl.async_chat(system_prompt, msg, dialog.llm_setting)\n        else:\n            answer = await chat_mdl.async_chat(system_prompt, msg, dialog.llm_setting, images=image_files)\n        user_content = msg[-1].get(\"content\", \"[content not available]\")\n        logging.debug(\"User: {}|Assistant: {}\".format(user_content, answer))\n        yield {\"answer\": answer, \"reference\": {}, \"audio_binary\": tts(tts_mdl, answer), \"prompt\": \"\", \"created_at\": time.time()}\n\n\ndef get_models(dialog, trace_context=None, langfuse_session_id=None):\n    embd_mdl, chat_mdl, rerank_mdl, tts_mdl = None, None, None, None\n    kbs = KnowledgebaseService.get_by_ids(dialog.kb_ids)\n    err = validate_dataset_embedding_models(kbs)\n    if err:\n        raise Exception(err)\n\n    if kbs and kbs[0].embd_id:\n        embd_owner_tenant_id = kbs[0].tenant_id\n        embd_model_config = resolve_model_config(embd_owner_tenant_id, LLMType.EMBEDDING, kbs[0].embd_id)\n        embd_mdl = LLMBundle(embd_owner_tenant_id, embd_model_config, trace_context=trace_context, langfuse_session_id=langfuse_session_id)\n        if not embd_mdl:\n            raise LookupError(\"Embedding model(%s) not found\" % kbs[0].embd_id)\n\n    if dialog.llm_id:\n        if dialog.tenant_llm_id:\n            try:\n                chat_model_config = get_model_config_by_id(dialog.tenant_id, LLMType.CHAT, dialog.tenant_llm_id)\n            except LookupError:\n                chat_model_config = resolve_model_config(dialog.tenant_id, LLMType.CHAT, dialog.llm_id)\n        else:\n            chat_model_config = resolve_model_config(dialog.tenant_id, LLMType.CHAT, dialog.llm_id)\n    else:\n        chat_model_config = get_tenant_default_model_by_type(dialog.tenant_id, LLMType.CHAT)","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/db/services/dialog_service.py#L341-L377","documentation":"Raised (as a generic Exception) from get_models in dialog_service when validate_dataset_embedding_models returns an error: the dialog references multiple datasets (kb_ids) where some have an embedding model configured and others have none. Mixed embedding state cannot be searched together, so model resolution aborts before building the embedding LLMBundle.","triggerScenarios":"Chat/ask request (or any flow calling get_models) against a dialog whose kb_ids includes at least one dataset with embd_id set and at least one with empty embd_id.","commonSituations":"Attaching a newly created dataset that never had an embedding model selected to an existing dialog with embedded datasets; a dataset whose embedding model was cleared; migrating dialogs that accumulated datasets over time.","solutions":["Set an embedding model on the un-embedded dataset(s) — it must match the others (see error 448).","Remove the un-embedded dataset from the dialog's kb_ids.","Re-create the empty dataset selecting the same embedding model as the dialog's other datasets, then swap it in."],"exampleFix":"# before\ndialog.kb_ids = [kb_with_embd.id, kb_without_embd.id]\n# after: give every dataset the same embedding model\nkb_without_embd.embd_id = kb_with_embd.embd_id\nkb_without_embd.save()","handlingStrategy":"validation","validationCode":"from api.db.services.knowledgebase_service import KnowledgebaseService, validate_dataset_embedding_models\n\nkbs = KnowledgebaseService.get_by_ids(dialog['kb_ids'])\nerr = validate_dataset_embedding_models(kbs)\nif err:\n    # fix datasets before opening the chat session\n    raise ValueError(err)","typeGuard":null,"tryCatchPattern":"try:\n    models = get_models(dialog)\nexcept Exception as e:\n    if 'embedding models' in str(e):\n        show_dataset_config_error(dialog.kb_ids)  # guide user to dataset settings\n    else:\n        raise","preventionTips":["Require an embedding model at dataset creation; disallow empty embd_id.","When editing a dialog's datasets, re-run validate_dataset_embedding_models on every change."],"tags":["validation","embedding-model","dialog","knowledge-base"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}