(Day 250) Seoul Tech Impact Day 1

Ivan Ivanov · September 7, 2024

Hello :) Today is Day 250!

A quick summary of today:

  • creating a language learning chatbot for expressions in different real-life situations

I am awake, ‘hacking’ and I am writing this blog quickly so that I can keep working on our app.

Here are some pics from today:

image image image

As I mentioned, we are creating a chatbot.

This is our Figma graph right now:

image

I am working on implementing chat history and feedback. I have setup postgres using Docker, and set up saving the chat history in the db. But I have been struggling to save user feedback. The reason is, it needs to be done using some buttons/submit form. But any time a button is clicked after a response comes from the RAG, the UI resets and nothing is executed.

Here is the problematic code:

if authentication_status:
    st.write(f'Welcome *{name}*')
    authenticator.logout('Logout', 'main')
    user_query = st.text_input("Enter your question:")

    if st.button("Search"):
        if user_query:
            st.session_state.last_query = user_query  # Store the last query
            with st.spinner("Searching..."):
                answer, token_usage, response_time, search_results = rag(user_query)
                st.success("Query Completed!")
                answer_data = {
                    'answer': answer,
                    'response_time': response_time,
                    'token_usage': token_usage,
                    'search_results': str(search_results)
                }
                st.write(answer)
                save_conversation(st.session_state.conversation_id, user_query, answer_data, username)
                
                # Display feedback options
                st.session_state.feedback = st.radio(
                    "Was this answer helpful?", 
                    options=[0, 1], 
                    format_func=lambda x: "👍" if x == 1 else "👎", 
                    key='feedback_radio'
                )
################## HERE
                if st.button("Submit Feedback"):
                    if st.session_state.feedback is not None:
                        feedback_value = 1 if st.session_state.feedback == 1 else -1  # Map radio button value to -1, +1
                        save_feedback(username, st.session_state.conversation_id, feedback_value)
                        st.success("Feedback submitted!")
                    else:
                        st.warning("Please provide feedback before submitting.")
#######################
        else:
            st.warning("Please enter a query.")

This is what I have right now. It does not work, but I am taking a 10 min break to write this blog. Other options with just buttons don’t work either.

Anyway ~ hopefully I figure it out.

Meanwhile, my teammate is working on prompt engineering and setting up the UI.

This is kind of quick but I still wanted to share something.

I will update if I survived not sleeping for 24 hrs.

That is all for today!

See you tomorrow :)