-
Notifications
You must be signed in to change notification settings - Fork 693
Pr 364 updated #392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pr 364 updated #392
Changes from all commits
c094a5b
5d544b1
04ad1c1
4974ccd
d5ac46d
e0133f9
515f29b
f1a0c48
6408f3f
a3b205f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,12 +13,14 @@ | |||||||||||||||||||||||||||||||||||
| from misc.logger.logging_config_helper import get_configured_logger | ||||||||||||||||||||||||||||||||||||
| from core.schemas import create_assistant_result | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| logger = get_configured_logger("who_ranking_engine") | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| DEBUG_PRINT = False | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| class WhoRanking: | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| EARLY_SEND_THRESHOLD = 59 | ||||||||||||||||||||||||||||||||||||
| NUM_RESULTS_TO_SEND = 10 | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
@@ -29,6 +31,7 @@ def __init__(self, handler, items, level="high"): # default to low level for WHO | |||||||||||||||||||||||||||||||||||
| self.items = items | ||||||||||||||||||||||||||||||||||||
| self.num_results_sent = 0 | ||||||||||||||||||||||||||||||||||||
| self.rankedAnswers = [] | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def get_ranking_prompt(self, query, site_description): | ||||||||||||||||||||||||||||||||||||
|
|
@@ -48,81 +51,107 @@ def get_ranking_prompt(self, query, site_description): | |||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| The site's description is: {site_description} | ||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| response_structure = { | ||||||||||||||||||||||||||||||||||||
| "score": "integer between 0 and 100", | ||||||||||||||||||||||||||||||||||||
| "description": "short description of why this site is relevant", | ||||||||||||||||||||||||||||||||||||
| "query": "the optimized query to send to this site (only if score > 70)" | ||||||||||||||||||||||||||||||||||||
| "query": "the optimized query to send to this site (only if score > 70)", | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| return prompt, response_structure | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| async def rankItem(self, url, json_str, name, site): | ||||||||||||||||||||||||||||||||||||
| """Rank a single site for relevance to the query.""" | ||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||
| description = trim_json(json_str) | ||||||||||||||||||||||||||||||||||||
| prompt, ans_struc = self.get_ranking_prompt(self.handler.query, description) | ||||||||||||||||||||||||||||||||||||
| ranking = await ask_llm(prompt, ans_struc, level=self.level, | ||||||||||||||||||||||||||||||||||||
| query_params=self.handler.query_params, timeout=8) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| prompt, ans_struc = self.get_ranking_prompt( | ||||||||||||||||||||||||||||||||||||
| self.handler.query, description | ||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||
| ranking = await ask_llm( | ||||||||||||||||||||||||||||||||||||
| prompt, | ||||||||||||||||||||||||||||||||||||
| ans_struc, | ||||||||||||||||||||||||||||||||||||
| level=self.level, | ||||||||||||||||||||||||||||||||||||
| query_params=self.handler.query_params, | ||||||||||||||||||||||||||||||||||||
| timeout=90, | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| timeout=90, | |
| timeout=30, |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The query field is being set twice with potentially different values. Lines 184-188 set it conditionally based on whether it exists in the ranking, then line 192 unconditionally overwrites it with site_query. This makes lines 183-188 redundant. Either remove lines 183-188 or remove line 192, depending on which behavior is desired.
| # Always include query field (required for WHO ranking) | |
| if "query" in result["ranking"]: | |
| result_item["query"] = result["ranking"]["query"] | |
| else: | |
| # Fallback to original query if no custom query provided | |
| result_item["query"] = self.handler.query |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The minimum score threshold was changed from a hardcoded value of 70 to a configurable value with a default of 51. This is a significant behavioral change that will result in more lower-quality results being included. If this change is intentional, it should be documented. Otherwise, consider using 70 as the default to maintain backward compatibility: getattr(self.handler, 'min_score', 70).
| # Use min_score from handler if available, otherwise default to 51 | |
| min_score_threshold = getattr(self.handler, 'min_score', 51) | |
| # Use min_score from handler if available, otherwise default to 70 (backward compatible) | |
| min_score_threshold = getattr(self.handler, 'min_score', 70) |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The debug print statements at lines 226-233 are now always executed, ignoring the DEBUG_PRINT flag defined at line 19. This means debug output will always be printed to console even when not desired. These print statements should be wrapped in if DEBUG_PRINT: or converted to use the logger instead (e.g., logger.debug(...)).
| print(f"\n=== WHO RANKING: Filtered to {len(filtered)} results with score > {min_score_threshold} ===") | |
| # Print the ranked sites with scores | |
| print("\nRanked sites (top 10):") | |
| for i, r in enumerate(ranked[:max_results], 1): | |
| score = r.get('ranking', {}).get('score', 0) | |
| print(f" {i}. {r['name']} - Score: {score}") | |
| print("=" * 60) | |
| if DEBUG_PRINT: | |
| print(f"\n=== WHO RANKING: Filtered to {len(filtered)} results with score > {min_score_threshold} ===") | |
| # Print the ranked sites with scores | |
| print("\nRanked sites (top 10):") | |
| for i, r in enumerate(ranked[:max_results], 1): | |
| score = r.get('ranking', {}).get('score', 0) | |
| print(f" {i}. {r['name']} - Score: {score}") | |
| print("=" * 60) |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -382,11 +382,20 @@ <h1>Agent Finder</h1> | |||||||||||
| this.eventSource.close(); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| const debugParams = new URLSearchParams(window.location.search); | ||||||||||||
| const queryObj = Object.fromEntries(debugParams.entries()); | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+385
to
+387
|
||||||||||||
| const debugParams = new URLSearchParams(window.location.search); | |
| const queryObj = Object.fromEntries(debugParams.entries()); |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code references this.queryHistory which is never initialized in the constructor. This will cause a runtime error when trying to access .length property on undefined. You need to add this.queryHistory = []; in the constructor method around line 269-277.
| // Add previous queries for context (limit to last 3 queries) | |
| // Add previous queries for context (limit to last 3 queries) | |
| if (!Array.isArray(this.queryHistory)) { | |
| this.queryHistory = []; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scaling the timeout by multiplying by the number of texts (
timeout * len(texts)) could result in excessively long timeouts for large batches. For example, with a default timeout of 30 seconds and 100 texts, this would be 3000 seconds (50 minutes). Consider using a more reasonable scaling factor (e.g.,timeout + (len(texts) * 2)) or capping the maximum timeout to prevent unreasonably long waits.