Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ def chat_with_ai(message, user_input):
|
|
13 |
try:
|
14 |
with session.post(api_url, json=payload) as response:
|
15 |
if response.status_code == 200:
|
16 |
-
return response.json().get('response')
|
17 |
else:
|
18 |
st.error("Failed to get a response from the AI API. π")
|
19 |
except requests.RequestException as e:
|
@@ -47,7 +47,10 @@ def main():
|
|
47 |
search_results = web_search(query)
|
48 |
|
49 |
# Prepare prompt based on provided guidelines
|
50 |
-
prompt = f"
|
|
|
|
|
|
|
51 |
|
52 |
# Pass the search results to the AI for generating a report
|
53 |
with st.spinner('π Generating report...'):
|
@@ -57,7 +60,7 @@ def main():
|
|
57 |
if isinstance(report, dict) and 'error' in report:
|
58 |
st.error(report['error'])
|
59 |
else:
|
60 |
-
output.text_area("Generated Report", report, height=600, max_chars=None, key=None)
|
61 |
|
62 |
else:
|
63 |
st.sidebar.error("β Please enter a research query.")
|
|
|
13 |
try:
|
14 |
with session.post(api_url, json=payload) as response:
|
15 |
if response.status_code == 200:
|
16 |
+
return response.json().get('response') # Access 'response' key
|
17 |
else:
|
18 |
st.error("Failed to get a response from the AI API. π")
|
19 |
except requests.RequestException as e:
|
|
|
47 |
search_results = web_search(query)
|
48 |
|
49 |
# Prepare prompt based on provided guidelines
|
50 |
+
prompt = f"User's query: {query}, Search Results: {search_results}. As TechScout, focus on AI innovations, share latest technological news, and maintain a pleasant atmosphere. Adopt a professional yet amiable demeanor, appealing to individuals with varying expertise levels. Inspire enthusiasm and investigation in science and technology, presenting facts and insights tailored to the user's interests. Use easy wordings for broad understanding. Don't include news sources or datetimes. Concentrate on breakthroughs and improvements in AI development. Integrate witty remarks or comical references to engage the user. Produce cogent, error-free replies demonstrating language skills and a comprehensive grasp of the subject. Enhance proficiency by learning from previous encounters and understanding user inclinations and technology trends. Explain each news item. Stay ahead with exciting AI developments! πβ‘οΈπ‘"
|
51 |
+
|
52 |
+
# Outro for the AI to conclude the report
|
53 |
+
outro = "Powered by Webscout's free news API."
|
54 |
|
55 |
# Pass the search results to the AI for generating a report
|
56 |
with st.spinner('π Generating report...'):
|
|
|
60 |
if isinstance(report, dict) and 'error' in report:
|
61 |
st.error(report['error'])
|
62 |
else:
|
63 |
+
output.text_area("Generated Report", report + "\n\n" + outro, height=600, max_chars=None, key=None)
|
64 |
|
65 |
else:
|
66 |
st.sidebar.error("β Please enter a research query.")
|