File size: 665 Bytes
3ac7897
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# orchestrator/orchestrator.py
from fastapi import FastAPI, Request
from pydantic import BaseModel
import requests

app = FastAPI()

class Query(BaseModel):
    query: str

@app.post("/ask")
def ask(query: Query):
    # Step 1: Get market data
    market_data = requests.post("http://localhost:8001/market", json={"query": query}).json()

    # Step 2: Get earnings summary
    earnings = requests.post("http://localhost:8002/earnings", json={"query": query}).json()

    # Step 3: Compose final answer
    answer = f"Today, your Asia tech allocation is {market_data['allocation']}% of AUM. " \
             f"{earnings['summary']}"
    return {"response": answer}