forked from ScottLogic/InferLLM
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
72 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
from typing import TypedDict | ||
from fastapi import UploadFile | ||
|
||
from src.utils.scratchpad import clear_scratchpad, update_scratchpad | ||
from src.utils.file_utils import handle_file_upload | ||
|
||
class FileUploadReport(TypedDict): | ||
id: str | ||
filename: str | None | ||
report: str | None | ||
|
||
async def report_on_file_upload(upload:UploadFile) -> FileUploadReport: | ||
|
||
file = handle_file_upload(upload) | ||
|
||
update_scratchpad(result=file["content"]) | ||
|
||
report = "#Report on upload as markdown" # await report_agent.invoke(file["content"]) | ||
|
||
clear_scratchpad() | ||
|
||
return {"filename": file["filename"], "id": file["uploadId"], "report": report} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from io import BytesIO | ||
from fastapi import UploadFile | ||
from fastapi.datastructures import Headers | ||
import pytest | ||
|
||
from src.session.file_uploads import FileUpload | ||
from src.directors.report_director import report_on_file_upload | ||
|
||
@pytest.mark.asyncio | ||
async def test_report_on_file_upload(mocker): | ||
|
||
file_upload = FileUpload(uploadId="1", filename="test.txt", content="test", contentType="text/plain", size=4) | ||
|
||
mock_handle_file_upload = mocker.patch("src.directors.report_director.handle_file_upload", return_value=file_upload) | ||
|
||
headers = Headers({"content-type": "text/plain"}) | ||
file = BytesIO(b"test content") | ||
request_upload_file = UploadFile(file=file, size=12, headers=headers, filename="test.txt") | ||
response = await report_on_file_upload(request_upload_file) | ||
|
||
mock_handle_file_upload.assert_called_once_with(request_upload_file) | ||
assert response == {"filename": "test.txt", "id": "1", "report": "#Report on upload as markdown"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters