Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -29,8 +29,6 @@ def append_to_transcript(thread_id, role, message): | |
| 29 |  | 
| 30 | 
             
            # Streamlit UI setup
         | 
| 31 | 
             
            st.set_page_config(page_title="Carfind.co.za AI Assistant", layout="wide")
         | 
| 32 | 
            -
            st.markdown("<h1 style='text-align: center;'></h1>", unsafe_allow_html=True)
         | 
| 33 | 
            -
            st.caption("To start a Chat with Carfind.co.za say Hi")
         | 
| 34 |  | 
| 35 | 
             
            st.markdown("""
         | 
| 36 | 
             
                <style>
         | 
| @@ -70,6 +68,9 @@ if openai_key and assistant_id: | |
| 70 | 
             
                    )
         | 
| 71 | 
             
                    append_to_transcript(st.session_state["thread_id"], "user", user_input)
         | 
| 72 |  | 
|  | |
|  | |
|  | |
| 73 | 
             
                    try:
         | 
| 74 | 
             
                        with st.spinner("Thinking and typing... 💭"):
         | 
| 75 | 
             
                            run = client.beta.threads.runs.create(
         | 
| @@ -110,7 +111,7 @@ if openai_key and assistant_id: | |
| 110 | 
             
                                    unsafe_allow_html=True
         | 
| 111 | 
             
                                )
         | 
| 112 |  | 
| 113 | 
            -
                        #  | 
| 114 | 
             
                        st.markdown("""
         | 
| 115 | 
             
                            <script>
         | 
| 116 | 
             
                                window.scrollTo(0, 0);
         | 
| @@ -120,4 +121,4 @@ if openai_key and assistant_id: | |
| 120 | 
             
                    except Exception as e:
         | 
| 121 | 
             
                        st.error(f"An error occurred: {str(e)}")
         | 
| 122 | 
             
            else:
         | 
| 123 | 
            -
                st.error("⚠️ OpenAI key or Assistant ID not found. Please ensure both are set as Hugging Face secrets.")
         | 
|  | |
| 29 |  | 
| 30 | 
             
            # Streamlit UI setup
         | 
| 31 | 
             
            st.set_page_config(page_title="Carfind.co.za AI Assistant", layout="wide")
         | 
|  | |
|  | |
| 32 |  | 
| 33 | 
             
            st.markdown("""
         | 
| 34 | 
             
                <style>
         | 
|  | |
| 68 | 
             
                    )
         | 
| 69 | 
             
                    append_to_transcript(st.session_state["thread_id"], "user", user_input)
         | 
| 70 |  | 
| 71 | 
            +
                    # Clear input box after sending
         | 
| 72 | 
            +
                    st.session_state["chat_input"] = ""
         | 
| 73 | 
            +
             | 
| 74 | 
             
                    try:
         | 
| 75 | 
             
                        with st.spinner("Thinking and typing... 💭"):
         | 
| 76 | 
             
                            run = client.beta.threads.runs.create(
         | 
|  | |
| 111 | 
             
                                    unsafe_allow_html=True
         | 
| 112 | 
             
                                )
         | 
| 113 |  | 
| 114 | 
            +
                        # Auto scroll to top
         | 
| 115 | 
             
                        st.markdown("""
         | 
| 116 | 
             
                            <script>
         | 
| 117 | 
             
                                window.scrollTo(0, 0);
         | 
|  | |
| 121 | 
             
                    except Exception as e:
         | 
| 122 | 
             
                        st.error(f"An error occurred: {str(e)}")
         | 
| 123 | 
             
            else:
         | 
| 124 | 
            +
                st.error("⚠️ OpenAI key or Assistant ID not found. Please ensure both are set as Hugging Face secrets.")
         | 
