Create User Message
The create_message
method is a crucial function for simulating user interactions within a chat session. It allows users to send messages to an AI assistant.
import taskingai
user_message = taskingai.assistant.create_message(
assistant_id="YOUR_ASSISTANT_ID",
chat_id="YOUR_CHAT_ID",
text="hello",
)
The create_message
method takes three parameters: the assistant_id
of the assistant, the chat_id
of the chat session, and the text
of the message you wish to send. It returns a Message
object representing the user's message within the chat session.
Message with Images
If the assistant's language model supports vision inputs, you can easily include images in Markdown format within the message text. The API will automatically extract the image URLs and process them accordingly.
To ensure proper processing by the backend, include a unique identifier [TASKINGAI_USER_IMAGE]
in the image Markdown link to distinguish the content from other Markdown elements.
user_message = taskingai.assistant.create_message(
assistant_id="YOUR_ASSISTANT_ID",
chat_id="YOUR_CHAT_ID",
text="What is in the following image?\n\n![TASKINGAI_USER_IMAGE](https://example.com/image.jpg)",
)
Including a specific identifier like [TASKINGAI_USER_IMAGE]
helps the backend parse and process the image correctly, avoiding conflicts with other Markdown elements in the conversation context.
Please ensure the image URL is publicly accessible for the assistant to retrieve and process the image content.