Haste171 / llamaindex-retrieval-api

API to load and query documents using RAG
MIT License
15 stars 3 forks source link

Add an HTTPException to the query endpoint to handle engine failure #22 #24 #25

Open Haste171 opened 5 months ago

Haste171 commented 5 months ago

Add an HTTPException to the query endpoint to handle engine failure #22 #24

Haste171 commented 5 months ago
Sweeping
    <br/>
    <div align='center'><img src='https://progress-bar.dev/40/?width=600' alt='40%'/></div>
    <br/><div align="center">🔎 Searching

I'm searching for relevant snippets in your repository.

Code Snippets Found https://github.com/Haste171/llamaindex-retrieval-api/blob/9cd5c37e745e52e3b1eba66d885992d34be0be64/routers/loaders/pdf.py#L0-L22
Haste171 commented 5 months ago

{"tag": "INITIAL_PLANNING", "workflow": {"tasks": [{"step": "Step 1", "name": "Import HTTPException", "action": "modify", "file": "routers/retrievers/query.py", "start_line": 1, "end_line": 1, "instructions": "At the top of the file, import HTTPException from fastapi.exceptions by adding the line 'from fastapi.exceptions import HTTPException'.", "async_score": 2, "assigned_agent": "AI", "dependencies": []}, {"step": "Step 2", "name": "Add HTTPException to query endpoint", "action": "modify", "file": "routers/retrievers/query.py", "start_line": 10, "end_line": 20, "instructions": "In the function that handles the query endpoint, add a try-except block around the code that interacts with the engine. In the except block, raise an HTTPException with status code 500 and a detail message indicating an engine failure. For example, 'except EngineFailure: raise HTTPException(status_code=500, detail='Engine failure')'.", "async_score": 8, "assigned_agent": "AI", "dependencies": ["Step 1"]}, {"step": "Step 3", "name": "Test HTTPException", "action": "create", "file": "tests/test_query.py", "start_line": 1, "end_line": 50, "instructions": "Create a new test file 'tests/test_query.py'. In this file, write tests to ensure that the HTTPException is raised correctly when the engine fails. This will involve creating a mock engine that raises an EngineFailure, and then making a request to the query endpoint and checking that the response has a status code of 500 and the correct detail message.", "async_score": 10, "assigned_agent": "User", "dependencies": ["Step 2"]}], "snippets": []}}

Step 1: Import HTTPException
    Action: modify
    File: routers/retrievers/query.py
    Start Line: 1
    End Line: 1
    Instructions: At the top of the file, import HTTPException from fastapi.exceptions by adding the line 'from fastapi.exceptions import HTTPException'.
    Async Score: 2
    Assigned Agent: AI
    Dependencies: []
Step 2: Add HTTPException to query endpoint
    Action: modify
    File: routers/retrievers/query.py
    Start Line: 10
    End Line: 20
    Instructions: In the function that handles the query endpoint, add a try-except block around the code that interacts with the engine. In the except block, raise an HTTPException with status code 500 and a detail message indicating an engine failure. For example, 'except EngineFailure: raise HTTPException(status_code=500, detail='Engine failure')'.
    Async Score: 8
    Assigned Agent: AI
    Dependencies: ['Step 1']
Step 3: Test HTTPException
    Action: create
    File: tests/test_query.py
    Start Line: 1
    End Line: 50
    Instructions: Create a new test file 'tests/test_query.py'. In this file, write tests to ensure that the HTTPException is raised correctly when the engine fails. This will involve creating a mock engine that raises an EngineFailure, and then making a request to the query endpoint and checking that the response has a status code of 500 and the correct detail message.
    Async Score: 10
    Assigned Agent: User
    Dependencies: ['Step 2']