conversations
Bases: BaseConversations
Source code in airia/client/conversations/async_conversations.py
create_conversation(user_id, title=None, deployment_id=None, data_source_files={}, is_bookmarked=False, correlation_id=None)
async
Create a new conversation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
The unique identifier of the user creating the conversation. |
required |
title
|
str
|
The title for the conversation. If not provided, the conversation will be created without a title. |
None
|
deployment_id
|
str
|
The unique identifier of the deployment to associate with the conversation. If not provided, the conversation will not be associated with any specific deployment. |
None
|
data_source_files
|
dict
|
Configuration for data source files to be associated with the conversation. If not provided, no data source files will be associated. |
{}
|
is_bookmarked
|
bool
|
Whether the conversation should be bookmarked. Defaults to False. |
False
|
correlation_id
|
str
|
A unique identifier for request tracing and logging. If not provided, one will be automatically generated. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
CreateConversationResponse |
CreateConversationResponse
|
A response object containing the created conversation details including its ID, creation timestamp, and all provided parameters. |
Raises:
| Type | Description |
|---|---|
AiriaAPIError
|
If the API request fails, including cases where: - The user_id doesn't exist (404) - The deployment_id is invalid (404) - Authentication fails (401) - Access is forbidden (403) - Server errors (5xx) |
Example
from airia import AiriaAsyncClient
client = AiriaAsyncClient(api_key="your_api_key")
# Create a basic conversation
conversation = await client.conversations.create_conversation(
user_id="user_123"
)
print(f"Created conversation: {conversation.conversation_id}")
# Create a conversation with all options
conversation = await client.conversations.create_conversation(
user_id="user_123",
title="My Research Session",
deployment_id="deployment_456",
data_source_files={"documents": ["doc1.pdf", "doc2.txt"]},
is_bookmarked=True
)
print(f"Created bookmarked conversation: {conversation.conversation_id}")
Note
The user_id is required and must correspond to a valid user in the system. All other parameters are optional and can be set to None or their default values.
Source code in airia/client/conversations/async_conversations.py
delete_conversation(conversation_id, correlation_id=None)
async
Delete a conversation by its ID.
This method permanently removes a conversation and all associated data from the Airia platform. This action cannot be undone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conversation_id
|
str
|
The unique identifier of the conversation to delete |
required |
correlation_id
|
Optional[str]
|
Optional correlation ID for request tracing |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This method returns nothing upon successful deletion |
Raises:
| Type | Description |
|---|---|
AiriaAPIError
|
If the API request fails or the conversation doesn't exist |
Source code in airia/client/conversations/async_conversations.py
get_conversation(conversation_id, correlation_id=None)
async
Retrieve detailed information about a specific conversation by its ID.
This method fetches comprehensive information about a conversation including all messages, metadata, policy redactions, and execution status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conversation_id
|
str
|
The unique identifier of the conversation to retrieve. |
required |
correlation_id
|
str
|
A unique identifier for request tracing and logging. If not provided, one will be automatically generated. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
GetConversationResponse |
GetConversationResponse
|
A response object containing the conversation details including user ID, messages, title, deployment information, data source files, bookmark status, policy redactions, and execution status. |
Raises:
| Type | Description |
|---|---|
AiriaAPIError
|
If the API request fails, including cases where: - The conversation_id doesn't exist (404) - Authentication fails (401) - Access is forbidden (403) - Server errors (5xx) |
Example
from airia import AiriaAsyncClient
async def main():
client = AiriaAsyncClient(api_key="your_api_key")
# Get conversation details
conversation = await client.conversations.get_conversation(
conversation_id="conversation_123"
)
print(f"Conversation: {conversation.title}")
print(f"User: {conversation.user_id}")
print(f"Messages: {len(conversation.messages)}")
print(f"Bookmarked: {conversation.is_bookmarked}")
# Access individual messages
for message in conversation.messages:
print(f"[{message.role}]: {message.message}")
asyncio.run(main())
Note
This method only retrieves conversation information and does not modify or execute any operations on the conversation.