Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -431,8 +431,11 @@ def create_project_proposals(budget_cluster_df, problem_cluster_df, location_clu
|
|
431 |
|
432 |
# prompt = f"Generate a solution oriented project proposal for the following:\n\nLocation: {location}\nProblem Domain: {problem_domain}\nProblems: {problems_summary}\n\nProject Proposal:"
|
433 |
prompt = f"Generate a solution-oriented project proposal for the following public problem (only output the proposal):\n\n Geographical/Digital Location: {location}\nProblem Category: {problem_domain}\nProblems: {problems_summary}\n\nProject Proposal:"
|
434 |
-
|
435 |
-
|
|
|
|
|
|
|
436 |
else:
|
437 |
print(f"Skipping empty problem descriptions for location: {location}, problem domain: {problem_domain}")
|
438 |
|
@@ -606,14 +609,23 @@ def process_excel(file):
|
|
606 |
consoleMessage_and_Print("Processing the DataFrame...")
|
607 |
processed_df, budget_cluster_df, problem_cluster_df, project_proposals, location_clusters, problem_clusters = nlp_pipeline(df)
|
608 |
# processed_df, budget_cluster_df, problem_cluster_df, location_clusters, problem_clusters = nlp_pipeline(df)
|
|
|
|
|
|
|
|
|
|
|
609 |
|
|
|
610 |
output_filename = "OutPut_PPs.xlsx"
|
611 |
with pd.ExcelWriter(output_filename) as writer:
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
|
|
|
|
|
|
617 |
|
618 |
budget_cluster_df.to_excel(writer, sheet_name='Financial_Weights')
|
619 |
problem_cluster_df.to_excel(writer, sheet_name='Problem_Descriptions')
|
@@ -652,8 +664,8 @@ def process_excel(file):
|
|
652 |
|
653 |
|
654 |
example_files = []
|
655 |
-
example_files.append('#TaxDirection (Responses)_BasicExample.xlsx')
|
656 |
-
|
657 |
# example_files.append('#TaxDirection (Responses)_UltimateExample.xlsx')
|
658 |
|
659 |
|
|
|
431 |
|
432 |
# prompt = f"Generate a solution oriented project proposal for the following:\n\nLocation: {location}\nProblem Domain: {problem_domain}\nProblems: {problems_summary}\n\nProject Proposal:"
|
433 |
prompt = f"Generate a solution-oriented project proposal for the following public problem (only output the proposal):\n\n Geographical/Digital Location: {location}\nProblem Category: {problem_domain}\nProblems: {problems_summary}\n\nProject Proposal:"
|
434 |
+
|
435 |
+
proposal = generate_project_proposal(prompt)
|
436 |
+
# Check if proposal is valid
|
437 |
+
if isinstance(proposal, str) and proposal.strip(): # Valid string that's not empty
|
438 |
+
proposals[(loc, prob)] = proposal
|
439 |
else:
|
440 |
print(f"Skipping empty problem descriptions for location: {location}, problem domain: {problem_domain}")
|
441 |
|
|
|
609 |
consoleMessage_and_Print("Processing the DataFrame...")
|
610 |
processed_df, budget_cluster_df, problem_cluster_df, project_proposals, location_clusters, problem_clusters = nlp_pipeline(df)
|
611 |
# processed_df, budget_cluster_df, problem_cluster_df, location_clusters, problem_clusters = nlp_pipeline(df)
|
612 |
+
|
613 |
+
### Convert project_proposals dictionary to DataFrame
|
614 |
+
project_proposals_df = pd.DataFrame.from_dict(project_proposals, orient='index', columns=['Solutions Proposed'])
|
615 |
+
project_proposals_df.index.names = ['Location_Cluster', 'Problem_Cluster']
|
616 |
+
project_proposals_df.reset_index(inplace=True)
|
617 |
|
618 |
+
consoleMessage_and_Print("Creating the Excel file.")
|
619 |
output_filename = "OutPut_PPs.xlsx"
|
620 |
with pd.ExcelWriter(output_filename) as writer:
|
621 |
+
|
622 |
+
try:
|
623 |
+
project_proposals_df.to_excel(writer, sheet_name='Project_Proposals', index=False)
|
624 |
+
except Exception as e:
|
625 |
+
consoleMessage_and_Print("Error during Project Proposal excelling at the end")
|
626 |
+
|
627 |
+
|
628 |
+
|
629 |
|
630 |
budget_cluster_df.to_excel(writer, sheet_name='Financial_Weights')
|
631 |
problem_cluster_df.to_excel(writer, sheet_name='Problem_Descriptions')
|
|
|
664 |
|
665 |
|
666 |
example_files = []
|
667 |
+
# example_files.append('#TaxDirection (Responses)_BasicExample.xlsx')
|
668 |
+
example_files.append('#TaxDirection (Responses)_IntermediateExample.xlsx')
|
669 |
# example_files.append('#TaxDirection (Responses)_UltimateExample.xlsx')
|
670 |
|
671 |
|