Skip to main content
This is an interactive notebook. You can run it locally or use the links below:

It is often hard to automatically evaluate a generated LLM response so, depending on your risk tolerance, you can gather direct user feedback to find areas to improve. In this tutorial, we’ll use a custom chatbot as an example app from which to collect user feedback. We’ll use Streamlit to build the interface and we’ll capture the LLM interactions and feedback in Weave.

Setup

Next, create a file called chatbot.py with the following contents:
You can run this with streamlit run chatbot.py. Now, you can interact with this application and click the feedback buttons after each response. Visit the Weave UI to see the attached feedback.

Explanation

If we consider our decorated prediction function as:
We can use it as usual to deliver some model response to the user:
To attach feedback, you need the call object, which is obtained by using the .call() method instead of calling the function as normal:
This call object is needed for attaching feedback to the specific response. After making the call, the output of the operation is available using result above.

Conclusion

In this tutorial, we built a chat UI with Streamlit which had inputs & outputs captured in Weave, alongside 👍👎 buttons to capture user feedback.