Skip to content

Commit

Permalink
Merge branch 'dev/proxy-server' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
vipul-maheshwari committed Aug 7, 2024
2 parents 5d29845 + 3449352 commit 6022691
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion local_setup/quickstart_ingestion_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,50 @@ async def rag_retrive(query: str, rag_id: str, index: str) -> list:
"""
docs = await rag_factory.retrieve_query(rag_name=rag_id, index=index, query=query)
send_filter = [{"text": node.text, "score": node.score} for node in docs]
return send_filter
return send_filter

@app.post("/make-rag")
async def make_rag(
file: UploadFile = File(...),
config: str = Form(...)
) -> Dict[str, Any]:
"""
Create a RAG configuration, return its ID, and ingest the uploaded file.
Args:
file (UploadFile): The file to upload and ingest.
config (str): The RAG configuration as a JSON string.
Returns:
Dict[str, Any]: A dictionary containing the created RAG ID, upload status, and index.
"""
try:
# Parse the JSON string into a RAGConfig object
rag_config = RAGConfig.parse_raw(config)

# Create RAG configuration
rag_id = rag_factory.make_rag(rag_config)

# Ingest the file
task = await rag_factory.file_ingest(rag_name=rag_id, file=file)

return {
"rag_id": rag_id,
"index": task._index,
"status": task._status,
"message": "RAG created and file ingested successfully"
}
except json.JSONDecodeError:
return {
"rag_id": None,
"index": None,
"status": "ERROR",
"message": "Invalid JSON in config parameter"
}
except Exception as e:
return {
"rag_id": None,
"index": None,
"status": "ERROR",
"message": f"Error creating RAG or ingesting file: {str(e)}"
}

0 comments on commit 6022691

Please sign in to comment.