Satyam0077 commited on
Commit
150c42e
·
verified ·
1 Parent(s): 56ae6d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -7,12 +7,12 @@ import pandas as pd
7
  os.environ['OPENAI_API_KEY'] = 'AIzaSyC8tIrUlJcCRnyksbykluUZVvER6ynHQeI'
8
  os.environ['SERPAPI_API_KEY'] = '533b5ecf4f322a3e1fb6c6341fc922267805add7e804f7783949a17175ed2f69'
9
 
10
- # Define the path for saving CSV files
11
- HUGGING_FACE_FOLDER = 'https://huggingface.co/spaces/Satyam0077/MultiAgentWorkflowAI/tree/main' # Update this to your actual Hugging Face directory
12
- SAVE_DIR = os.path.join(HUGGING_FACE_FOLDER, 'https://huggingface.co/spaces/Satyam0077/MultiAgentWorkflowAI/resolve/main/saved_csv_files')
13
 
14
  # Ensure the save directory exists
15
- os.makedirs(SAVE_DIR, exist_ok=True)
 
16
 
17
  # Define the functions for your workflow
18
  def industry_research(company_name, industry_name):
@@ -42,7 +42,7 @@ def save_results_to_csv(results, company_name):
42
  df = pd.DataFrame(results)
43
  csv_file_path = os.path.join(SAVE_DIR, f"{company_name}_research_results.csv")
44
  df.to_csv(csv_file_path, index=False)
45
- st.success(f"Results saved to {csv_file_path}")
46
 
47
  def main():
48
  st.title("Multi-Agent Workflow for AI Use Cases")
@@ -73,8 +73,10 @@ def main():
73
  for result in research_results:
74
  st.write(f"- [Resource: {result.get('title')}]({result.get('link')})")
75
 
76
- # Save results to CSV
77
- save_results_to_csv(research_results, company_name)
 
 
78
 
79
  else:
80
  st.error("Error: " + research_results['error'])
@@ -82,4 +84,4 @@ def main():
82
  st.warning("Please enter both a company name and an industry name.")
83
 
84
  if __name__ == "__main__":
85
- main()
 
7
  os.environ['OPENAI_API_KEY'] = 'AIzaSyC8tIrUlJcCRnyksbykluUZVvER6ynHQeI'
8
  os.environ['SERPAPI_API_KEY'] = '533b5ecf4f322a3e1fb6c6341fc922267805add7e804f7783949a17175ed2f69'
9
 
10
+ # Define the directory name for saving CSV files
11
+ SAVE_DIR = 'saved_csv_files'
 
12
 
13
  # Ensure the save directory exists
14
+ if not os.path.exists(SAVE_DIR):
15
+ os.makedirs(SAVE_DIR)
16
 
17
  # Define the functions for your workflow
18
  def industry_research(company_name, industry_name):
 
42
  df = pd.DataFrame(results)
43
  csv_file_path = os.path.join(SAVE_DIR, f"{company_name}_research_results.csv")
44
  df.to_csv(csv_file_path, index=False)
45
+ return csv_file_path # Return the file path for download
46
 
47
  def main():
48
  st.title("Multi-Agent Workflow for AI Use Cases")
 
73
  for result in research_results:
74
  st.write(f"- [Resource: {result.get('title')}]({result.get('link')})")
75
 
76
+ # Save results to CSV and provide a download link
77
+ csv_file_path = save_results_to_csv(research_results, company_name)
78
+ with open(csv_file_path, 'rb') as file:
79
+ st.download_button(label="Download CSV", data=file, file_name=os.path.basename(csv_file_path), mime='text/csv')
80
 
81
  else:
82
  st.error("Error: " + research_results['error'])
 
84
  st.warning("Please enter both a company name and an industry name.")
85
 
86
  if __name__ == "__main__":
87
+ main()