Spaces:
Sleeping
Sleeping
Update orchestrator/orchestrator.py
Browse files- orchestrator/orchestrator.py +22 -0
orchestrator/orchestrator.py
CHANGED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# orchestrator/orchestrator.py
|
2 |
+
from fastapi import FastAPI, Request
|
3 |
+
from pydantic import BaseModel
|
4 |
+
import requests
|
5 |
+
|
6 |
+
app = FastAPI()
|
7 |
+
|
8 |
+
class Query(BaseModel):
|
9 |
+
query: str
|
10 |
+
|
11 |
+
@app.post("/ask")
|
12 |
+
def ask(query: Query):
|
13 |
+
# Step 1: Get market data
|
14 |
+
market_data = requests.post("http://localhost:8001/market", json={"query": query}).json()
|
15 |
+
|
16 |
+
# Step 2: Get earnings summary
|
17 |
+
earnings = requests.post("http://localhost:8002/earnings", json={"query": query}).json()
|
18 |
+
|
19 |
+
# Step 3: Compose final answer
|
20 |
+
answer = f"Today, your Asia tech allocation is {market_data['allocation']}% of AUM. " \
|
21 |
+
f"{earnings['summary']}"
|
22 |
+
return {"response": answer}
|