mehmet0001 commited on
Commit
b83a14b
·
verified ·
1 Parent(s): db8135f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -16,7 +16,6 @@ prompt_template = """Answer the question only according to the information provi
16
  # {}"""
17
 
18
  st.session_state.messages = []
19
-
20
  if not "stage" in st.session_state:
21
  st.session_state.stage = "crawl-input"
22
  elif st.session_state.stage == "remove-crawl-input-widgets":
@@ -37,15 +36,17 @@ if st.session_state.stage == "crawl-input":
37
  st.session_state.stage = "remove-crawl-input-widgets"
38
 
39
  if st.session_state.stage == "prompt-input":
40
- for message in st.session_state.messages:
41
- with st.chat_message(message["role"]):
42
- st.markdown(message)
43
  prompt = st.chat_input("Ask the documentation a question!")
44
 
45
  if prompt:
46
  with st.chat_message("user"):
47
  st.markdown(prompt)
48
 
 
 
 
 
49
  st.session_state.messages.append({"role":"user","message":prompt})
50
  results = st.session_state.collection.query(query_texts=[prompt],n_results=5)
51
  infos = results["documents"][0]
@@ -62,9 +63,10 @@ if st.session_state.stage == "prompt-input":
62
  extra_body={},
63
  model="deepseek/deepseek-r1:free",
64
  messages=[{"role":"user","content":prompt}])
65
- full_response = ""
66
- message_placeholder = st.empty()
67
  with st.chat_message("assistant"):
 
 
68
  for chunk in completion.choices[0].message.content.split():
69
  full_response += chunk + " "
70
  time.sleep(0.05)
 
16
  # {}"""
17
 
18
  st.session_state.messages = []
 
19
  if not "stage" in st.session_state:
20
  st.session_state.stage = "crawl-input"
21
  elif st.session_state.stage == "remove-crawl-input-widgets":
 
36
  st.session_state.stage = "remove-crawl-input-widgets"
37
 
38
  if st.session_state.stage == "prompt-input":
39
+
 
 
40
  prompt = st.chat_input("Ask the documentation a question!")
41
 
42
  if prompt:
43
  with st.chat_message("user"):
44
  st.markdown(prompt)
45
 
46
+ for message in st.session_state.messages:
47
+ with st.chat_message(message["role"]):
48
+ st.markdown(message)
49
+
50
  st.session_state.messages.append({"role":"user","message":prompt})
51
  results = st.session_state.collection.query(query_texts=[prompt],n_results=5)
52
  infos = results["documents"][0]
 
63
  extra_body={},
64
  model="deepseek/deepseek-r1:free",
65
  messages=[{"role":"user","content":prompt}])
66
+
 
67
  with st.chat_message("assistant"):
68
+ full_response = ""
69
+ message_placeholder = st.empty()
70
  for chunk in completion.choices[0].message.content.split():
71
  full_response += chunk + " "
72
  time.sleep(0.05)