Open iclyn-taero opened 2 months ago
test json
{
"queries": {
"onChatLoad": {
"id": "onChatLoad",
"cells": [
{
"id": "64545",
"widget": "code",
"parameters": {
"code": "history = []",
"type": "py"
}
},
{
"id": "23285",
"widget": "code",
"parameters": {
"type": "py",
"code": "def promptQuery(search_statement:str, limit = 5) -> str:\r\n import json\r\n from gaas_gpt_model import ModelEngine\r\n model = ModelEngine(engine_id = \"4801422a-5c62-421e-a00c-05c6a9e15de8\", insight_id = '${i}')\r\n prompt = search_statement + ' Format the result as markdown.'\r\n response = model.ask(question = prompt)\r\n return json.dumps(response[0]['response'])"
}
}
]
},
"askChat": {
"id": "askChat",
"cells": [
{
"id": "20487",
"widget": "code",
"parameters": {
"type": "py",
"code": "res = promptQuery('{{block.chat--3027.ask}}')\r\n\r\n# add to the history\r\nhistory.append({'agent': res, 'user' : '{{block.chat--3027.ask}}'})"
}
}
]
},
"getChatMessages": {
"id": "getChatMessages",
"cells": [
{
"id": "33923",
"widget": "code",
"parameters": {
"type": "py",
"code": "history"
}
}
]
}
},
"blocks": {
"page-1": {
"slots": {
"content": {
"children": [
"text--8787",
"container--9338"
],
"name": "content"
}
},
"widget": "page",
"data": {
"style": {
"padding": "24px",
"fontFamily": "roboto",
"flexDirection": "column",
"display": "flex",
"gap": "8px"
}
},
"listeners": {
"onPageLoad": []
},
"id": "page-1"
},
"container--9338": {
"id": "container--9338",
"widget": "container",
"parent": {
"id": "page-1",
"slot": "content"
},
"data": {
"style": {
"display": "flex",
"flexDirection": "column",
"padding": "16px",
"gap": "8px",
"flexWrap": "wrap",
"border": "1px solid #d6d6d6",
"height": "100%",
"width": "100%"
}
},
"listeners": {},
"slots": {
"children": {
"name": "children",
"children": [
"chat--3027"
]
}
}
},
"chat--3027": {
"id": "chat--3027",
"widget": "chat",
"parent": {
"id": "container--9338",
"slot": "children"
},
"data": {
"loading": "{{query.askChat.isLoading}}",
"ask": "",
"history": "{{query.getChatMessages.output}}"
},
"listeners": {
"onAsk": [
{
"message": "RUN_QUERY",
"payload": {
"queryId": "askChat"
}
},
{
"message": "RUN_QUERY",
"payload": {
"queryId": "getChatMessages"
}
}
],
"onLoad": [
{
"message": "RUN_QUERY",
"payload": {
"queryId": "onChatLoad"
}
},
{
"message": "RUN_QUERY",
"payload": {
"queryId": "getChatMessages"
}
}
]
},
"slots": {
"children": {
"name": "children",
"children": []
}
}
},
"text--8787": {
"id": "text--8787",
"widget": "text",
"parent": {
"id": "page-1",
"slot": "content"
},
"data": {
"style": {
"padding": "4px",
"whiteSpace": "pre-line",
"textOverflow": "ellipsis"
},
"text": "AI Assistant",
"variant": "h2"
},
"listeners": {},
"slots": {}
}
},
"variables": {},
"dependencies": {},
"version": "1.0.0-alpha"
}
Description
Add the ability to drag a Chat block into the ui. This should allow the user to interact with the notebook and excute code
Existing
n/a
Reference
n/a
Tasks
onLoad
listener called when the component is initializedhistory
data from an array containing user (string input), agent (markdown response)ask
data- input into the chatonAsk
listener triggered when the user inputs -- [ ] Addloading
data - boolean set when true or false