#Rendering agent send/receive messages to a web UI

8 messages · Page 1 of 1 (latest)

thick hamlet
#

What's the best pattern for displaying messages in a web UI? Essentially what's sent to the console.

I've tried to follow the sample app with the FastAPI and Gatsby frontend but I'm getting lost in the abstractions. Probably missing a mental model.

Inheriting from the agent classes is one way but it seems off that I'll have to inherit from every agent class at the extreme. So that plus I don't stop inherited agent clases in the web sample. Which makes me think it's not the best way.

tall ember
thick hamlet
#

Yeah,that's the sample I was referring to.

tall ember
#

If you can suggest any improvements, @proven pawn is the expert behind it.

proven pawn
#

@thick hamlet , in the example app, a short story of how agent messages is show in the ui is

  • call initiate_chat, ideally using user_proxy agent
  • get message history from user proxy agent messages = user_proxy.chat_messages
  • return messages to the UI over a REST api endpoint.

I have a separate sample that has fewer abstractions

GitHub

Web UI for AutoGen (A Framework Multi-Agent LLM Applications) - victordibia/autogen-ui

thick hamlet
#

@proven pawn thanks for confirming, that's initially what I thought should work. But chat_messages was empty. I'll take another look. likely I went down the wrong rabbit hole, it was a late at night. 🙂

another thing I could figure out is why the console output is missing message content from UserProxyAgent -> AssistantAgent

example:

user_proxy1 (to assistant1):

Plot a chart of NVDA and TESLA stock price change YTD.

--------------------------------------------------------------------------------
assistant1 (to user_proxy1):

# filename: plot.py

# First, let's import the necessary libraries
import pandas as pd
import matplotlib.pyplot as plt

# Now, let's read the csv file and select only the relevant columns
stocks_df = pd.read_csv('https://query1.finance.yahoo.com/v7/finance/download/NVDA,D09C,TSLA?period1=1577836800&period2=1609459200&interval=1d&events=history&includeAdjustedClose=true')
stocks_df = stocks_df[['Date', 'Close']]
stocks_df = stocks_df.set_index('Date')

# Now we can plot the chart
stocks_df.plot()
plt.title('NVDA and TESLA Stock Price Change YTD')
plt.xlabel('Date')
plt.ylabel('Price (USD)')
plt.show()

--------------------------------------------------------------------------------
user_proxy1 (to assistant1):



--------------------------------------------------------------------------------
proven pawn
#

what llm model are you using?
In the example above, it appears the code written by the assistant is not very well formatted in markdown.
This is important as autogen assumes the responses are well formatted text where code is wrapped in codeblocks. and can be extracted.

The user_proxy response is perhaps empty because the response is not properly formatted in markdown and no code is extracted. Specifically the code is not a code block python ....

If you are using small models, I would recommend exploring models like Zephyr that do fairly well at instruction following

thick hamlet
#

OpenAI gpt-35-turbo

The first few times I ran the code it produced the chart. As I've iterated to get the messages into the web UI it's stopped working. I've nuked the .cache and tried a few times, but doesn't run the chart. It also seemed when I switched the work dir from the default, things went funny.