Haste171 / llamaindex-retrieval-api

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

Add an HTTPException for when the engine fails in query.py #34

Open Haste171 opened 5 months ago

Haste171 commented 5 months ago

Add an HTTPException for when the engine fails in query.py

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.

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Relevant Code Snippets Found https://github.com/Haste171/llamaindex-retrieval-api/blob/9cd5c37e745e52e3b1eba66d885992d34be0be64/routers/loaders/pdf.py#L0-L24 https://github.com/Haste171/llamaindex-retrieval-api/blob/9cd5c37e745e52e3b1eba66d885992d34be0be64/.gitignore#L0-L15 https://github.com/Haste171/llamaindex-retrieval-api/blob/9cd5c37e745e52e3b1eba66d885992d34be0be64/.gitignore#L15-L30 https://github.com/Haste171/llamaindex-retrieval-api/blob/9cd5c37e745e52e3b1eba66d885992d34be0be64/.gitignore#L30-L45 https://github.com/Haste171/llamaindex-retrieval-api/blob/9cd5c37e745e52e3b1eba66d885992d34be0be64/.gitignore#L45-L60

I have created the following workflow as a basis for the discussion and coding will be derived.

Steps

Step 1

Import HTTPException

More Info Action: modify File: `routers/retrievers/query.py` Start Line: `1` End Line: 1 **Instructions:** *At the top of the file, import HTTPException from fastapi. The import statement should look like this: 'from fastapi import HTTPException'.* Dependencies: []
### Step 2 #### Add HTTPException
More Info Action: modify File: `routers/retrievers/query.py` Start Line: `10` End Line: 20 **Instructions:** *Identify the function where the engine is called. In the try block where the engine is invoked, add an except block to catch any exceptions that may occur. In the except block, raise an HTTPException with a status code of 500 and a detail message indicating that the engine has failed. The code should look like this: 'except Exception: raise HTTPException(status_code=500, detail="Engine has failed.")'.* Dependencies: ['Step 1']
### Step 3 #### Test the exception handling
More Info Action: create File: `tests/test_query.py` Start Line: `1` End Line: 20 **Instructions:** *Create a new test file to test the exception handling. In this file, write a test function that invokes the function from query.py with parameters that will cause the engine to fail. Assert that the HTTPException is raised with a status code of 500 and the correct detail message. The test function should look like this: 'def test_engine_failure(): with pytest.raises(HTTPException) as exc_info: function_to_test() assert exc_info.value.status_code == 500 assert exc_info.value.detail == "Engine has failed."'.* Dependencies: ['Step 2']
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. The import statement should look like this: 'from fastapi import HTTPException'.", "async_score": 2, "assigned_agent": "AI or User", "dependencies": []}, {"step": "Step 2", "name": "Add HTTPException", "action": "modify", "file": "routers/retrievers/query.py", "start_line": 10, "end_line": 20, "instructions": "Identify the function where the engine is called. In the try block where the engine is invoked, add an except block to catch any exceptions that may occur. In the except block, raise an HTTPException with a status code of 500 and a detail message indicating that the engine has failed. The code should look like this: 'except Exception: raise HTTPException(status_code=500, detail=\"Engine has failed.\")'.", "async_score": 8, "assigned_agent": "AI or User", "dependencies": ["Step 1"]}, {"step": "Step 3", "name": "Test the exception handling", "action": "create", "file": "tests/test_query.py", "start_line": 1, "end_line": 20, "instructions": "Create a new test file to test the exception handling. In this file, write a test function that invokes the function from query.py with parameters that will cause the engine to fail. Assert that the HTTPException is raised with a status code of 500 and the correct detail message. The test function should look like this: 'def test_engine_failure(): with pytest.raises(HTTPException) as exc_info: function_to_test() assert exc_info.value.status_code == 500 assert exc_info.value.detail == \"Engine has failed.\"'.", "async_score": 10, "assigned_agent": "AI or 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. The import statement should look like this: 'from fastapi import HTTPException'.
    Async Score: 2
    Assigned Agent: AI or User
    Dependencies: []
Step 2: Add HTTPException
    Action: modify
    File: routers/retrievers/query.py
    Start Line: 10
    End Line: 20
    Instructions: Identify the function where the engine is called. In the try block where the engine is invoked, add an except block to catch any exceptions that may occur. In the except block, raise an HTTPException with a status code of 500 and a detail message indicating that the engine has failed. The code should look like this: 'except Exception: raise HTTPException(status_code=500, detail="Engine has failed.")'.
    Async Score: 8
    Assigned Agent: AI or User
    Dependencies: ['Step 1']
Step 3: Test the exception handling
    Action: create
    File: tests/test_query.py
    Start Line: 1
    End Line: 20
    Instructions: Create a new test file to test the exception handling. In this file, write a test function that invokes the function from query.py with parameters that will cause the engine to fail. Assert that the HTTPException is raised with a status code of 500 and the correct detail message. The test function should look like this: 'def test_engine_failure(): with pytest.raises(HTTPException) as exc_info: function_to_test() assert exc_info.value.status_code == 500 assert exc_info.value.detail == "Engine has failed."'.
    Async Score: 10
    Assigned Agent: AI or User
    Dependencies: ['Step 2']