Implementation:Infiniflow Ragflow DialogService Save
Appearance
| Knowledge Sources | |
|---|---|
| Domains | RAG, Conversational_AI |
| Last Updated | 2026-02-12 06:00 GMT |
Overview
Concrete tool for creating chat application (Dialog) records provided by RAGFlow DialogService.
Description
DialogService.save creates a new Dialog record via the inherited CommonService.save method. The POST /v1/dialog/set endpoint validates inputs (prompt_config presence, KB existence, LLM model availability), sets defaults for LLM settings and retrieval parameters, then persists the Dialog.
Usage
Called via the REST API to create or update a chat application configuration.
Code Reference
Source Location
- Repository: ragflow
- File: api/db/services/dialog_service.py (save: L54-67), api/apps/dialog_app.py (endpoint: L34-144)
Signature
class DialogService(CommonService):
model = Dialog
@classmethod
def save(cls, **kwargs) -> Dialog:
"""Create a new Dialog record.
Key kwargs:
name: str - Dialog name.
tenant_id: str - Owner tenant ID.
kb_ids: list[str] - Linked knowledge base IDs.
llm_id: str - LLM model ID.
llm_setting: dict - {temperature, top_p, frequency_penalty,
presence_penalty, max_tokens}.
prompt_config: dict - {system, prologue, parameters, empty_response}.
similarity_threshold: float - Default 0.2.
vector_similarity_weight: float - Default 0.3.
top_n: int - Default 6.
top_k: int - Default 1024.
Returns:
Dialog model instance.
"""
Import
from api.db.services.dialog_service import DialogService
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| name | str | Yes | Chat application name |
| tenant_id | str | Yes | Owner tenant ID |
| kb_ids | list[str] | Yes | Knowledge base IDs to link |
| llm_id | str | No | LLM model (defaults to tenant default) |
| llm_setting | dict | No | Generation parameters |
| prompt_config | dict | Yes | System prompt and configuration |
| similarity_threshold | float | No | Default 0.2 |
| vector_similarity_weight | float | No | Default 0.3 |
Outputs
| Name | Type | Description |
|---|---|---|
| dialog | Dialog | Created Dialog model instance with generated ID |
Usage Examples
import requests
url = "http://localhost:9380/v1/dialog/set"
payload = {
"name": "Customer Support Bot",
"kb_ids": ["kb-uuid-1"],
"llm_id": "gpt-4-turbo",
"llm_setting": {"temperature": 0.1, "max_tokens": 512},
"prompt_config": {
"system": "You are a helpful customer support assistant.",
"prologue": "Hello! How can I help you today?",
"empty_response": "I couldn't find relevant information."
}
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, json=payload, headers=headers)
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment