Skip to content

Commit a8743a7

Browse files
committed
refactor: apply PR feedback for result filtering
- Refactored `condensed_results` for loop into a more concise, idiomatic list comprehension
1 parent a2c6857 commit a8743a7

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

backend/python/src/handlers/process_run.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,15 @@ def filter_results(results: list, query: str, groq_api_key: str) -> list:
119119
print(f"Filtering {len(results)} results using LLM...")
120120

121121
# Prepare a condensed list of results for the LLM to save tokens
122-
condensed_results = []
123-
for i, r in enumerate(results):
124-
condensed_results.append(
125-
{
126-
"index": i,
127-
"title": r.get("title", ""),
128-
"snippet": r.get("snippet", r.get("description", "")),
129-
"domain": parse_domain(r.get("link", r.get("website", ""))),
130-
}
131-
)
122+
condensed_results = [
123+
{
124+
"index": i,
125+
"title": r.get("title", ""),
126+
"snippet": r.get("snippet", r.get("description", "")),
127+
"domain": parse_domain(r.get("link", r.get("website", ""))),
128+
}
129+
for i, r in enumerate(results)
130+
]
132131

133132
prompt = f"""
134133
The user is looking for companies matching: {json.dumps(query)}

0 commit comments

Comments
 (0)