Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 11 |
-
|
| 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.
|
|
|
|
| 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 |
-
|
| 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()
|