SuperAPI AI Directory

rag-service

Data & analytics

View repository

Updated 10-16 00:00

About this skill

Features

RAG multi-channel retrieval service, providing:

  1. Vector semantic retrieval - Vector similarity search based on Milvus
  2. Rerank reranking - Fine-ranking of retrieval results
  3. Document storage - Save documents to the vector database

Usage

from services.rag_service.client import RAGServiceClient

client = RAGServiceClient()

# 健康检查
status = client.health()
Semantic retrieval

result = client.retrieve( query="Python asynchronous programming best practices", top_k=5, min_score=0.85, rerank=True ) print(result["results"])

Convenience method: get only the list of texts

texts = client.retrieve_texts(query="Python asynchronous programming", top_k=5)

Save documents

client.save(documents=[ {"text": "Document content...", "metadata": {"title": "Title", "url": "..."}} ])


## 返回格式

### retrieve
```json
{
  "query": "Python 异步编程",
  "results": [
    {
      "id": "abc123",
      "text": "Python异步编程基于asyncio库...",
      "score": 0.92,
      "metadata": {"title": "Python官方文档", "url": "..."}
    }
  ],
  "total": 3,
  "elapsed_ms": 45.2,
  "from_cache": false
}

save

{
  "saved_count": 5,
  "collection_name": "websearch_results"
}