Skip to content

Commit 24dc637

Browse files
authored
Update README.md
Signed-off-by: Ali Amer <76897266+aliamerj@users.noreply.github.com>
1 parent 4d44433 commit 24dc637

1 file changed

Lines changed: 84 additions & 1 deletion

File tree

README.md

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,90 @@ Next, Dcup automatically chunks and embeds your data into vectors using OpenAI e
4040
### 3️⃣ Retrieve
4141

4242
The final step is to use the Dcup Retrieval API to get relevant chunks for your semantic search queries. Built-in features like re-ranking, summary index, entity extraction, flexible filtering, and hybrid semantic and keyword search ensure highly accurate and relevant results for your AI applications.
43-
43+
#### Retrieval API Documentation
44+
##### Endpoint
45+
```bash
46+
POST /api/retrievals
47+
```
48+
#### Description
49+
This API endpoint allows you to retrieve relevant chunks from your indexed documents based on a search query. The process involves expanding your query, generating embeddings, and using Qdrant to search for matching chunks. Optionally, the results can be re-ranked using cosine similarity.
50+
51+
##### Request Body Parameters
52+
- **query (string, required)**: The search query. Must be at least 2 characters long.
53+
- **top_chunk (number, optional)**: The number of top results to return. Default is 5.
54+
- **filter (object, optional)**: A filter object to narrow down results.
55+
- **rerank (boolean, optional)**: Set to true to enable re-ranking of results based on similarity. Defaults to false.
56+
- **min_score_threshold (number, optional)**: Minimum score threshold for filtering results.
57+
#### Example Request
58+
```json
59+
{
60+
"query": "example search query",
61+
"top_chunk": 5,
62+
"filter": {
63+
"field": "value"
64+
},
65+
"rerank": true,
66+
"min_score_threshold": 0.5
67+
}
68+
```
69+
#### Note:
70+
Include an Authorization header with your API key in the format:
71+
Authorization: Bearer YOUR_API_KEY
72+
73+
#### How It Works
74+
- Query Expansion & Embedding:
75+
The API expands your query and generates embeddings using OpenAI.
76+
- Search & Filter:
77+
Qdrant searches the indexed vectors. You can use a filter to refine the search.
78+
- Re-ranking (Optional):
79+
If enabled, the API generates a hypothetical answer, calculates its embedding, and re-ranks the chunks by cosine similarity.
80+
- Response:
81+
The API returns the top matching chunks, each containing metadata like document name, page number, content, and score.
82+
83+
#### Response Format
84+
A successful response returns a JSON object with a key scored_chunks that contains an array of matching chunks. Each chunk includes:
85+
86+
- id: Identifier of the chunk.
87+
- document_name: Name of the source document.
88+
- page_number: Page number (if applicable).
89+
- chunk_number: Chunk identifier.
90+
- source: Data source.
91+
- title: Title of the document/chunk.
92+
- summary: Summary (if available).
93+
- content: The chunk's content.
94+
- type: The type/category of the chunk.
95+
- metadata: Additional metadata.
96+
- score: Matching score.
97+
#### Example Response
98+
```json
99+
{
100+
"scored_chunks": [
101+
{
102+
"id": "chunk_1",
103+
"document_name": "Document A",
104+
"page_number": 1,
105+
"chunk_number": 2,
106+
"source": "Google Drive",
107+
"title": "Introduction",
108+
"summary": "Overview of the topic",
109+
"content": "Lorem ipsum dolor sit amet...",
110+
"type": "text",
111+
"metadata": {},
112+
"score": 0.87
113+
}
114+
// ...more chunks
115+
]
116+
}
117+
```
118+
#### Error Handling
119+
- 400 Bad Request:
120+
If the request body fails validation, you'll receive details about the validation errors.
121+
- 401 Unauthorized:
122+
If the Authorization header is missing or invalid.
123+
- 403 Forbidden:
124+
If the API key is not associated with a valid user.
125+
- 500 Internal Server Error:
126+
If an unexpected error occurs.
44127

45128
### 🌟 Key Features
46129

0 commit comments

Comments
 (0)