Implementation:Infiniflow Ragflow Async Ask
Appearance
| Knowledge Sources | |
|---|---|
| Domains | RAG, Search |
| Last Updated | 2026-02-12 06:00 GMT |
Overview
Concrete tool for executing search queries with SSE-streamed AI answers and related features provided by RAGFlow's conversation endpoints.
Description
The POST /conversation/ask endpoint streams AI-synthesized search answers via SSE using async_ask. Companion endpoints POST /conversation/mindmap and POST /conversation/related_questions provide structured knowledge visualization and follow-up suggestions.
Usage
Called by the search application frontend via the useSendQuestion hook.
Code Reference
Source Location
- Repository: ragflow
- File: api/apps/conversation_app.py (L394-423 ask, L426-441 mindmap, L444-478 related_questions)
Signature
@manager.route("/ask", methods=["POST"])
@login_required
@validate_request("question", "kb_ids")
async def ask_about():
"""Search with SSE-streamed AI answer.
Body: {question: str, kb_ids: list[str], search_id?: str}
SSE: data:{code:0, data:{answer, reference}}
"""
@manager.route("/mindmap", methods=["POST"])
@login_required
@validate_request("question", "kb_ids")
async def mindmap():
"""Generate mind map from search results.
Body: {question: str, kb_ids: list[str], search_id?: str}
Returns: Mind map dict.
"""
@manager.route("/related_questions", methods=["POST"])
@login_required
@validate_request("question")
async def related_questions():
"""Generate related search questions.
Body: {question: str, search_id?: str}
Returns: list[str] of suggested questions.
"""
Import
from api.db.services.dialog_service import async_ask, gen_mindmap
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| question | str | Yes | Search query |
| kb_ids | list[str] | Yes | Knowledge base IDs |
| search_id | str | No | Search app ID (loads search_config) |
Outputs
| Name | Type | Description |
|---|---|---|
| SSE stream | text/event-stream | data:{code:0, data:{answer, reference}} chunks |
| mindmap | dict | Structured mind map |
| related_questions | list[str] | Suggested follow-up queries |
Usage Examples
import requests
# Search with SSE streaming
url = "http://localhost:9380/conversation/ask"
payload = {"question": "What is RAGFlow?", "kb_ids": ["kb-uuid-1"]}
with requests.post(url, json=payload, headers=headers, stream=True) as r:
for line in r.iter_lines():
if line.startswith(b"data:"):
print(line.decode())
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment