Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	
		Théo Rousseaux
		
	commited on
		
		
					Commit 
							
							·
						
						36269bc
	
1
								Parent(s):
							
							31207dc
								
UI
Browse files
    	
        app.py
    CHANGED
    
    | @@ -40,7 +40,7 @@ display_workout = False | |
| 40 | 
             
            # First column containers
         | 
| 41 | 
             
            with col1:
         | 
| 42 |  | 
| 43 | 
            -
                st.subheader(" | 
| 44 |  | 
| 45 | 
             
                if "messages" not in st.session_state:
         | 
| 46 | 
             
                    st.session_state.messages = []
         | 
| @@ -48,11 +48,11 @@ with col1: | |
| 48 | 
             
                if "file_name" not in st.session_state:
         | 
| 49 | 
             
                    st.session_state.file_name = None
         | 
| 50 |  | 
| 51 | 
            -
                for message in st.session_state.messages:
         | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 |  | 
| 55 | 
            -
                if prompt := st.chat_input("What  | 
| 56 | 
             
                    st.session_state.messages.append({"role": "user", "content": prompt})
         | 
| 57 | 
             
                    with st.chat_message("user"):
         | 
| 58 | 
             
                        st.markdown(prompt)
         | 
| @@ -63,7 +63,7 @@ with col1: | |
| 63 | 
             
                        print(type(direction))
         | 
| 64 | 
             
                        print(direction)
         | 
| 65 | 
             
                        if direction=='fitness_advices':
         | 
| 66 | 
            -
                            with st.spinner(" | 
| 67 | 
             
                                response = rag_chain.invoke(
         | 
| 68 | 
             
                                            prompt
         | 
| 69 | 
             
                                            )
         | 
| @@ -80,12 +80,13 @@ with col1: | |
| 80 | 
             
                                    {"input" : prompt}
         | 
| 81 | 
             
                                )["output"]
         | 
| 82 | 
             
                        else:
         | 
| 83 | 
            -
                             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
|  | |
| 89 | 
             
                        print(type(response))
         | 
| 90 | 
             
                        st.session_state.messages.append({"role": "assistant", "content": response})
         | 
| 91 | 
             
                        st.markdown(response)
         | 
| @@ -97,7 +98,7 @@ with col1: | |
| 97 | 
             
            with col2:
         | 
| 98 | 
             
                # st.subheader("Sports Agenda")
         | 
| 99 | 
             
                    # TO DO
         | 
| 100 | 
            -
                st.subheader(" | 
| 101 |  | 
| 102 | 
             
                video_uploaded = st.file_uploader("Choose a video file", type=["mp4", "ogg", "webm", "MOV"])
         | 
| 103 | 
             
                if video_uploaded:
         | 
|  | |
| 40 | 
             
            # First column containers
         | 
| 41 | 
             
            with col1:
         | 
| 42 |  | 
| 43 | 
            +
                st.subheader("Coach chat")
         | 
| 44 |  | 
| 45 | 
             
                if "messages" not in st.session_state:
         | 
| 46 | 
             
                    st.session_state.messages = []
         | 
|  | |
| 48 | 
             
                if "file_name" not in st.session_state:
         | 
| 49 | 
             
                    st.session_state.file_name = None
         | 
| 50 |  | 
| 51 | 
            +
                # for message in st.session_state.messages:
         | 
| 52 | 
            +
                #     with st.chat_message(message["role"]):
         | 
| 53 | 
            +
                #         st.markdown(message["content"])
         | 
| 54 |  | 
| 55 | 
            +
                if prompt := st.chat_input("What's up?"):
         | 
| 56 | 
             
                    st.session_state.messages.append({"role": "user", "content": prompt})
         | 
| 57 | 
             
                    with st.chat_message("user"):
         | 
| 58 | 
             
                        st.markdown(prompt)
         | 
|  | |
| 63 | 
             
                        print(type(direction))
         | 
| 64 | 
             
                        print(direction)
         | 
| 65 | 
             
                        if direction=='fitness_advices':
         | 
| 66 | 
            +
                            with st.spinner("Retrieving relevant data..."):
         | 
| 67 | 
             
                                response = rag_chain.invoke(
         | 
| 68 | 
             
                                            prompt
         | 
| 69 | 
             
                                            )
         | 
|  | |
| 80 | 
             
                                    {"input" : prompt}
         | 
| 81 | 
             
                                )["output"]
         | 
| 82 | 
             
                        else:
         | 
| 83 | 
            +
                            with st.spinner("Creating workout program..."):
         | 
| 84 | 
            +
                                response = "Sure! I just made a workout for you. Check on the table I just provided you."
         | 
| 85 | 
            +
                                json_output = workout_chain.invoke({"query":prompt})
         | 
| 86 | 
            +
                                exercises_list = json_output['exercises']
         | 
| 87 | 
            +
                                workout_df = pd.DataFrame(exercises_list)
         | 
| 88 | 
            +
                                workout_df.columns = ["exercice", "nombre_series", "nombre_repetitions", "temps_repos"]
         | 
| 89 | 
            +
                                display_workout=True
         | 
| 90 | 
             
                        print(type(response))
         | 
| 91 | 
             
                        st.session_state.messages.append({"role": "assistant", "content": response})
         | 
| 92 | 
             
                        st.markdown(response)
         | 
|  | |
| 98 | 
             
            with col2:
         | 
| 99 | 
             
                # st.subheader("Sports Agenda")
         | 
| 100 | 
             
                    # TO DO
         | 
| 101 | 
            +
                st.subheader("Technique Analysis")
         | 
| 102 |  | 
| 103 | 
             
                video_uploaded = st.file_uploader("Choose a video file", type=["mp4", "ogg", "webm", "MOV"])
         | 
| 104 | 
             
                if video_uploaded:
         | 
