Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
68 |
-
|
69 |
-
search_results = ""
|
70 |
-
entities = ""
|
71 |
-
full_names = ""
|
72 |
|
73 |
try:
|
74 |
progress(0.1)
|
75 |
-
|
|
|
76 |
search_results = search_articles(name.strip())
|
77 |
-
yield search_results, "", "", status
|
78 |
-
|
79 |
progress(0.4)
|
80 |
-
|
81 |
-
entities = extract_entities(search_results)
|
82 |
-
yield search_results, entities, "", status
|
83 |
|
|
|
84 |
progress(0.7)
|
85 |
-
|
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
|
|
|
|
|
|
|
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 |
-
|
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 |
-
#
|
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()
|
|