Skip to content

Commit

Permalink
✨ Add echart method to agent in python sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
aurelien-brabant committed Oct 26, 2023
1 parent 489d7c8 commit 6591715
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions sdks/python-sdk/agentlabs/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def write(self, token: str):
"agentId": self.agent_id
})


def typewrite(
self,
token: str,
Expand Down Expand Up @@ -105,6 +106,25 @@ def _upload_attachment(self, attachment: AttachmentItem) -> _UploadedAttachment:

return uploaded_attachment

def echart(self, conversation_id: str, echart: dict, text = '', text_format: MessageFormat = MessageFormat.PLAIN_TEXT):
"""Sends an [echart](https://echarts.apache.org/en/index.html) chart to a conversation, with an optional text message attached.
The echart parameter holds the chart configuration, including styling and data, and should only contain JSON serializable values.
Because echart is a Javascript library, this python SDK does not provide strong typing for the echart parameter.
You may want to refer to the examples from [this page](https://echarts.apache.org/examples/en/index.html) to get an idea of what the echart parameter should look like.
"""
self._realtime.emit('chat-message', {
"conversationId": conversation_id,
"text": text,
"agentId": self.id,
"source": "AGENT",
"format": text_format.value,
"attachments": [],
"type": "ECHART",
"metadata": echart
});

def send(self, text: str, conversation_id: str, format: MessageFormat = MessageFormat.PLAIN_TEXT, attachments: list[AttachmentItem] = []):
"""Sends a message to a conversation.
Such message will be communicated instantly to the conversation.
Expand Down

0 comments on commit 6591715

Please sign in to comment.