From the course: Build with AI: LLM-Powered Applications with Streamlit

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Provide clear and helpful feedback to users

Provide clear and helpful feedback to users - Python Tutorial

From the course: Build with AI: LLM-Powered Applications with Streamlit

Provide clear and helpful feedback to users

- [Instructor] Let's keep up the great work by providing clear and helpful feedback to your users. This will include adding in chat history, similar to how you did it previously in the course. Let's provide clear feedback using the file 04_04b.py. You'll begin by importing your packages and dealing with your OpenAI key text file, and then you can add in a title, which will be RAG Chat with User Feedback. You can then scroll down to the section that you'll need to work on. Let's begin by determining if the chat history exists. So you have if "history" not in st.session_state and you'll have st.session_state.history equals an empty list. Then you'll define a function to handle the user's question and provide feedback. So you could define this as def send_and_feedback with some parenthesis and add your colon. And then let's begin by retrieving a user's query and removing any leading or trailing whitespace. So you'll have user_query = st.session_state .query.strip() and then you'll check…

Contents