This is an interactive notebook. You can run it locally or use the links below:
Setup
First, install the required packages and set your OpenAI and W&B API keys so that the chatbot can call the OpenAI API and log calls to Weave.chatbot.py with the following contents. This file defines the Streamlit chat interface, wraps the OpenAI call with a Weave op so each response is tracked, and renders the feedback controls that attach reactions and notes back to the corresponding Weave call.
streamlit run chatbot.py.
You can now interact with this application and click the feedback buttons after each response. Visit the Weave UI to see the attached feedback. Each chat exchange is recorded as a Weave call, and any reactions or notes you submit are linked to the call that produced the response.
Explanation
The following section walks through the key Weave APIs used in the chatbot, so you can apply the same pattern to your own application. Consider the following decorated prediction function:call object, which you obtain by using the .call() method instead of calling the function as normal:
call object to attach feedback to the specific response. After you make the call, the output of the operation is available as result.
With the call object in hand, you can then record user feedback against that specific response: