Public API / SDK Changes

1 min read

SDK

tech Chat In Space - Chat within a space using an assistant. You must provide an assistantId (e.g. assistant_hjcdga64bkklcjnhu4) and the message text to initiate the conversation.

You can send the message in an existing chat by specifying a chat_id (e.g. chat_dh37sjdcn38klhs) , or omit the chat_id to automatically create a new chat session. Check the optional parameters list for more configs.

The script sends a prompt asynchronously and continuously polls for completion, which is determined when the stoppedStreamingAt field of the message becomes non-null.

Optional parameters:

  • tool_choices: A list of tool names to be used for the message (e.g., ["WebSearch"]). If not provided, no tools will be used.

  • scope_rules: A dictionary specifying scope rules for the message, allowing you to restrict the context or data sources available to the assistant.

  • chat_id: The ID of the chat where the message should be sent. If omitted, a new chat will be created.

  • poll_interval: The number of seconds to wait between polling attempts (default: 1 second).

  • max_wait: The maximum number of seconds to wait for the message to complete (default: 60 seconds).

Example

latest_message = unique_sdk.utils.send_message_and_wait_for_completion(
        user_id=user_id,
        company_id=company_id,
        assistant_id=assistant_id,
        text="Tell me a short story.",
        chat_id=chat_id, # Optional - if no chat id is specified, a new chat will be created
        tool_choices=["WebSearch"],
        scope_rules={
            "or": [
                {
                    "operator": "in",
                    "path": [
                        "contentId"
                    ],
                    "value": [
                        "cont_u888z7cazxxm4lugfdjq7pks"
                    ]
                }
            ]
        },
    )

Check out Unique SDK on PyPI: https://pypi.org/project/unique_sdk/ .

Author

Last updated