Spaces:
Build error
Build error
Commit
·
2eb3e22
1
Parent(s):
b0f8541
test MarkitDown
Browse files- app/main.py +14 -0
- document_logs_2024-12-20.txt +1 -0
- document_logs_2024-12-21.txt +0 -0
app/main.py
CHANGED
|
@@ -26,6 +26,8 @@ from app.api.api_prompt import prompt_router
|
|
| 26 |
from app.api.api_file import file_router
|
| 27 |
from app.utils.load_env import ACCESS_TOKEN, WHATSAPP_API_URL, GEMINI_API
|
| 28 |
|
|
|
|
|
|
|
| 29 |
# Configure logging
|
| 30 |
logging.basicConfig(
|
| 31 |
level=logging.INFO,
|
|
@@ -149,6 +151,18 @@ async def webhook(request: Request):
|
|
| 149 |
|
| 150 |
app.get("/webhook")(verify_webhook)
|
| 151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
# Add a route for Prometheus metrics (optional, if not using a separate Prometheus server)
|
| 153 |
@app.get("/metrics")
|
| 154 |
async def metrics():
|
|
|
|
| 26 |
from app.api.api_file import file_router
|
| 27 |
from app.utils.load_env import ACCESS_TOKEN, WHATSAPP_API_URL, GEMINI_API
|
| 28 |
|
| 29 |
+
from markitdown import MarkItDown
|
| 30 |
+
|
| 31 |
# Configure logging
|
| 32 |
logging.basicConfig(
|
| 33 |
level=logging.INFO,
|
|
|
|
| 151 |
|
| 152 |
app.get("/webhook")(verify_webhook)
|
| 153 |
|
| 154 |
+
@app.post("/load_file")
|
| 155 |
+
async def load_file_with_markitdown(file_path:str, llm_client:str=None, model:str=None):
|
| 156 |
+
|
| 157 |
+
if llm_client and model:
|
| 158 |
+
markitdown = MarkItDown(llm_client, model)
|
| 159 |
+
documents = markitdown.convert(file_path)
|
| 160 |
+
else:
|
| 161 |
+
markitdown = MarkItDown()
|
| 162 |
+
documents = markitdown.convert(file_path)
|
| 163 |
+
|
| 164 |
+
print(f"documents: {documents}")
|
| 165 |
+
return documents
|
| 166 |
# Add a route for Prometheus metrics (optional, if not using a separate Prometheus server)
|
| 167 |
@app.get("/metrics")
|
| 168 |
async def metrics():
|
document_logs_2024-12-20.txt
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
2024-12-20 12:49:01,713 - INFO - ID: ea205193-4582-44bc-ab71-80176aac7aef, Snippet: [SSW](https://sswalfa.surabaya.go.id/home) [ [ [![](https://sswalfa.surabaya.go.id/assets/images/logo-
|
document_logs_2024-12-21.txt
ADDED
|
File without changes
|