Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,10 +7,6 @@ api_key = "sk-or-v1-5b41e7106feb9b982d4ef5a6aa0959993387ba2e5fc9830df1279418776e
|
|
7 |
|
8 |
openai_client = OpenAI(base_url="https://openrouter.ai/api/v1",api_key=api_key)
|
9 |
|
10 |
-
prompt_input_area = st.empty()
|
11 |
-
prompt_btn_area = st.empty()
|
12 |
-
output = st.empty()
|
13 |
-
|
14 |
prompt_template = """Answer the question only according to the information provided below. Answer only the user's question, dont give additional information.
|
15 |
## Information :
|
16 |
{}
|
@@ -38,10 +34,11 @@ if st.session_state.stage == "crawl-input":
|
|
38 |
st.session_state.stage = "remove-crawl-input-widgets"
|
39 |
|
40 |
if st.session_state.stage == "prompt-input":
|
41 |
-
prompt =
|
42 |
-
prompt_btn = prompt_btn_area.button("Enter")
|
43 |
|
44 |
-
if prompt
|
|
|
|
|
45 |
results = st.session_state.collection.query(query_texts=[prompt],n_results=5)
|
46 |
infos = results["documents"][0]
|
47 |
|
@@ -57,5 +54,9 @@ if st.session_state.stage == "prompt-input":
|
|
57 |
extra_body={},
|
58 |
model="deepseek/deepseek-r1:free",
|
59 |
messages=[{"role":"user","content":prompt}])
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
openai_client = OpenAI(base_url="https://openrouter.ai/api/v1",api_key=api_key)
|
9 |
|
|
|
|
|
|
|
|
|
10 |
prompt_template = """Answer the question only according to the information provided below. Answer only the user's question, dont give additional information.
|
11 |
## Information :
|
12 |
{}
|
|
|
34 |
st.session_state.stage = "remove-crawl-input-widgets"
|
35 |
|
36 |
if st.session_state.stage == "prompt-input":
|
37 |
+
prompt = st.chat_input("Ask the documentation a question!")
|
|
|
38 |
|
39 |
+
if prompt:
|
40 |
+
with st.chat_message("user"):
|
41 |
+
st.markdown(prompt)
|
42 |
results = st.session_state.collection.query(query_texts=[prompt],n_results=5)
|
43 |
infos = results["documents"][0]
|
44 |
|
|
|
54 |
extra_body={},
|
55 |
model="deepseek/deepseek-r1:free",
|
56 |
messages=[{"role":"user","content":prompt}])
|
57 |
+
|
58 |
+
for chunk in completion.choices[0].message.content.split():
|
59 |
+
full_response += chunk + " "
|
60 |
+
time.sleep(0.05)
|
61 |
+
message_placeholder.markdown(full_response + "▌")
|
62 |
+
message_placeholder.markdown(full_response)
|