mirror of
https://github.com/katanemo/plano.git
synced 2026-04-26 01:06:25 +02:00
lint + formating with black (#158)
* lint + formating with black * add black as pre commit
This commit is contained in:
parent
498e7f9724
commit
5c4a6bc8ff
22 changed files with 581 additions and 295 deletions
|
|
@ -6,56 +6,54 @@ import logging
|
|||
from pydantic import BaseModel
|
||||
|
||||
|
||||
logger = logging.getLogger('uvicorn.error')
|
||||
logger = logging.getLogger("uvicorn.error")
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/healthz")
|
||||
async def healthz():
|
||||
return {
|
||||
"status": "ok"
|
||||
}
|
||||
return {"status": "ok"}
|
||||
|
||||
|
||||
class WeatherRequest(BaseModel):
|
||||
city: str
|
||||
days: int = 7
|
||||
units: str = "Farenheit"
|
||||
city: str
|
||||
days: int = 7
|
||||
units: str = "Farenheit"
|
||||
|
||||
|
||||
@app.post("/weather")
|
||||
async def weather(req: WeatherRequest, res: Response):
|
||||
|
||||
weather_forecast = {
|
||||
"city": req.city,
|
||||
"temperature": [],
|
||||
"units": req.units,
|
||||
}
|
||||
for i in range(7):
|
||||
min_temp = random.randrange(50,90)
|
||||
max_temp = random.randrange(min_temp+5, min_temp+20)
|
||||
if req.units.lower() == "celsius" or req.units.lower() == "c":
|
||||
min_temp = (min_temp - 32) * 5.0/9.0
|
||||
max_temp = (max_temp - 32) * 5.0/9.0
|
||||
weather_forecast["temperature"].append({
|
||||
"date": str(date.today() + timedelta(days=i)),
|
||||
"temperature": {
|
||||
"min": min_temp,
|
||||
"max": max_temp
|
||||
},
|
||||
"units": req.units,
|
||||
"query_time": str(datetime.now(timezone.utc))
|
||||
})
|
||||
min_temp = random.randrange(50, 90)
|
||||
max_temp = random.randrange(min_temp + 5, min_temp + 20)
|
||||
if req.units.lower() == "celsius" or req.units.lower() == "c":
|
||||
min_temp = (min_temp - 32) * 5.0 / 9.0
|
||||
max_temp = (max_temp - 32) * 5.0 / 9.0
|
||||
weather_forecast["temperature"].append(
|
||||
{
|
||||
"date": str(date.today() + timedelta(days=i)),
|
||||
"temperature": {"min": min_temp, "max": max_temp},
|
||||
"units": req.units,
|
||||
"query_time": str(datetime.now(timezone.utc)),
|
||||
}
|
||||
)
|
||||
|
||||
return weather_forecast
|
||||
|
||||
|
||||
class InsuranceClaimDetailsRequest(BaseModel):
|
||||
policy_number: str
|
||||
policy_number: str
|
||||
|
||||
|
||||
@app.post("/insurance_claim_details")
|
||||
async def insurance_claim_details(req: InsuranceClaimDetailsRequest, res: Response):
|
||||
|
||||
claim_details = {
|
||||
"policy_number": req.policy_number,
|
||||
"claim_status": "Approved",
|
||||
|
|
@ -68,26 +66,25 @@ async def insurance_claim_details(req: InsuranceClaimDetailsRequest, res: Respon
|
|||
|
||||
|
||||
class DefaultTargetRequest(BaseModel):
|
||||
arch_messages: list
|
||||
arch_messages: list
|
||||
|
||||
|
||||
@app.post("/default_target")
|
||||
async def default_target(req: DefaultTargetRequest, res: Response):
|
||||
logger.info(f"Received arch_messages: {req.arch_messages}")
|
||||
resp = {
|
||||
"choices": [
|
||||
{
|
||||
"choices": [
|
||||
{
|
||||
"message": {
|
||||
"role": "assistant",
|
||||
"content": "hello world from api server"
|
||||
"role": "assistant",
|
||||
"content": "hello world from api server",
|
||||
},
|
||||
"finish_reason": "completed",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"model": "api_server",
|
||||
"usage": {
|
||||
"completion_tokens": 0
|
||||
"index": 0,
|
||||
}
|
||||
}
|
||||
],
|
||||
"model": "api_server",
|
||||
"usage": {"completion_tokens": 0},
|
||||
}
|
||||
logger.info(f"sending response: {json.dumps(resp)}")
|
||||
return resp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue