dygoo commited on
Commit
6e54f33
·
verified ·
1 Parent(s): 45ed981

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -125,7 +125,7 @@ def search_articles(name: str, max_articles: int = 2) -> str:
125
 
126
  return f"[INFO] No articles found for {name}"
127
 
128
- def extract_entities(search_results: str) -> str:
129
  """Extract entities using Claude 4"""
130
  MAX_CHARS = 8000
131
  if len(search_results) > MAX_CHARS:
@@ -133,11 +133,13 @@ def extract_entities(search_results: str) -> str:
133
  last_period = trunc.rfind('. ')
134
  search_results = trunc[:last_period + 1] if last_period > 3000 else trunc
135
 
136
- prompt = f"""Extract all named entities that are described as founders of the searched business from the following text.
 
 
137
  Return a JSON object with the following two keys:
138
- - "people": a list of names of people mentioned
139
  - "organizations": a list of organization names mentioned
140
- Respond only with valid JSON. Do not include any explanations, comments, or additional formatting. Double check that you included all founders. Double check that the founders you included are indeed founders of the business described in the search.
141
  Text:
142
  {search_results}"""
143
 
@@ -176,13 +178,16 @@ def search_only(name: str, article_count: int):
176
  except Exception as e:
177
  return f"[ERROR] Search failed: {str(e)}", ""
178
 
179
- def extract_only(stored_results: str):
180
  if not stored_results.strip():
181
  return "No search results available. Please search first."
 
 
 
182
 
183
  try:
184
  start = time.time()
185
- entities = extract_entities(stored_results)
186
  elapsed = time.time() - start
187
  return f"✅ Extraction completed in {elapsed:.1f}s\n\n{entities}"
188
  except Exception as e:
@@ -220,13 +225,11 @@ with gr.Blocks(title="Founder Finder") as demo:
220
 
221
  extract_btn.click(
222
  fn=extract_only,
223
- inputs=[search_state],
224
  outputs=[output2]
225
  )
226
 
227
  if __name__ == "__main__":
228
  demo.launch()
229
 
230
-
231
-
232
 
 
125
 
126
  return f"[INFO] No articles found for {name}"
127
 
128
+ def extract_entities(search_results: str, company_name: str) -> str:
129
  """Extract entities using Claude 4"""
130
  MAX_CHARS = 8000
131
  if len(search_results) > MAX_CHARS:
 
133
  last_period = trunc.rfind('. ')
134
  search_results = trunc[:last_period + 1] if last_period > 3000 else trunc
135
 
136
+ prompt = f"""Extract all named entities that are described as founders of "{company_name}" specifically from the following text.
137
+ Only include founders who are explicitly mentioned as founders of {company_name}.
138
+ Ignore founders of other companies that may be mentioned in the text.
139
  Return a JSON object with the following two keys:
140
+ - "people": a list of names of people mentioned as founders of {company_name}
141
  - "organizations": a list of organization names mentioned
142
+ Respond only with valid JSON. Do not include any explanations, comments, or additional formatting. Double check that you included all founders. Double check that the founders you included are indeed founders of {company_name}.
143
  Text:
144
  {search_results}"""
145
 
 
178
  except Exception as e:
179
  return f"[ERROR] Search failed: {str(e)}", ""
180
 
181
+ def extract_only(stored_results: str, company_name: str):
182
  if not stored_results.strip():
183
  return "No search results available. Please search first."
184
+
185
+ if not company_name.strip():
186
+ return "No company name provided. Please search first."
187
 
188
  try:
189
  start = time.time()
190
+ entities = extract_entities(stored_results, company_name.strip())
191
  elapsed = time.time() - start
192
  return f"✅ Extraction completed in {elapsed:.1f}s\n\n{entities}"
193
  except Exception as e:
 
225
 
226
  extract_btn.click(
227
  fn=extract_only,
228
+ inputs=[search_state, name_input],
229
  outputs=[output2]
230
  )
231
 
232
  if __name__ == "__main__":
233
  demo.launch()
234
 
 
 
235