Spaces:
Running
Running
Sohan Kshirsagar commited on
Commit ·
5fce5c5
1
Parent(s): 409ad9f
document upload tests
Browse files
multi_llm_chatbot_backend/app/tests/test_document_upload.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
|
| 3 |
+
# Set your file path here
|
| 4 |
+
file_path = "C:/Projects/Neon AI Project/Neon-AI-Project/multi_llm_chatbot_backend/app/tests/Resume.pdf"
|
| 5 |
+
|
| 6 |
+
# Step 1: Upload the file
|
| 7 |
+
upload_url = "http://localhost:8000/upload-document"
|
| 8 |
+
with open(file_path, "rb") as file:
|
| 9 |
+
files = {"file": ("Resume.pdf", file, "application/pdf")}
|
| 10 |
+
#print("Received file type:", file.content_type)
|
| 11 |
+
upload_response = requests.post(upload_url, files=files)
|
| 12 |
+
|
| 13 |
+
print("Upload Status:", upload_response.status_code)
|
| 14 |
+
print("Upload Response:", upload_response.json())
|
| 15 |
+
|
| 16 |
+
# Step 2: Fetch context
|
| 17 |
+
context_url = "http://localhost:8000/context"
|
| 18 |
+
context_response = requests.get(context_url)
|
| 19 |
+
|
| 20 |
+
print("\nSession Context Status:", context_response.status_code)
|
| 21 |
+
print("Latest Context Snippet:")
|
| 22 |
+
for msg in context_response.json()[-3:]: # Show last 3 entries
|
| 23 |
+
print(msg)
|