Abhaykoul commited on
Commit
9c6d734
1 Parent(s): d5f4461

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -10
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import streamlit as st
2
  import requests
3
- import time
4
 
5
  # Create a session for reusing connections
6
  session = requests.Session()
@@ -26,20 +25,38 @@ def web_search(query):
26
  response = requests.post(url, json=payload)
27
 
28
  if response.status_code == 200:
29
- return response.json()
30
  else:
31
  return {"error": f"Error: {response.status_code}"}
32
 
33
  # Main function
34
  def main():
35
- query = st.text_input("Enter your research query: ")
36
- if query:
37
- # Perform web search
38
- search_results = web_search(query)
39
- # Pass the search results to the AI for generating a report
40
- report = chat_with_ai(search_results)
41
- # Display the report
42
- st.write(report)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  if __name__ == "__main__":
45
  main()
 
1
  import streamlit as st
2
  import requests
 
3
 
4
  # Create a session for reusing connections
5
  session = requests.Session()
 
25
  response = requests.post(url, json=payload)
26
 
27
  if response.status_code == 200:
28
+ return response.json().get('results') # Assuming 'results' contain relevant info
29
  else:
30
  return {"error": f"Error: {response.status_code}"}
31
 
32
  # Main function
33
  def main():
34
+ st.title("AI Research Assistant")
35
+ st.write("This tool helps you generate a research report based on the text obtained from a web search.")
36
+
37
+ query = st.text_area("Enter your search query:", value="", height=200, max_chars=None, key=None)
38
+
39
+ if st.button("Generate Report"):
40
+ if query:
41
+ # Perform web search
42
+ search_results = web_search(query)
43
+
44
+ # Extract relevant information and convert it into a message
45
+ message = "" # Create an empty string to store the message
46
+ for result in search_results:
47
+ # Assuming each result is a string, you might adjust this part accordingly
48
+ message += result + ". " # Concatenate results with a period
49
+
50
+ # Combine prompt and message for AI conversation
51
+ full_message = f"Generate a research report based on the following text: {message}"
52
+
53
+ # Pass the combined message to the AI for generating a report
54
+ report = chat_with_ai(full_message)
55
+
56
+ # Display the report
57
+ st.write(report)
58
+ else:
59
+ st.write("Please enter a search query.")
60
 
61
  if __name__ == "__main__":
62
  main()