-
Notifications
You must be signed in to change notification settings - Fork 0
fix: restore hybrid search and patch MCP/embedding bugs #2
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
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| HF_TOKEN= | ||
| CONTEXT8_DB_HOST=localhost | ||
| CONTEXT8_DB_PORT=50051 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,6 @@ Thumbs.db | |
| # Models cache | ||
| .cache/ | ||
| models/ | ||
|
|
||
|
|
||
| .env | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,39 +97,40 @@ def _handle_browse(args: dict) -> list[TextContent]: | |
| from ..storage import StorageService | ||
|
|
||
| storage = StorageService() | ||
| try: | ||
| records = browse( | ||
| storage, | ||
| tag=args.get("tag"), | ||
| language=args.get("language"), | ||
| framework=args.get("framework"), | ||
| error_type=args.get("error_type"), | ||
| limit=args.get("limit", 20), | ||
| ) | ||
|
|
||
| if not records: | ||
| return [TextContent(type="text", text="No records match those filters.")] | ||
|
|
||
| lines = [f"Found {len(records)} record(s):\n"] | ||
| for i, r in enumerate(records, 1): | ||
| meta = [] | ||
| if r.language: | ||
| meta.append(r.language) | ||
| if r.framework: | ||
| meta.append(r.framework) | ||
| if r.error_type: | ||
| meta.append(r.error_type) | ||
| meta_str = f" ({', '.join(meta)})" if meta else "" | ||
|
|
||
| lines.append(f"[{i}] {r.problem_text[:120]}{meta_str}") | ||
| lines.append(f" Fix: {r.solution_text[:150]}") | ||
| if r.tags: | ||
| lines.append(f" Tags: {', '.join(r.tags[:5])}") | ||
| lines.append(f" ID: {r.id} Confidence: {r.confidence:.0%}") | ||
| lines.append("") | ||
|
|
||
| records = browse( | ||
| storage, | ||
| tag=args.get("tag"), | ||
| language=args.get("language"), | ||
| framework=args.get("framework"), | ||
| error_type=args.get("error_type"), | ||
| limit=args.get("limit", 20), | ||
| ) | ||
|
|
||
| if not records: | ||
| return [TextContent(type="text", text="No records match those filters.")] | ||
|
|
||
| lines = [f"Found {len(records)} record(s):\n"] | ||
| for i, r in enumerate(records, 1): | ||
| meta = [] | ||
| if r.language: | ||
| meta.append(r.language) | ||
| if r.framework: | ||
| meta.append(r.framework) | ||
| if r.error_type: | ||
| meta.append(r.error_type) | ||
| meta_str = f" ({', '.join(meta)})" if meta else "" | ||
|
|
||
| lines.append(f"[{i}] {r.problem_text[:120]}{meta_str}") | ||
| lines.append(f" Fix: {r.solution_text[:150]}") | ||
| if r.tags: | ||
| lines.append(f" Tags: {', '.join(r.tags[:5])}") | ||
| lines.append(f" ID: {r.id} Confidence: {r.confidence:.0%}") | ||
| lines.append("") | ||
|
|
||
| storage.close() | ||
| return [TextContent(type="text", text="\n".join(lines))] | ||
| return [TextContent(type="text", text="\n".join(lines))] | ||
| finally: | ||
| storage.close() | ||
|
Comment on lines
99
to
+133
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same gRPC leak still present in The try/finally fix here is correct and covers both the empty-records early return and any exception during 🛡️ Proposed fix for `_handle_ecosystem` def _handle_ecosystem(args: dict) -> list[TextContent]:
from ..browse import browse
from ..storage import StorageService
storage = StorageService()
+ try:
+ languages = args.get("languages", [])
+ frameworks = args.get("frameworks", [])
+ limit = args.get("limit", 10)
- languages = args.get("languages", [])
- frameworks = args.get("frameworks", [])
- limit = args.get("limit", 10)
+ all_records = []
+ seen_ids: set[str] = set()
- all_records = []
- seen_ids: set[str] = set()
+ for lang in languages:
+ records = browse(storage, language=lang, limit=limit)
+ for r in records:
+ if r.id not in seen_ids:
+ all_records.append(r)
+ seen_ids.add(r.id)
- # Collect records across all specified languages and frameworks
- for lang in languages:
- records = browse(storage, language=lang, limit=limit)
- for r in records:
- if r.id not in seen_ids:
- all_records.append(r)
- seen_ids.add(r.id)
-
- for fw in frameworks:
- records = browse(storage, framework=fw, limit=limit)
- for r in records:
- if r.id not in seen_ids:
- all_records.append(r)
- seen_ids.add(r.id)
-
- storage.close()
+ for fw in frameworks:
+ records = browse(storage, framework=fw, limit=limit)
+ for r in records:
+ if r.id not in seen_ids:
+ all_records.append(r)
+ seen_ids.add(r.id)
+ finally:
+ storage.close()(The remainder of the function, which only formats 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| def _handle_ecosystem(args: dict) -> list[TextContent]: | ||
|
|
||
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.
suggestion: Ruff might be better scoped as a dev-only dependency instead of a runtime dependency.
Including
ruffindependencieswill install it in all production environments, even though it’s only needed for linting. Unless there’s a runtime requirement, please move it to a dev/extra group (e.g.,devorlint) to avoid bloating production installs.