Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ def chat_with_ai(message):
|
|
14 |
if response.status_code == 200:
|
15 |
return response.json().get('response') # Access 'response' key
|
16 |
else:
|
17 |
-
return {"error": "Failed to get a response from the AI API."}
|
18 |
except requests.RequestException as e:
|
19 |
return {"error": f"Error: {e}"}
|
20 |
|
@@ -31,23 +31,26 @@ def web_search(query):
|
|
31 |
|
32 |
# Main function
|
33 |
def main():
|
34 |
-
st.title("HelpingAI Research Assistant")
|
35 |
-
|
36 |
-
query = st.text_input("Enter your research query: ")
|
37 |
-
|
38 |
-
|
|
|
39 |
if query:
|
40 |
-
|
41 |
-
|
|
|
42 |
|
43 |
# Pass the search results to the AI for generating a report
|
44 |
-
prompt = f"Generate a research report based on the following
|
45 |
-
|
|
|
46 |
|
47 |
# Display the report
|
48 |
st.write(report)
|
49 |
else:
|
50 |
-
st.
|
51 |
|
52 |
if __name__ == "__main__":
|
53 |
main()
|
|
|
14 |
if response.status_code == 200:
|
15 |
return response.json().get('response') # Access 'response' key
|
16 |
else:
|
17 |
+
return {"error": "Failed to get a response from the AI API. π"}
|
18 |
except requests.RequestException as e:
|
19 |
return {"error": f"Error: {e}"}
|
20 |
|
|
|
31 |
|
32 |
# Main function
|
33 |
def main():
|
34 |
+
st.title("π HelpingAI Research Assistant")
|
35 |
+
st.sidebar.header("π οΈ Settings")
|
36 |
+
query = st.sidebar.text_input("π Enter your research query: ")
|
37 |
+
generate_report = st.sidebar.button("π Generate Report")
|
38 |
+
|
39 |
+
if generate_report:
|
40 |
if query:
|
41 |
+
with st.spinner('π Searching...'):
|
42 |
+
# Perform web search
|
43 |
+
search_results = web_search(query)
|
44 |
|
45 |
# Pass the search results to the AI for generating a report
|
46 |
+
prompt = f"Generate a research report based on the following information: {search_results}. If the search results are insufficient, answer the user's question using the information available."
|
47 |
+
with st.spinner('π Generating report...'):
|
48 |
+
report = chat_with_ai(prompt)
|
49 |
|
50 |
# Display the report
|
51 |
st.write(report)
|
52 |
else:
|
53 |
+
st.sidebar.error("β Please enter a research query.")
|
54 |
|
55 |
if __name__ == "__main__":
|
56 |
main()
|