Spaces:
Runtime error
Runtime error
changing the name of the query funtcion
Browse files- app.py +9 -11
- utils/haystack.py +1 -2
app.py
CHANGED
@@ -7,7 +7,6 @@ import requests
|
|
7 |
|
8 |
import streamlit as st
|
9 |
|
10 |
-
from utils.haystack import query, start_haystack
|
11 |
from utils.ui import reset_results, set_initial_state, sidebar
|
12 |
from utils.config import TWITTER_BEARER_TOKEN, SERPER_KEY, OPENAI_API_KEY
|
13 |
|
@@ -38,16 +37,15 @@ run_query = (
|
|
38 |
if run_query and question:
|
39 |
reset_results()
|
40 |
st.session_state.question = question
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
st.error("π An error occurred during the request.")
|
51 |
|
52 |
if st.session_state.result:
|
53 |
result = st.session_state.result
|
|
|
7 |
|
8 |
import streamlit as st
|
9 |
|
|
|
10 |
from utils.ui import reset_results, set_initial_state, sidebar
|
11 |
from utils.config import TWITTER_BEARER_TOKEN, SERPER_KEY, OPENAI_API_KEY
|
12 |
|
|
|
37 |
if run_query and question:
|
38 |
reset_results()
|
39 |
st.session_state.question = question
|
40 |
+
try:
|
41 |
+
st.session_state.result = run_agent(agent, question)
|
42 |
+
except JSONDecodeError as je:
|
43 |
+
st.error(
|
44 |
+
"π An error occurred reading the results. Is the document store working?"
|
45 |
+
)
|
46 |
+
except Exception as e:
|
47 |
+
logging.exception(e)
|
48 |
+
st.error("π An error occurred during the request.")
|
|
|
49 |
|
50 |
if st.session_state.result:
|
51 |
result = st.session_state.result
|
utils/haystack.py
CHANGED
@@ -36,10 +36,9 @@ def start_haystack(openai_key, twitter_bearer, serper_key, last_k_tweets):
|
|
36 |
|
37 |
|
38 |
@st.cache_data(show_spinner=True)
|
39 |
-
def
|
40 |
try:
|
41 |
result = _agent.run(question)
|
42 |
except Exception as e:
|
43 |
-
print(e)
|
44 |
result = ["Life isn't ideal sometimes and this Agent fails at doing a good job.. Maybe try another query..."]
|
45 |
return result
|
|
|
36 |
|
37 |
|
38 |
@st.cache_data(show_spinner=True)
|
39 |
+
def run_agent(_agent, question):
|
40 |
try:
|
41 |
result = _agent.run(question)
|
42 |
except Exception as e:
|
|
|
43 |
result = ["Life isn't ideal sometimes and this Agent fails at doing a good job.. Maybe try another query..."]
|
44 |
return result
|