Cobuild conversations¶
The Python client can start Cobuild conversations to explore or modify Agent Management objects. Cobuild must be available and configured on the instance, and the user or API key must have access to the requested tools and objects.
In the following examples, client is an AgentManagementClient created as described in The main AgentManagementClient class.
Starting a conversation¶
print(client.get_cobuild_status())
conversation = client.new_cobuild_conversation()
response = conversation.send_message("List all agents")
print(response.message)
if response.is_error:
print("Cobuild returned an error")
send_message() waits for the response. By default, allow_edit=False prevents the turn from creating or editing objects. Missing tool permissions are reported as an error response. conversation.messages contains the exchanges made through this handle.
Drafting and executing a plan¶
from dataikuapi.dss.cobuild import CobuildConversationMode
response = conversation.send_message(
"Plan how to tag the production support agents with customer-support",
conversation_mode=CobuildConversationMode.PLAN,
)
plan = response.updated_plan
if plan is not None:
print(plan.title, plan.status.value)
for milestone in plan.milestones:
print(milestone.title, milestone.status.value)
After inspecting the draft, approve execution with editing enabled for that turn.
response = conversation.approve_plan(allow_edit=True)
print(response.message)
Editing permission is granted per turn. Pass allow_edit=True again for subsequent execution turns when needed. To discard or detach the attached plan, use conversation.detach_plan().
Answering questions and confirmations¶
A response can ask you to answer a question or confirm an action. Inspect the response and supply an explicit choice before continuing.
if response.is_question_request:
print(response.title, response.predefined_answers)
response = conversation.answer_question(
answers=["Only agents on the production platform"],
used_custom_answer=True,
)
if response.is_confirmation_request:
print(response.objects_to_delete)
print(response.deletion_impacts)
# This example cancels the requested action:
response = conversation.answer_confirmation("CANCEL")
Select one of the offered choices, or provide your own answer if allow_custom_answer is true. Use APPROVE instead of CANCEL only after reviewing the requested action and its effects.
Reference documentation¶
Classes¶
A handle to a Cobuild conversation in Agent Management. |
|
Mode used for a Cobuild user message. |
|
A response from the Cobuild AI assistant. |
|
Read-only typed snapshot of a Cobuild plan. |
Functions¶
|
Answer a pending confirmation request and wait for the next response. |
|
Answer a pending question request and wait for the next response. |
|
Approve the current draft plan and wait for its execution response. |
Detach the current draft, active, or completed plan and return to build mode. |
|
Returns whether Cobuild is available to the authenticated caller. |
|
Start a new empty Cobuild conversation in Agent Management. |
|
|
Send a message and wait for the assistant's response. |
