Usage of wave chatbot_card with pandas-ai #2049
-
Hi, I want to use to the chatbot_card from wave in combination with pandas-ai for interactions with a Dataframe. At first, my question is, whether the syntax of the following code snippet ist right? because I don't see the output of the LLM in the UI, just in terminal. The second question is, whether the chat_card is able to visualize charts/ Images? Because pandas-ai is able to create from a prompt charts from the dataframe. query = "SELECT * FROM mytable"
df = pd.read_sql_query(query, conn)
@app('/demo')
async def serve(q: Q):
if not q.client.initialized:
q.page['chat'] = ui.chatbot_card(box='1 1 5 5', data=data(fields='content from_user', t='list'), name='chatbot')
q.client.initialized = True
if q.args.chatbot:
user_message = q.args.chatbot
q.page['chat'].data += [[user_message, True]]
try:
result = pandas_ai(df, prompt=user_message)
q.page['chat'].data += [[result, False]]
except Exception as e:
q.page['chat'].data += [[str(e), False]]
await q.page.save() Thank you very much for your answer in advance. BG, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
It's not. Your code has extra brackets. Instead of
Yes. The chatbot is able to interpret markdown, which supports both images and embedded HTML. |
Beta Was this translation helpful? Give feedback.
The
result
in your case is int, rather than string.q.page['chat'].data += [str(result), False]
should solve it. Can you give it a try and let me know?