Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -129,18 +129,18 @@ def rag_query(query): | |
| 129 |  | 
| 130 | 
             
                return response
         | 
| 131 |  | 
| 132 | 
            -
             | 
| 133 | 
            -
            # | 
| 134 | 
            -
             | 
| 135 | 
            -
            # | 
| 136 | 
            -
             | 
| 137 | 
            -
             | 
| 138 | 
            -
            # | 
| 139 | 
            -
            # | 
| 140 | 
            -
             | 
| 141 | 
            -
             | 
| 142 | 
            -
             | 
| 143 | 
            -
             | 
| 144 |  | 
| 145 | 
             
            # Streamlit interface
         | 
| 146 |  | 
| @@ -149,11 +149,11 @@ st.markdown("***") | |
| 149 | 
             
            st.info('''
         | 
| 150 | 
             
                    Tôi sẽ giải đáp các thắc mắc của bạn liên quan đến các sản phẩm bảo hiểm nhân thọ của MB Ageas Life''')
         | 
| 151 |  | 
| 152 | 
            -
             | 
| 153 |  | 
| 154 | 
            -
             | 
| 155 | 
            -
             | 
| 156 | 
            -
             | 
| 157 | 
             
            st.switch_page("pages/chatbot.py")
         | 
| 158 |  | 
| 159 |  | 
|  | |
| 129 |  | 
| 130 | 
             
                return response
         | 
| 131 |  | 
| 132 | 
            +
            def process_feedback(query, response, feedback):
         | 
| 133 | 
            +
               # st.write(f"Feedback received: {'👍' if feedback else '👎'} for query: {query}")
         | 
| 134 | 
            +
                if feedback:
         | 
| 135 | 
            +
                    # If thumbs up, store the response in memory buffer
         | 
| 136 | 
            +
                    memory.chat_memory.add_ai_message(response)
         | 
| 137 | 
            +
                else:
         | 
| 138 | 
            +
                    # If thumbs down, remove the response from memory buffer and regenerate the response
         | 
| 139 | 
            +
                   # memory.chat_memory.messages = [msg for msg in memory.chat_memory.messages if msg.get("content") != response]
         | 
| 140 | 
            +
                    new_query=f"{query}. Give better response"
         | 
| 141 | 
            +
                    new_response = rag_query(new_query)
         | 
| 142 | 
            +
                    st.markdown(new_response)
         | 
| 143 | 
            +
                    memory.chat_memory.add_ai_message(new_response)
         | 
| 144 |  | 
| 145 | 
             
            # Streamlit interface
         | 
| 146 |  | 
|  | |
| 149 | 
             
            st.info('''
         | 
| 150 | 
             
                    Tôi sẽ giải đáp các thắc mắc của bạn liên quan đến các sản phẩm bảo hiểm nhân thọ của MB Ageas Life''')
         | 
| 151 |  | 
| 152 | 
            +
            col1, col2 = st.columns(2)
         | 
| 153 |  | 
| 154 | 
            +
            with col1:
         | 
| 155 | 
            +
                chat = st.button("Chat")
         | 
| 156 | 
            +
                if chat:
         | 
| 157 | 
             
            st.switch_page("pages/chatbot.py")
         | 
| 158 |  | 
| 159 |  | 
