mirror of
https://github.com/katanemo/plano.git
synced 2026-04-26 17:26:26 +02:00
add support for default target (#111)
* add support for default target * add more fixes
This commit is contained in:
parent
c8d0dbec26
commit
1b57a49c9d
8 changed files with 215 additions and 88 deletions
|
|
@ -16,4 +16,4 @@ COPY --from=builder /runtime /usr/local
|
|||
COPY /app /app
|
||||
WORKDIR /app
|
||||
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80", "--log-level", "info"]
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import json
|
||||
import random
|
||||
from fastapi import FastAPI, Response
|
||||
from datetime import datetime, date, timedelta, timezone
|
||||
import logging
|
||||
from pydantic import BaseModel
|
||||
import pytz
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger = logging.getLogger('uvicorn.error')
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
|
@ -58,18 +59,28 @@ async def insurance_claim_details(req: InsuranceClaimDetailsRequest, res: Respon
|
|||
|
||||
return claim_details
|
||||
|
||||
@app.get("/current_time")
|
||||
async def current_time(timezone: str):
|
||||
tz = None
|
||||
try:
|
||||
timezone.strip('"')
|
||||
tz = pytz.timezone(timezone)
|
||||
except pytz.exceptions.UnknownTimeZoneError:
|
||||
return {
|
||||
"error": "Invalid timezone: {}".format(timezone)
|
||||
}
|
||||
current_time = datetime.now(tz)
|
||||
return {
|
||||
"timezone": timezone,
|
||||
"current_time": current_time.strftime("%Y-%m-%d %H:%M:%S %Z")
|
||||
}
|
||||
|
||||
class DefaultTargetRequest(BaseModel):
|
||||
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": [
|
||||
{
|
||||
"message": {
|
||||
"role": "assistant",
|
||||
"content": "hello world from api server"
|
||||
},
|
||||
"finish_reason": "completed",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"model": "api_server",
|
||||
"usage": {
|
||||
"completion_tokens": 0
|
||||
}
|
||||
}
|
||||
logger.info(f"sending response: {json.dumps(resp)}")
|
||||
return resp
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
fastapi
|
||||
uvicorn
|
||||
pytz
|
||||
pyyaml
|
||||
|
|
|
|||
|
|
@ -47,21 +47,6 @@ prompt_targets:
|
|||
- Use farenheight for temperature
|
||||
- Use miles per hour for wind speed
|
||||
|
||||
- name: system_time
|
||||
description: This function provides the current system time.
|
||||
parameters:
|
||||
- name: timezone
|
||||
description: The city for which the weather forecast is requested.
|
||||
default: US/Pacific
|
||||
type: string
|
||||
endpoint:
|
||||
name: api_server
|
||||
path: /current_time
|
||||
system_prompt: |
|
||||
You are a helpful system time provider. Use system time data that is provided to you. Please following following guidelines when responding to user queries:
|
||||
- Use 12 hour time format
|
||||
- Use AM/PM for time
|
||||
|
||||
- name: insurance_claim_details
|
||||
description: This function resolver provides insurance claim details for a given policy number.
|
||||
parameters:
|
||||
|
|
@ -80,6 +65,18 @@ prompt_targets:
|
|||
You are a helpful insurance claim details provider. Use insurance claim data that is provided to you. Please following following guidelines when responding to user queries:
|
||||
- Use policy number to retrieve insurance claim details
|
||||
|
||||
- name: default_target
|
||||
default: true
|
||||
description: This is the default target for all unmatched prompts.
|
||||
endpoint:
|
||||
name: api_server
|
||||
path: /default_target
|
||||
system_prompt: |
|
||||
You are a helpful assistant. Use the information that is provided to you.
|
||||
# if it is set to false arch will send response that it received from this prompt target to the user
|
||||
# if true arch will forward the response to the default LLM
|
||||
auto_llm_dispatch_on_response: true
|
||||
|
||||
ratelimits:
|
||||
- provider: gpt-3.5-turbo
|
||||
selector:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue