bhulston commited on
Commit
f573c2a
1 Parent(s): 2fc110c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -45
app.py CHANGED
@@ -56,58 +56,61 @@ units = st.slider(
56
  )
57
 
58
 
59
- for message in st.session_state.messages:
60
- with st.chat_message(message["role"]):
61
- st.markdown(message["content"])
62
 
 
 
63
 
64
- ### GPT Response
65
- # Display assistant response in chat message container
66
- with st.chat_message("assistant"):
67
  message_placeholder = st.empty()
68
  full_response = ""
69
- assistant_response = "How can I help you today?"
70
  # Simulate stream of response with milliseconds delay
71
  for chunk in assistant_response.split():
72
  full_response += chunk + " "
73
  time.sleep(0.05)
74
  # Add a blinking cursor to simulate typing
75
- message_placeholder.markdown(full_response + "▌")
76
- message_placeholder.markdown(full_response)
77
- # Add assistant response to chat history
78
- st.session_state.messages.append({"role": "assistant", "content": full_response})
79
-
80
- if prompt := st.chat_input("What kind of class are you looking for?"):
81
- # Display user message in chat message container
82
- with st.chat_message("user"):
83
- st.markdown(prompt)
84
- # Add user message to chat history
85
- st.session_state.messages.append({"role": "user", "content": prompt})
86
-
87
- response = filter_agent(prompt, OPENAI_API)
88
- query = response
89
-
90
- response = index.query(
91
- vector= embeddings.embed_query(query),
92
- # filter= build_filter(json),
93
- top_k=5,
94
- include_metadata=True
95
- )
96
- response = reranker(query, response)
97
- result_query = 'Original Query:' + query + 'Query Results:' + str(response)
98
- assistant_response = result_agent(result_query, OPENAI_API)
99
-
100
- if assistant_response:
101
- with st.chat_message("assistant"):
102
- message_placeholder = st.empty()
103
- full_response = ""
104
- # Simulate stream of response with milliseconds delay
105
- for chunk in assistant_response.split():
106
- full_response += chunk + " "
107
- time.sleep(0.05)
108
- # Add a blinking cursor to simulate typing
109
- message_placeholder.markdown(full_response + "")
110
- message_placeholder.markdown(full_response)
111
- # Add assistant response to chat history
112
- st.session_state.messages.append({"role": "assistant", "content": full_response})
 
 
 
113
 
 
56
  )
57
 
58
 
59
+ # for message in st.session_state.messages:
60
+ # with st.chat_message(message["role"]):
61
+ # st.markdown(message["content"])
62
 
63
+ assistant = st.chat_message("assistant")
64
+ assistant.write("How can I help you today?")
65
 
66
+ def assistant_response(response):
 
 
67
  message_placeholder = st.empty()
68
  full_response = ""
69
+ assistant_response = response
70
  # Simulate stream of response with milliseconds delay
71
  for chunk in assistant_response.split():
72
  full_response += chunk + " "
73
  time.sleep(0.05)
74
  # Add a blinking cursor to simulate typing
75
+ assistant.markdown(full_response + "▌")
76
+ assistant.markdown(full_response)
77
+ # Add assistant response to chat history
78
+ st.session_state.messages.append({"role": "assistant", "content": full_response})
79
+
80
+ assistant_response("Yah I'm tired af right now boi")
81
+
82
+
83
+ # if prompt := st.chat_input("What kind of class are you looking for?"):
84
+ # # Display user message in chat message container
85
+ # with st.chat_message("user"):
86
+ # st.markdown(prompt)
87
+ # # Add user message to chat history
88
+ # st.session_state.messages.append({"role": "user", "content": prompt})
89
+
90
+ # response = filter_agent(prompt, OPENAI_API)
91
+ # query = response
92
+
93
+ # response = index.query(
94
+ # vector= embeddings.embed_query(query),
95
+ # # filter= build_filter(json),
96
+ # top_k=5,
97
+ # include_metadata=True
98
+ # )
99
+ # response = reranker(query, response)
100
+ # result_query = 'Original Query:' + query + 'Query Results:' + str(response)
101
+ # assistant_response = results_agent(result_query, OPENAI_API)
102
+
103
+ # if assistant_response:
104
+ # with st.chat_message("assistant"):
105
+ # message_placeholder = st.empty()
106
+ # full_response = ""
107
+ # # Simulate stream of response with milliseconds delay
108
+ # for chunk in assistant_response.split():
109
+ # full_response += chunk + " "
110
+ # time.sleep(0.05)
111
+ # # Add a blinking cursor to simulate typing
112
+ # message_placeholder.markdown(full_response + "")
113
+ # message_placeholder.markdown(full_response)
114
+ # # Add assistant response to chat history
115
+ # st.session_state.messages.append({"role": "assistant", "content": full_response})
116