dygoo commited on
Commit
63b8e63
Β·
verified Β·
1 Parent(s): 3c6afdf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -20
app.py CHANGED
@@ -64,34 +64,30 @@ Provide full names with their roles/titles where mentioned."""
64
  # --- Pipeline Function with Progress & Status ---
65
  def process_name_with_progress(name: str, progress=gr.Progress(track_tqdm=True)):
66
  if not name.strip():
67
- yield "", "", "", "Please enter a name."
68
-
69
- search_results = ""
70
- entities = ""
71
- full_names = ""
72
 
73
  try:
74
  progress(0.1)
75
- status = "πŸ” Searching for articles..."
 
76
  search_results = search_articles(name.strip())
77
- yield search_results, "", "", status
78
-
79
  progress(0.4)
80
- status = "πŸ“„ Extracting entities from articles..."
81
- entities = extract_entities(search_results)
82
- yield search_results, entities, "", status
83
 
 
84
  progress(0.7)
85
- status = "🧠 Finding full names and roles..."
86
- full_names = find_full_names(search_results, entities)
87
- yield search_results, entities, full_names, status
88
 
 
89
  progress(1.0)
90
  yield search_results, entities, full_names, "βœ… Complete!"
91
 
92
  except Exception as e:
93
  err = f"❌ Error: {str(e)}"
94
- yield search_results or err, entities or err, full_names or err, err
 
 
 
95
 
96
  # --- Gradio Interface ---
97
  with gr.Blocks(title="Name Research Tool") as demo:
@@ -100,9 +96,7 @@ with gr.Blocks(title="Name Research Tool") as demo:
100
 
101
  with gr.Row():
102
  name_input = gr.Textbox(label="Name", placeholder="Enter business or project name")
103
- with gr.Column():
104
- search_btn = gr.Button("Search (Real-time)", variant="primary")
105
- debug_btn = gr.Button("Search (Debug Mode)", variant="secondary")
106
 
107
  with gr.Column():
108
  output1 = gr.Textbox(label="Search Results", lines=10, max_lines=20)
@@ -110,7 +104,7 @@ with gr.Blocks(title="Name Research Tool") as demo:
110
  output3 = gr.Textbox(label="Full Names", lines=5, max_lines=10)
111
  status_output = gr.Textbox(label="Status / Progress", lines=1, interactive=False)
112
 
113
- # Real-time search with progress
114
  search_btn.click(
115
  fn=process_name_with_progress,
116
  inputs=[name_input],
@@ -119,4 +113,3 @@ with gr.Blocks(title="Name Research Tool") as demo:
119
 
120
  if __name__ == "__main__":
121
  demo.launch()
122
-
 
64
  # --- Pipeline Function with Progress & Status ---
65
  def process_name_with_progress(name: str, progress=gr.Progress(track_tqdm=True)):
66
  if not name.strip():
67
+ return "", "", "", "Please enter a name."
 
 
 
 
68
 
69
  try:
70
  progress(0.1)
71
+ yield "", "", "", "πŸ” Searching for articles..."
72
+
73
  search_results = search_articles(name.strip())
 
 
74
  progress(0.4)
75
+ yield search_results, "", "", "πŸ“„ Extracting entities from articles..."
 
 
76
 
77
+ entities = extract_entities(search_results)
78
  progress(0.7)
79
+ yield search_results, entities, "", "🧠 Finding full names and roles..."
 
 
80
 
81
+ full_names = find_full_names(search_results, entities)
82
  progress(1.0)
83
  yield search_results, entities, full_names, "βœ… Complete!"
84
 
85
  except Exception as e:
86
  err = f"❌ Error: {str(e)}"
87
+ yield search_results if 'search_results' in locals() else "", \
88
+ entities if 'entities' in locals() else "", \
89
+ full_names if 'full_names' in locals() else "", \
90
+ err
91
 
92
  # --- Gradio Interface ---
93
  with gr.Blocks(title="Name Research Tool") as demo:
 
96
 
97
  with gr.Row():
98
  name_input = gr.Textbox(label="Name", placeholder="Enter business or project name")
99
+ search_btn = gr.Button("Search", variant="primary")
 
 
100
 
101
  with gr.Column():
102
  output1 = gr.Textbox(label="Search Results", lines=10, max_lines=20)
 
104
  output3 = gr.Textbox(label="Full Names", lines=5, max_lines=10)
105
  status_output = gr.Textbox(label="Status / Progress", lines=1, interactive=False)
106
 
107
+ # Search with progress
108
  search_btn.click(
109
  fn=process_name_with_progress,
110
  inputs=[name_input],
 
113
 
114
  if __name__ == "__main__":
115
  demo.launch()