This commit is contained in:
ayush chaurasia
2025-04-23 18:36:46 +05:30
parent d071268058
commit 1f8950653a

View File

@@ -67,6 +67,25 @@ async def ingest_data(content: str) -> str:
```
### Retreive data tool
```python
@mcp.tool()
async def retrieve_data(query: str, limit: int = 5) -> str:
"""
Search db using vector search
Args:
query: The search query
limit: Maximum number of results to return
"""
tbl = db[TABLE_NAME]
rs = tbl.search(query).limit(limit).to_list()
data = [
r["text"] for r in rs
]
if not data:
return "No relevant data found."
return "\n\n".join(data)
```
This function takes a string and limit as input and searches the LanceDB table for the most relevant memories.