bhulston commited on
Commit
3884ef0
·
1 Parent(s): 146b565

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -32
app.py CHANGED
@@ -62,35 +62,18 @@ for message in st.session_state.messages:
62
 
63
  prompt = st.chat_input("What kind of class are you looking for?")
64
 
65
- if st.button("Submit"):
66
- with st.chat_message("user"):
67
- st.markdown(prompt)
68
- st.session_state.message.append({"role": "user", "content": prompt})
69
-
70
- response = filter_agent(prompt, OPENAI_API)
71
- query = response
72
-
73
- response = index.query(
74
- vector= embeddings.embed_query(query),
75
- # filter= build_filter(json),
76
- top_k=5,
77
- include_metadata=True
78
- )
79
- response = reranker(query, response)
80
- result_query = 'Original Query:' + query + 'Query Results:' + str(response)
81
- final_response = result_agent(result_query, OPENAI_API)
82
-
83
- ### GPT Response
84
- # Display assistant response in chat message container
85
- with st.chat_message("assistant"):
86
- message_placeholder = st.empty()
87
- assistant_response = "Hello there! How can I assist you today?"
88
- # Simulate stream of response with milliseconds delay
89
- for chunk in assistant_response.split():
90
- full_response += chunk + " "
91
- time.sleep(0.05)
92
- # Add a blinking cursor to simulate typing
93
- message_placeholder.markdown(full_response + "▌")
94
- message_placeholder.markdown(final_response)
95
- # Add assistant response to chat history
96
- st.session_state.messages.append({"role": "assistant", "content": final_response})
 
62
 
63
  prompt = st.chat_input("What kind of class are you looking for?")
64
 
65
+
66
+ ### GPT Response
67
+ # Display assistant response in chat message container
68
+ with st.chat_message("assistant"):
69
+ message_placeholder = st.empty()
70
+ assistant_response = "Hello there! How can I assist you today?"
71
+ # Simulate stream of response with milliseconds delay
72
+ for chunk in assistant_response.split():
73
+ full_response += chunk + " "
74
+ time.sleep(0.05)
75
+ # Add a blinking cursor to simulate typing
76
+ message_placeholder.markdown(full_response + "▌")
77
+ message_placeholder.markdown(final_response)
78
+ # Add assistant response to chat history
79
+ st.session_state.messages.append({"role": "assistant", "content": final_response})