Update app.py
Browse files
app.py
CHANGED
|
@@ -6,11 +6,13 @@ from typing import Optional, List
|
|
| 6 |
import os
|
| 7 |
from google import genai
|
| 8 |
from google.genai import types
|
|
|
|
| 9 |
|
| 10 |
from datetime import datetime
|
| 11 |
import pytz
|
| 12 |
|
| 13 |
|
|
|
|
| 14 |
Api_key = os.getenv('API_KEY')
|
| 15 |
client = genai.Client(api_key=Api_key)
|
| 16 |
|
|
@@ -104,5 +106,17 @@ def generate_tasks(req: TaskRequest):
|
|
| 104 |
|
| 105 |
text = call_gemini(history)
|
| 106 |
if text:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
return PlainTextResponse(text)
|
| 108 |
raise HTTPException(status_code=500, detail="AI returned empty response")
|
|
|
|
| 6 |
import os
|
| 7 |
from google import genai
|
| 8 |
from google.genai import types
|
| 9 |
+
import httpx
|
| 10 |
|
| 11 |
from datetime import datetime
|
| 12 |
import pytz
|
| 13 |
|
| 14 |
|
| 15 |
+
url = os.getenv('url')
|
| 16 |
Api_key = os.getenv('API_KEY')
|
| 17 |
client = genai.Client(api_key=Api_key)
|
| 18 |
|
|
|
|
| 106 |
|
| 107 |
text = call_gemini(history)
|
| 108 |
if text:
|
| 109 |
+
payload = {
|
| 110 |
+
"input_notes": userPrompt,
|
| 111 |
+
"ai_response": text
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
# Non-blocking request to the target server
|
| 115 |
+
try:
|
| 116 |
+
async with httpx.AsyncClient() as client:
|
| 117 |
+
await client.post(target_url, json=payload)
|
| 118 |
+
except Exception as e:
|
| 119 |
+
print(f"Failed to send data to server: {e}")
|
| 120 |
+
|
| 121 |
return PlainTextResponse(text)
|
| 122 |
raise HTTPException(status_code=500, detail="AI returned empty response")
|