cheshire-cat-ai / core

Production ready AI agent framework
https://cheshirecat.ai
GNU General Public License v3.0
2.28k stars 312 forks source link

[Refactor] Refactoring `/message` endpoint in order to execute the agent #921

Open valentimarco opened 2 weeks ago

valentimarco commented 2 weeks ago

At the moment, /message is mostly bugged when trying to interact with the agent.

The last dev meeting, we discuss how can be:

  1. No streaming (If you need it, use WS.). The reason is simple: This http method will be design for agent interaction that are not conversational but rather utility (Translations, Interaction with CRMs etc...)
  2. JSON that contains at least the key "text" (like we do in WS). This way if you have some custom stuff that reads the json, you are free to do it even in http.
  3. Some python types to help OpenApi gen (PLS)
MihirKohli commented 1 week ago

Can you please brief more about the issue.

mastrogiovanni commented 1 week ago

What to do with websocket notifications? I fixed the /message endpoint with the following (mutuated from ws interface):

@router.post("/message", response_model=CatMessage)
async def message_with_cat(
    payload: Dict = Body({"text": "hello!"}),
    stray=Depends(HTTPAuth(AuthResource.CONVERSATION, AuthPermission.WRITE)),
) -> Dict:
    """Get a response from the Cat"""
    payload["user_id"] = stray.user_id
    return await stray.__call__(payload)

The problem is that stray cat try to send notification to websocket producing a lot of warnings. Is that ok if I'll remove the warnings and I'll leave the current behaviour that simply ignore the notifications if ws is None?