bhulston commited on
Commit
6164e6b
1 Parent(s): f5d7bd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -27
app.py CHANGED
@@ -54,42 +54,41 @@ units = st.slider(
54
  )
55
 
56
 
57
- # for message in st.session_state.messages:
58
- # with st.chat_message(message["role"]):
59
- # st.markdown(message["content"])
60
-
61
-
62
-
63
  assistant = st.chat_message("assistant")
64
  initial_message = "How can I help you today?"
65
 
66
- def assistant_response(response):
67
- message_placeholder = assistant.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
- 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 "messages" not in st.session_state:
81
  st.session_state.messages = []
82
- assistant_response(initial_message)
83
-
84
-
 
85
 
86
  if prompt := st.chat_input("What kind of class are you looking for?"):
87
  st.session_state.messages.append({"role": "user", "content": prompt})
88
- assistant_response("Yah I'm tired af right now boi")
89
-
90
- for message in st.session_state.messages:
91
- with st.chat_message(message["role"]):
92
  st.markdown(message["content"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
 
95
 
 
54
  )
55
 
56
 
 
 
 
 
 
 
57
  assistant = st.chat_message("assistant")
58
  initial_message = "How can I help you today?"
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  if "messages" not in st.session_state:
61
  st.session_state.messages = []
62
+ with st.chat_message("assistant"):
63
+ st.markdown(initial_message)
64
+ st.session_state.messages.append({"role": "assistant", "content": initial_message})
65
+
66
 
67
  if prompt := st.chat_input("What kind of class are you looking for?"):
68
  st.session_state.messages.append({"role": "user", "content": prompt})
69
+ with st.chat_message("user"):
 
 
 
70
  st.markdown(message["content"])
71
+
72
+ with st.chat_message("assistant"):
73
+ message_placeholder = st.empty()
74
+ full_response = ""
75
+ response = filter_agent(prompt, OPENAI_API)
76
+ query = response
77
+ response = index.query(
78
+ vector = embeddings.embed_query(query),
79
+ top_k = 25,
80
+ include_metadata = True
81
+ )
82
+ response = reranker(query, response)
83
+ result_query = 'Original Query:' + query + 'Query Results:' + str(response)
84
+ assistant_response = results_agent(result_query, OPENAI_API)
85
+
86
+ for chunk in assistant_response.split():
87
+ full_response += chunk + " "
88
+ time.sleep(0.05)
89
+ message_placeholder.markdown(full_response + "▌")
90
+ message_placeholder.markdown(full_response)
91
+ st.session_state.messages.append({"role": "assistant", "content": full_response})
92
 
93
 
94