Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,10 @@ from pydantic import BaseModel
|
|
| 4 |
import requests
|
| 5 |
import json
|
| 6 |
from typing import AsyncIterator
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
app = FastAPI()
|
| 9 |
|
|
@@ -64,6 +68,21 @@ async def chat(request: ChatRequest):
|
|
| 64 |
print(e)
|
| 65 |
raise HTTPException(status_code=500, detail=str(e))
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
if __name__ == "__main__":
|
| 68 |
import uvicorn
|
| 69 |
uvicorn.run(app, host="0.0.0.0", port=8083)
|
|
|
|
| 4 |
import requests
|
| 5 |
import json
|
| 6 |
from typing import AsyncIterator
|
| 7 |
+
import asyncio
|
| 8 |
+
import schedule
|
| 9 |
+
import time
|
| 10 |
+
import threading
|
| 11 |
|
| 12 |
app = FastAPI()
|
| 13 |
|
|
|
|
| 68 |
print(e)
|
| 69 |
raise HTTPException(status_code=500, detail=str(e))
|
| 70 |
|
| 71 |
+
def run_schedule():
|
| 72 |
+
while True:
|
| 73 |
+
schedule.run_pending()
|
| 74 |
+
time.sleep(1)
|
| 75 |
+
|
| 76 |
+
def scheduled_function():
|
| 77 |
+
print("Done") # Placeholder for your future functionality
|
| 78 |
+
|
| 79 |
+
# Schedule the function to run every minute
|
| 80 |
+
schedule.every(1).minutes.do(scheduled_function)
|
| 81 |
+
|
| 82 |
+
# Run the scheduler in a separate thread to avoid blocking the main thread
|
| 83 |
+
thread = threading.Thread(target=run_schedule)
|
| 84 |
+
thread.start()
|
| 85 |
+
|
| 86 |
if __name__ == "__main__":
|
| 87 |
import uvicorn
|
| 88 |
uvicorn.run(app, host="0.0.0.0", port=8083)
|