Chat in Space Utility¶
Helper functions for interacting with spaces (assistants) asynchronously, including waiting for completions and chatting against files.
Overview¶
The Chat in Space utilities provide:
- Async message sending with automatic polling
- Waiting for message completion
- File upload and chat workflows
Methods¶
unique_sdk.utils.chat_in_space.send_message_and_wait_for_completion - Send message and wait
Sends a message to a space asynchronously and polls until completion.
Parameters:
user_id(required) - User IDcompany_id(required) - Company IDassistant_id(required) - Assistant/Space IDtext(required) - Message texttool_choices(optional) - List of tools to use (e.g.,["WebSearch", "InternalSearch"])scope_rules(optional) - UniqueQL filter for document scopechat_id(optional) - Existing chat ID (creates new chat if omitted)poll_interval(optional) - Seconds between polls (default: 1.0)max_wait(optional) - Maximum seconds to wait (default: 60.0)stop_condition(optional) - When to stop:"stoppedStreamingAt"or"completedAt"(default:"stoppedStreamingAt")
Returns:
Space.Messageobject with the completed response
Example - Basic Usage:
Example - With Tools:
Example - With Scope Rules:
unique_sdk.utils.chat_in_space.chat_against_file - Upload file and chat
Uploads a file to a chat and sends a message, waiting for the response.
Parameters:
user_id(required) - User IDcompany_id(required) - Company IDassistant_id(required) - Assistant/Space IDpath_to_file(required) - Local file path to uploaddisplayed_filename(required) - Filename to displaymime_type(required) - MIME type (e.g.,"application/pdf")text(required) - Message to send after uploadpoll_interval(optional) - Seconds between polls (default: 1.0)max_wait(optional) - Maximum seconds to wait (default: 60.0)should_delete_chat(optional) - Delete chat after completion (default: True)
Returns:
Space.Messageobject with the response
Example:
Best Practices¶
Choose Appropriate Polling Settings
Use Stop Conditions Appropriately
Related Resources¶
- Space API - Direct space API methods
- Message API - Manage messages
- File I/O - Upload files before chatting
- Content API - Manage uploaded content