Cobuild¶
- class dataikuapi.dss.cobuild.DSSCobuildConversation(client, project_key, conversation_id, selected_objects=None)¶
A handle to a conversation with Cobuild AI assistant.
Important
Do not create this class directly, instead use
dataikuapi.dss.project.DSSProject.new_cobuild_conversation().The
messagesproperty accumulates all exchanges made through this handle (user inputs and assistant responses).A typical interaction:
conv = project.new_cobuild_conversation() response = conv.send_message("List the datasets in this project") print(response.message) conv.send_message("Now filter the Orders dataset to keep only orders with an amount > 1000") print(conv.messages[-1].message)
To attach an image, upload it to this conversation before sending the message:
with open("screenshot.png", "rb") as image: conversation_file_id = conv.upload_file(image, "screenshot.png") response = conv.send_message( "Explain this screenshot", conversation_file_ids=[conversation_file_id] ) print(response.message)
When the assistant needs to delete objects, it first asks for confirmation:
response = conv.send_message("Delete the Orders dataset") if response.is_confirmation_request: print("Objects to delete:", response.objects_to_delete) response = conv.answer_confirmation("APPROVE") print(response.message)
When the assistant needs an explicit answer, it asks a question:
response = conv.send_message("Use the best date column for sorting") if response.is_question_request: print("Question:", response.title) print("Choices:", response.predefined_answers) print("Allow custom answer:", response.allow_custom_answer) response = conv.answer_question( answers=["OrderDate"], rejected=False, used_custom_answer=False ) print(response.message)
You can also decline answering a question:
response = conv.send_message("Pick the dataset to build") if response.is_question_request: response = conv.answer_question( answers=[], rejected=True, used_custom_answer=False ) print(response.message)
For tools that require project edit permission, pass
allow_edit_project=Truetosend_message(). To allow file operations in specific managed folders, pass their IDs throughallow_edit_managed_folder_contents.Cobuild can also create plans, iterate with the user and implement them once approved by the user. The conversation can be in one of three states: build mode without a plan, plan mode with a draft plan, and build mode with an active plan. Send messages with
conversation_mode=CobuildConversationMode.PLANto draft a plan, then callapprove_plan()to execute it and wait for the final response. Discard a draft plan before returning to build mode, and discard an active plan before returning to plan mode.- property messages¶
All messages exchanged during this conversation, in order.
User message entries are
CobuildUserMessage.Assistant message entries are
CobuildAssistantResponse.- Return type:
list of
CobuildAssistantResponseorCobuildUserMessage
- list_skills()¶
List skills available to the current user in this project.
Each dictionary contains the following string fields:
name: project-qualified skill identifier, such asMYPROJECT.my-skill. Pass this value in theskillsargument ofsend_message().displayName: human-readable skill name, for display purposes.displayDescription: description of the skill’s purpose, for display purposes.
Results are sorted by
displayName, ignoring case.For example, to use the first available skill:
skills = conversation.list_skills() if skills: conversation.send_message("Help me with this task", skills=[skills[0]["name"]])
- Returns:
skill metadata, or an empty list if no skills are available
- Return type:
list[dict[str, str]]
- upload_file(fp, filename)¶
Upload an image file to this conversation.
Pass the returned identifier to
send_message()throughconversation_file_idsto attach the image to a message.JPEG and PNG images are supported, up to 32 MiB, with a maximum width and height of 2048 pixels each. Resize larger images before uploading. The image is uploaded as provided, without resizing or format conversion. The caller is responsible for closing the input file.
- Parameters:
fp (file) – A binary file-like object containing the image
filename (str) – The file name
- Returns:
the conversation file identifier
- Return type:
str
- delete_file(conversation_file_id)¶
Delete a conversation file from this conversation.
- Parameters:
conversation_file_id (str) – The identifier returned by
upload_file()
- send_message(message, selected_objects=None, allow_edit_project=False, conversation_mode=CobuildConversationMode.BUILD, intelligence_level=None, allow_edit_managed_folder_contents=None, skills=None, conversation_file_ids=None)¶
Send a message to the assistant and wait for its response.
The message and assistant response are appended to
messages.- Parameters:
message (str) – the message to send
selected_objects (list[
DSSDataset,DSSRecipe,DSSLabelingTask,DSSManagedFolder,DSSSavedModel,DSSKnowledgeBank,DSSModelEvaluationStoreorDSSStreamingEndpoint]) – object selection the assistant should focus on. It is reused for any subsequent message, unless overwrittenallow_edit_project (bool) – whether to allow Cobuild to create and edit everything needed in this project to follow this message. This permission applies only to this message.
allow_edit_managed_folder_contents (list[str]) – list of managed folder ids in which Cobuild is allowed to write, modify or delete files This permission applies only to this message.
conversation_mode (CobuildConversationMode) –
CobuildConversationMode.BUILD(the default) for normal or plan-execution messages, orCobuildConversationMode.PLANto draft or revise a plan. A draft plan must be discarded before switching back to build mode; an active plan must be discarded before switching back to plan mode.intelligence_level (str) – optional intelligence level:
"LIGHT","MEDIUM","HIGH", or"VERY_HIGH".Nonedefaults to"MEDIUM".skills (list[str]) – optional names of skills to load for this message, as returned by
list_skills(). A skill that is unknown or unavailable in this project makes the call fail. In the conversation as stored by DSS, the skills appear as references at the start of the message.conversation_file_ids (list[str]) – identifiers returned by
upload_file()for this conversation. Files apply only to this message and are not reused for subsequent messages.
- Returns:
the assistant’s response
- Return type:
- approve_plan(allow_edit_project=False, intelligence_level=None, allow_edit_managed_folder_contents=None)¶
Approve the current draft plan, wait for its execution, and return its final response.
A plan can be approved only while it is a draft. Use
detach_plan()to remove the active plan before returning to plan mode.- Parameters:
allow_edit_project (bool) – whether to allow Cobuild to create and edit everything needed in this project to execute the plan. This permission applies only to this Cobuild turn. If Cobuild comes back with a message without the plan being fully executed (e.g. after hitting a blocker), the same parameter should be passed on the next turn to retain this behavior.
allow_edit_managed_folder_contents (list[str]) – list of managed folder ids in which Cobuild is allowed to write, modify or delete files permission applies to the next turn, as it does for allow_edit_project
intelligence_level (str) – optional intelligence level:
"LIGHT","MEDIUM","HIGH", or"VERY_HIGH".Nonedefaults to"MEDIUM".
- Returns:
the final assistant response from plan execution
- Return type:
- detach_plan()¶
Detach the current draft/active/completed plan and return the conversation to build mode.
Call this before leaving plan mode with a draft, or before entering plan mode while an active plan is attached to the conversation.
- answer_confirmation(choice, options=None)¶
Answer a pending confirmation request and wait for the assistant’s next response.
Call this after receiving a response with
is_confirmation_requestset toTrue.The choice and assistant response are appended to
messages.- Parameters:
choice (str) –
"APPROVE"to proceed with the operation, or"CANCEL"to abort itoptions (list) – optional list of per-object deletion options (advanced use, for delete confirmations only). Each entry is a dict with
projectKey,type,id, and anoptionsdict containingdropData,dropMetastoreTable, anddeleteOrphanInsightsbooleans. When omitted, all options default toFalse(data is not dropped, metastore tables are not dropped, orphan insights are not deleted).
- Returns:
the assistant’s response after the confirmation
- Return type:
- answer_question(answers=None, rejected=False, used_custom_answer=False, selected_objects=None)¶
Answer a pending question request and wait for the assistant’s next response.
Call this after receiving a response with
is_question_requestset toTrue.The answer and assistant response are appended to
messages.- Parameters:
answers (list[str]) – answers selected or entered by the user. Use an empty list when
rejected=True. Defaults to[].rejected (bool) – whether to decline answering the question
used_custom_answer (bool) – whether one of the answers came from the custom free-text input
selected_objects (list[
DSSDataset,DSSRecipe,DSSLabelingTask,DSSManagedFolder,DSSSavedModel,DSSKnowledgeBank,DSSModelEvaluationStoreorDSSStreamingEndpoint]) – object selection the assistant should focus on. It is reused for subsequent messages and question answers, unless overwritten
- Returns:
the assistant’s response after the question answer
- Return type:
- class dataikuapi.dss.cobuild.CobuildConversationMode(*values)¶
Mode used for a Cobuild user message.
- BUILD = 'BUILD'¶
- PLAN = 'PLAN'¶
- class dataikuapi.dss.cobuild.CobuildMessage(raw)¶
- property message¶
The text content of the response.
- Return type:
str or None
- class dataikuapi.dss.cobuild.CobuildUserMessage(raw)¶
A message sent to Cobuild AI assistant by the user.
Important
Do not create this class directly, it is automatically created when using
dataikuapi.dss.project.DSSProject.new_cobuild_conversation(),DSSCobuildConversation.send_message(), andDSSCobuildConversation.answer_confirmation(), andDSSCobuildConversation.answer_question(). It is also used bydataikuapi.agentmanagement.cobuild.CobuildConversation.- property role¶
Role of the message sender (“user” or “assistant”)
- Return type:
str
- property conversation_file_ids¶
Identifiers of the conversation files sent with this message.
- Return type:
list[str]
- property type¶
Type of the message:
"request","delete_confirmation_response", or"ask_question_to_user_response"."request": a normal message sent to cobuild."delete_confirmation_response": user response when cobuild requests confirmation before deleting objects"ask_question_to_user_response": user response when cobuild requests an explicit answer
- Return type:
str
- property is_confirmation_response¶
Whether this message is the answer for assistant requesting confirmation before deleting objects
- Return type:
bool
- property is_question_response¶
Whether this message is the answer for assistant requesting an explicit answer.
- Return type:
bool
- property message¶
The text content of the response.
- Return type:
str or None
- class dataikuapi.dss.cobuild.CobuildAssistantResponse(raw)¶
A response from the Cobuild AI assistant.
Important
Do not create this class directly, it is returned by
DSSCobuildConversation.send_message()DSSCobuildConversation.answer_confirmation(), andDSSCobuildConversation.answer_question(), andDSSCobuildConversation.approve_plan(). Agent Management conversations return this same response type throughdataikuapi.agentmanagement.cobuild.CobuildConversation.- property role¶
Role of the message sender (“user” or “assistant”)
- Return type:
str
- property type¶
Type of the response:
"assistant_message","delete_confirmation_request","ask_question_to_user_request", or"error"."assistant_message": the assistant has completed its turn; the conversation is idle."delete_confirmation_request": the assistant is requesting confirmation before deleting objects. CallDSSCobuildConversation.answer_confirmation()with a choice of"APPROVE"or"CANCEL"to continue."ask_question_to_user_request": the assistant is requesting an explicit answer before it can continue. CallDSSCobuildConversation.answer_question()to continue."error": an error occurred while processing the Cobuild turn. In the public API, missing tool permissions are reported through this error response too.
- Return type:
str
- property is_question¶
DEPRECATED … DEPRECATED … DEPRECATED … DEPRECATED Whether the assistant is asking the user a question. If
True, callDSSCobuildConversation.send_message()again with the answer to continue.- Return type:
bool
- property is_confirmation_request¶
Whether the assistant is requesting confirmation before deleting objects or doing other operations requiring confirmation. If
True, callDSSCobuildConversation.answer_confirmation()with a choice of"APPROVE"or"CANCEL"to continue. If the confirmation is about a deletion, inspectobjects_to_deleteanddeletion_impactsfor details.- Return type:
bool
- property is_question_request¶
Whether the assistant is requesting an explicit answer before continuing. If
True, callDSSCobuildConversation.answer_question().- Return type:
bool
- property is_error¶
Whether the response represents an error.
- Return type:
bool
- property objects_to_delete¶
For
"delete_confirmation_request"responses: the list of objects that the assistant is requesting permission to delete (or unshare). Each entry is a dict with fieldsprojectKey,type,id, anddisplayName.Nonefor other response types.- Return type:
list of dict or None
- property deletion_impacts¶
For
"delete_confirmation_request"responses: a dict describing the cascading effects of the requested deletion (recipes that would be deleted, datasets left unchanged, etc.).Nonefor other response types.- Return type:
dict or None
- property question_id¶
For
"ask_question_to_user_request"responses: the identifier of the pending question.Nonefor other response types.- Return type:
str or None
- property title¶
For
"ask_question_to_user_request"responses: the short question shown to the user.Nonefor other response types.- Return type:
str or None
- property predefined_answers¶
For
"ask_question_to_user_request"responses: the list of predefined answers proposed by Cobuild.Nonefor other response types.- Return type:
list[str] or None
- property allow_custom_answer¶
For
"ask_question_to_user_request"responses: whether a custom free-text answer is allowed.Nonefor other response types.- Return type:
bool or None
- property allow_multiple_answers¶
For
"ask_question_to_user_request"responses: whether multiple answers can be selected.Nonefor other response types.- Return type:
bool or None
- property default_answer_set¶
For
"ask_question_to_user_request"responses: whether Cobuild suggested a default answer.Nonefor other response types.- Return type:
bool or None
- property updated_plan¶
The latest non-null plan update emitted while processing this request.
The returned
CobuildPlanis a read-only snapshot of the complete current plan, including its status, title, description, and typed milestones.Nonewhen the request did not update a plan or if it got discarded.- Return type:
CobuildPlanor None
- property message¶
The text content of the response.
- Return type:
str or None
- class dataikuapi.dss.cobuild.CobuildPlan(raw)¶
Read-only typed snapshot of a Cobuild plan.
A plan is returned by
CobuildAssistantResponse.updated_planwhenever Cobuild updates it while processing a request. The snapshot contains the complete current plan, not a patch. To revise it, send another message inCobuildConversationMode.PLANmode; to execute a draft, callDSSCobuildConversation.approve_plan()ordataikuapi.agentmanagement.cobuild.CobuildConversation.approve_plan().For example:
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)
- property id¶
Identifier of this plan.
- Return type:
str
- property status¶
Current lifecycle state of this plan.
- Return type:
- property title¶
Short description of the overall plan.
- Return type:
str or None
- property description¶
Detailed description of the plan.
- Return type:
str or None
- property milestones¶
Ordered milestones making up this plan.
- Return type:
list of
CobuildPlanMilestone
- class dataikuapi.dss.cobuild.CobuildPlanStatus(*values)¶
Lifecycle state of a
CobuildPlan.- DRAFT = 'DRAFT'¶
- ACTIVE = 'ACTIVE'¶
- INACTIVE = 'INACTIVE'¶
- class dataikuapi.dss.cobuild.CobuildPlanMilestone(raw)¶
One ordered unit of work in a
CobuildPlan.Milestones are read-only snapshots of the plan returned by the server. Their fields describe both the intended work and its current execution state; changing this object does not modify the plan on the server.
- property id¶
Identifier of this milestone.
- Return type:
str
- property status¶
Current execution state of this milestone.
- Return type:
- property title¶
Short description of the milestone.
- Return type:
str or None
- property steps¶
Markdown description of the work Cobuild intends to carry out.
- Return type:
str or None
- property completion_checklist¶
Checks Cobuild uses to determine whether the milestone is complete.
- Return type:
list[str]
- property output_description_summary¶
Summary of the expected outputs or outcomes of this milestone.
- Return type:
str or None
- property implementation_notes¶
Additional implementation context, when Cobuild supplied it.
- Return type:
CobuildPlanImplementationNotesor None
- class dataikuapi.dss.cobuild.CobuildPlanMilestoneStatus(*values)¶
Execution state of a
CobuildPlanMilestone.- NOT_STARTED = 'NOT_STARTED'¶
- IN_PROGRESS = 'IN_PROGRESS'¶
- DONE = 'DONE'¶
- class dataikuapi.dss.cobuild.CobuildPlanImplementationNotes(raw)¶
Additional implementation context for a Cobuild plan milestone.
These notes record the tools that Cobuild planned to use and the reasoning it retained while validating and executing the plan. They are provided for inspection only; changing this object does not modify the plan on the server.
- property tools¶
Names of the tools Cobuild planned to use.
- Return type:
list[str]
- property details¶
Detailed implementation and validation notes.
- Return type:
str or None
