Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -28,23 +28,23 @@ if st.session_state.stage == "crawl-input":
|
|
28 |
st.session_state.stage = "prompt-input"
|
29 |
else:
|
30 |
prompt = st.text_area("What would you like to chat about?")
|
31 |
-
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
|
42 |
-
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
|
|
|
28 |
st.session_state.stage = "prompt-input"
|
29 |
else:
|
30 |
prompt = st.text_area("What would you like to chat about?")
|
31 |
+
prompt_btn = st.button("Enter")
|
32 |
|
33 |
+
if prompt and prompt_btn:
|
34 |
+
results = st.session_state.collection.query(query_texts=[prompt],n_results=5)
|
35 |
+
infos = results["documents"][0]
|
36 |
|
37 |
+
info_text = ""
|
38 |
+
for info in infos:
|
39 |
+
info_text += info + "\n---\n"
|
40 |
+
info_text = info_text.strip()
|
41 |
|
42 |
+
prompt = prompt_template.format(info_text,prompt)
|
43 |
|
44 |
+
completion = openai_client.chat.completions.create(
|
45 |
+
extra_headers={},
|
46 |
+
extra_body={},
|
47 |
+
model="deepseek/deepseek-r1:free",
|
48 |
+
messages=[{"role":"user","content":prompt}])
|
49 |
|
50 |
+
st.write((completion.choices[0].message.content)[7:-1])
|