uezo / aiavatarkit

🥰 Building AI-based conversational avatars lightning fast ⚡️💬
Apache License 2.0
162 stars 10 forks source link

Make it possible to exit chat on turn end #30

Closed uezo closed 2 months ago

uezo commented 2 months ago

Implement AIAvatar.on_turn_end that is call at the end of each conversation turn to control exit/not exit.

This is an example to exit chat if the request message contains "bye".

app = AIAvatar()

async def on_turn_end(req, resp):
    if "bye" in req:
        # Reset histories
        app.chat_processor.reset_histories()
        # Return True to exit chat
        return True

# Set the function to on_turn_end
app.on_turn_end = on_turn_end