paulo_34072
01/24/2025, 8:40 PMAI Evy
01/24/2025, 8:40 PMAI Evy
01/24/2025, 8:40 PMAI Evy
01/24/2025, 8:40 PMjavascript
{
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "The city of the weather"
}
},
"required": [
"city"
]
}
2. Al recibir la llamada, necesitas acceder a los argumentos a través de args en el cuerpo de la solicitud [(3)]() .
3. Para Python, puedes manejar los argumentos así [(2)]() :
python
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from retell import Retell
retell = Retell(api_key=os.environ["RETELL_API_KEY"])
@app.post("/check-weather")
async def check-weather(request: Request):
try:
post_data = await request.json()
args = post_data["args"]
if args["city"] == "New York":
return JSONResponse(status_code=200, content={"result": "25f and sunny"})
Un error común es no agregar "type": "object" en el nivel superior del esquema JSON [(1)]() [(2)]() .AI Evy
01/24/2025, 8:40 PMpaulo_34072
01/24/2025, 8:51 PMAI Evy
01/24/2025, 8:51 PMAI Evy
01/24/2025, 8:52 PMjavascript
this.app.post("/check-weather", async (req: Request, res: Response) => {
const content = req.body;
console.log(content.args); // Verifica los argumentos aquí
[(1)]()
2. Para Python:
python
@app.post("/check-weather")
async def check-weather(request: Request):
try:
post_data = await request.json()
args = post_data["args"] # Los argumentos estarán aquí
3. En el prompt del LLM, necesitas instruir explícitamente al agente sobre cómo usar la función con los argumentos [(2)]() . Por ejemplo: "Use the ID mentioned by the customer and call the xyz function with that".
Si los argumentos siguen sin pasar, verifica que:
- El esquema JSON está correctamente formateado con "type": "object" [(1)]()
- La descripción del parámetro es clara para el LLM
- La función está siendo llamada en el momento correcto dentro del flujo de la conversación [(2)]()AI Evy
01/24/2025, 8:52 PM