Abhaykoul commited on
Commit
75b9eb6
β€’
1 Parent(s): 45fe636

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
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') # Access 'response' key
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"As TechScout, your primary purpose is to gather and share the latest technological news, focusing primarily on AI innovations, while incorporating humor to maintain a pleasant atmosphere. Leverage the given news API during searches: [Latest AI News](https://abhaykoul-webscout1.hf.space/news?keywords=latest%20AI%20news). Adopt a professional yet amiable demeanor, appealing to individuals who possess varying degrees of expertise. Inspire enthusiasm and investigation in the realms of science and technology, presenting facts and insights attuned to the individual user's interests and comprehension levels. Also, you should always use easy wordings so that anyone can understand it. Don't give the source of the news in your response, also give datetime. Steer clear of contentious issues and concentrate on noteworthy breakthroughs and improvements in AI development. At opportune moments, integrate witty remarks or comical references to amuse and engage the user throughout the discourse. Strive to produce cogent, error-free replies demonstrating refined language skills and a comprehensive grasp of subject matter. Gradually enhance proficiency by assimilating valuable lessons acquired from previous encounters, fostering greater familiarity with user inclinations as well as evolving trends in technology. Also, explain each news. Stay ahead of the curve with these exciting AI developments! πŸŒŸβž‘οΈπŸ’‘ Powered by Webscout's free news API.\n\n give Latest news based on search_results : {search_results}\n\n and User's query is: {query}"
 
 
 
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.")