Update app.py
Browse files
app.py
CHANGED
@@ -31,9 +31,14 @@ def initialize_gemini(api_key: str):
|
|
31 |
)
|
32 |
return model
|
33 |
|
34 |
-
def google_search_naics(company_name: str) -> List[str]:
|
35 |
-
"""Find potential NAICS codes for a company using Google search"""
|
36 |
-
query
|
|
|
|
|
|
|
|
|
|
|
37 |
naics_codes = set()
|
38 |
|
39 |
try:
|
@@ -166,8 +171,10 @@ def find_naics_code(api_key, company_name, company_description):
|
|
166 |
# Initialize Gemini API
|
167 |
model = initialize_gemini(api_key)
|
168 |
|
169 |
-
# Search for NAICS candidates
|
170 |
-
naics_candidates = google_search_naics(company_name)
|
|
|
|
|
171 |
|
172 |
# Get classification
|
173 |
if not naics_candidates:
|
@@ -191,7 +198,8 @@ def find_naics_code(api_key, company_name, company_description):
|
|
191 |
output += f"**Conclusion:**\n{result['conclusion']}\n\n"
|
192 |
|
193 |
if naics_candidates:
|
194 |
-
output += f"**Candidate NAICS Codes Found from Google:**\n{', '.join(naics_candidates)}"
|
|
|
195 |
|
196 |
return output
|
197 |
|
|
|
31 |
)
|
32 |
return model
|
33 |
|
34 |
+
def google_search_naics(company_name: str, company_description: str = "") -> List[str]:
|
35 |
+
"""Find potential NAICS codes for a company using Google search with enhanced context"""
|
36 |
+
# Create a more effective search query with company description if available
|
37 |
+
if company_description:
|
38 |
+
query = f"2022 NAICS code for \"{company_name}\" {company_description} industry classification"
|
39 |
+
else:
|
40 |
+
query = f"2022 NAICS code for \"{company_name}\" company industry classification"
|
41 |
+
|
42 |
naics_codes = set()
|
43 |
|
44 |
try:
|
|
|
171 |
# Initialize Gemini API
|
172 |
model = initialize_gemini(api_key)
|
173 |
|
174 |
+
# Search for NAICS candidates with company description for better context
|
175 |
+
naics_candidates = google_search_naics(company_name, company_description)
|
176 |
+
# Store search query for reporting
|
177 |
+
search_query = f"2022 NAICS code for \"{company_name}\" {company_description} industry classification" if company_description else f"2022 NAICS code for \"{company_name}\" company industry classification"
|
178 |
|
179 |
# Get classification
|
180 |
if not naics_candidates:
|
|
|
198 |
output += f"**Conclusion:**\n{result['conclusion']}\n\n"
|
199 |
|
200 |
if naics_candidates:
|
201 |
+
output += f"**Candidate NAICS Codes Found from Google:**\n{', '.join(naics_candidates)}\n\n"
|
202 |
+
output += f"*Search query used: \"{search_query}\"*"
|
203 |
|
204 |
return output
|
205 |
|