- Supports local file upload (txt/md/pdf/docx, etc.), with automatic parsing of text and images
- Supports image extraction, VLM image-text understanding, and description vectorization ingestion
- Supports single-file deletion and full-database clearing
- Supports querying the list of uploaded files
- Supports querying the text/image fragment content after file parsing
- Supports hybrid recall of semantic vector retrieval + BM25 full-text search
- Supports configuration of similarity threshold and number of returned results
Before using this SKILL, ensure that the RAG server'sRAG_SERVER_ADDRESSenvironment variables
RAG_SERVER_ADDRESS: RAG knowledge management service FastAPI service URL, for example:http://127.0.0.1:8000
The example.py file in the current skill directory describes sample client request code for each interface of the RAG service
Introduction to the input and output parameters of each method of the RAGClient classquery
- server interface: /query
- request method: POST
- description: Retrieve knowledge information from the knowledge base based on the user's question and summarize the final answer
- Input: query: str (user question) top_k: int = 3 (number of returned results) score_threshold: float = 0.5 (similarity threshold)
- Output: str
retrieve_similar_docs
- server interface: /retrieval
- request method: POST
- description: Retrieve and recall the top_k semantically most similar knowledge fragments from the knowledge base based on the user's question
- Input: query: str (user question) top_k: int = 3 (number of returned results) score_threshold: float = 0.5 (similarity threshold)
- Output: List[Dict](content, score, metadata)
upload_file
- server interface: /upload_file
- request method: POST
- description: Upload a document to the RAG knowledge base
- Input: file_path: str (local file path)
- Output: Dict (upload result, status information)
- Exception: FileNotFoundError, HTTPError
delete_file
- server interface: /delete_file
- request method: POST
- description: Delete the specified file name
- Input: file_name: str (file name in the knowledge base) confirm: bool = False (confirm deletion)
- Output: Dict (deletion result)
delete_all_files
- server interface: /delete_all_files
- request method: DELETE
- description: Delete all files in the RAG knowledge base
- Input: confirm: bool = False (confirm deletion)
- Output: Dict (clearing result)
list_files
- server interface: /list_files
- request method: GET
- description: View all file names in the RAG knowledge base
- Input: None
- Output: List[str] (list of file names)
query_file_content
- server interface: /query_file_content
- request method: POST
- description: View the content of the specified file name in the RAG knowledge base
- Input: file_name: str
- Output: List[Dict[str, Any] (text fragments + metadata)
from example import RAGClient
client = RAGClient(base_url="http://127.0.0.1:9098")
# 上传文件
await client.upload_file("/path/test.pdf")
# 检索知识
docs = await client.retrieval("什么是RAG?")
# 查询文件列表
files = await client.list_files()
# 删除文件
await client.delete_file("test.pdf", confirm=True)