Assistants allow you to run a conversation without having to track state.

To use assistants, you first need to create an Intent via the Maitai Portal.

Add your prompt, and then you’re ready to get started.

For each turn in the assistant conversation, you only need to send one message at a time:

import maitai

response = maitai.chat.completions.create(
    messages=[{"role": "user", "content": "What's the weather in Barcelona?"}],
    session_id="YOUR_SESSION_ID",
    intent="ASSISTANT",
    application="personal_assistant",
    assistant=True,
}

follow_up_response = maitai.chat.completions.create(
    messages=[{"role": "user", "content": "And what's that in fahrenheit?"}],
    session_id="YOUR_SESSION_ID",
    intent="ASSISTANT",
    application="personal_assistant",
    assistant=True,
}

Turn specific instructions can also be used with an assistant. This is appended to your Intent prompt previously set in the portal.

import maitai

response = maitai.chat.completions.create(
    messages=[
      {"role": "system", "content": "This user has a VIP subscription"}
      {"role": "user", "content": "I need to schedule an appointment"}
    ],
    session_id="YOUR_SESSION_ID",
    intent="ASSISTANT",
    application="personal_assistant",
    assistant=True,
}