code-finder 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- claude_context/__init__.py +33 -0
- claude_context/agentic_integration.py +309 -0
- claude_context/ast_chunker.py +646 -0
- claude_context/config.py +239 -0
- claude_context/context_manager.py +627 -0
- claude_context/embeddings.py +307 -0
- claude_context/embeddings_interface.py +226 -0
- claude_context/enhanced_ast_chunker.py +1129 -0
- claude_context/explorer.py +951 -0
- claude_context/explorer_with_context.py +1008 -0
- claude_context/indexer.py +893 -0
- claude_context/markdown_chunker.py +421 -0
- claude_context/mode_handler.py +1774 -0
- claude_context/query_metrics.py +164 -0
- claude_context/question_generator.py +800 -0
- claude_context/readme_extractor.py +485 -0
- claude_context/repository_adapter.py +399 -0
- claude_context/search.py +493 -0
- claude_context/skills/__init__.py +11 -0
- claude_context/skills/_cli_common.py +74 -0
- claude_context/skills/_index_manager.py +98 -0
- claude_context/skills/api_surface.py +219 -0
- claude_context/skills/evidence_retrieval.py +151 -0
- claude_context/skills/grounded_review.py +212 -0
- claude_context/synthesis/__init__.py +8 -0
- claude_context/synthesis/editor_agent.py +391 -0
- claude_context/synthesis/llm_synthesizer.py +153 -0
- claude_context/synthesis/logic_explainer.py +235 -0
- claude_context/synthesis/multi_review_pipeline.py +717 -0
- claude_context/synthesis/prompt_builder.py +439 -0
- claude_context/synthesis/providers.py +115 -0
- claude_context/synthesis/validators.py +458 -0
- code_finder-0.1.0.dist-info/METADATA +823 -0
- code_finder-0.1.0.dist-info/RECORD +37 -0
- code_finder-0.1.0.dist-info/WHEEL +5 -0
- code_finder-0.1.0.dist-info/entry_points.txt +4 -0
- code_finder-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Query Interpretation Metrics
|
|
3
|
+
|
|
4
|
+
Tracks the performance and effectiveness of LLM-based query interpretation
|
|
5
|
+
to measure impact on documentation quality.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from typing import Dict, Any, List
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class QueryMetrics:
|
|
17
|
+
"""
|
|
18
|
+
Track query interpretation quality and success rates.
|
|
19
|
+
|
|
20
|
+
Used to monitor whether enhanced LLM interpretation improves
|
|
21
|
+
documentation quality by finding more relevant code.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
# Basic counts
|
|
25
|
+
questions_asked: int = 0
|
|
26
|
+
llm_interpretations: int = 0
|
|
27
|
+
results_found_after_llm: int = 0
|
|
28
|
+
|
|
29
|
+
# Quality metrics
|
|
30
|
+
total_confidence: float = 0.0
|
|
31
|
+
|
|
32
|
+
# Domain breakdown (for analysis)
|
|
33
|
+
ai_ml_questions: int = 0
|
|
34
|
+
k8s_questions: int = 0
|
|
35
|
+
web_questions: int = 0
|
|
36
|
+
cli_questions: int = 0
|
|
37
|
+
general_questions: int = 0
|
|
38
|
+
|
|
39
|
+
# Track interpretations for detailed analysis
|
|
40
|
+
interpretation_log: List[Dict] = field(default_factory=list)
|
|
41
|
+
|
|
42
|
+
def log_question(self, question: str, used_llm: bool, results_count: int, confidence: float):
|
|
43
|
+
"""
|
|
44
|
+
Log a question and its outcome.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
question: The question asked
|
|
48
|
+
used_llm: Whether LLM interpretation was used
|
|
49
|
+
results_count: Number of results found
|
|
50
|
+
confidence: Confidence score of the answer
|
|
51
|
+
"""
|
|
52
|
+
self.questions_asked += 1
|
|
53
|
+
self.total_confidence += confidence
|
|
54
|
+
|
|
55
|
+
if used_llm:
|
|
56
|
+
self.llm_interpretations += 1
|
|
57
|
+
if results_count > 0:
|
|
58
|
+
self.results_found_after_llm += 1
|
|
59
|
+
|
|
60
|
+
# Classify by domain (simple keyword matching)
|
|
61
|
+
question_lower = question.lower()
|
|
62
|
+
|
|
63
|
+
if any(term in question_lower for term in [
|
|
64
|
+
"quantization", "quantize", "model", "training", "inference",
|
|
65
|
+
"pruning", "distillation", "neural", "transformer"
|
|
66
|
+
]):
|
|
67
|
+
self.ai_ml_questions += 1
|
|
68
|
+
domain = "ai_ml"
|
|
69
|
+
elif any(term in question_lower for term in [
|
|
70
|
+
"kubernetes", "kubectl", "operator", "crd", "configmap",
|
|
71
|
+
"pod", "deployment", "namespace"
|
|
72
|
+
]):
|
|
73
|
+
self.k8s_questions += 1
|
|
74
|
+
domain = "k8s"
|
|
75
|
+
elif any(term in question_lower for term in [
|
|
76
|
+
"route", "endpoint", "api", "request", "response",
|
|
77
|
+
"middleware", "handler"
|
|
78
|
+
]):
|
|
79
|
+
self.web_questions += 1
|
|
80
|
+
domain = "web"
|
|
81
|
+
elif any(term in question_lower for term in [
|
|
82
|
+
"command", "cli", "flag", "option", "subcommand"
|
|
83
|
+
]):
|
|
84
|
+
self.cli_questions += 1
|
|
85
|
+
domain = "cli"
|
|
86
|
+
else:
|
|
87
|
+
self.general_questions += 1
|
|
88
|
+
domain = "general"
|
|
89
|
+
|
|
90
|
+
# Store for detailed analysis
|
|
91
|
+
self.interpretation_log.append({
|
|
92
|
+
"question": question[:100], # Truncate for storage
|
|
93
|
+
"domain": domain,
|
|
94
|
+
"used_llm": used_llm,
|
|
95
|
+
"results_count": results_count,
|
|
96
|
+
"confidence": confidence
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
# Keep log size manageable (last 100 questions)
|
|
100
|
+
if len(self.interpretation_log) > 100:
|
|
101
|
+
self.interpretation_log = self.interpretation_log[-100:]
|
|
102
|
+
|
|
103
|
+
def get_success_rate(self) -> float:
|
|
104
|
+
"""
|
|
105
|
+
Calculate success rate of LLM interpretations.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
Percentage of LLM interpretations that found results (0.0-1.0)
|
|
109
|
+
"""
|
|
110
|
+
if self.llm_interpretations == 0:
|
|
111
|
+
return 0.0
|
|
112
|
+
return self.results_found_after_llm / self.llm_interpretations
|
|
113
|
+
|
|
114
|
+
def get_avg_confidence(self) -> float:
|
|
115
|
+
"""Get average confidence across all questions."""
|
|
116
|
+
if self.questions_asked == 0:
|
|
117
|
+
return 0.0
|
|
118
|
+
return self.total_confidence / self.questions_asked
|
|
119
|
+
|
|
120
|
+
def get_summary(self) -> Dict[str, Any]:
|
|
121
|
+
"""
|
|
122
|
+
Get comprehensive metrics summary.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
Dictionary with all metrics and analysis
|
|
126
|
+
"""
|
|
127
|
+
return {
|
|
128
|
+
"total_questions": self.questions_asked,
|
|
129
|
+
"llm_interpretations": self.llm_interpretations,
|
|
130
|
+
"llm_success_rate": self.get_success_rate(),
|
|
131
|
+
"avg_confidence": self.get_avg_confidence(),
|
|
132
|
+
"domain_breakdown": {
|
|
133
|
+
"ai_ml": self.ai_ml_questions,
|
|
134
|
+
"k8s": self.k8s_questions,
|
|
135
|
+
"web": self.web_questions,
|
|
136
|
+
"cli": self.cli_questions,
|
|
137
|
+
"general": self.general_questions
|
|
138
|
+
},
|
|
139
|
+
"llm_usage_rate": self.llm_interpretations / self.questions_asked if self.questions_asked > 0 else 0.0
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
def print_report(self):
|
|
143
|
+
"""Print human-readable metrics report."""
|
|
144
|
+
summary = self.get_summary()
|
|
145
|
+
|
|
146
|
+
print("\n" + "="*60)
|
|
147
|
+
print("Query Interpretation Metrics")
|
|
148
|
+
print("="*60)
|
|
149
|
+
|
|
150
|
+
print(f"\nQuestions Asked: {summary['total_questions']}")
|
|
151
|
+
print(f"LLM Interpretations Used: {summary['llm_interpretations']} ({summary['llm_usage_rate']:.1%})")
|
|
152
|
+
print(f"LLM Success Rate: {summary['llm_success_rate']:.1%}")
|
|
153
|
+
print(f"Average Confidence: {summary['avg_confidence']:.1%}")
|
|
154
|
+
|
|
155
|
+
print(f"\nDomain Breakdown:")
|
|
156
|
+
for domain, count in summary['domain_breakdown'].items():
|
|
157
|
+
if count > 0:
|
|
158
|
+
print(f" {domain}: {count}")
|
|
159
|
+
|
|
160
|
+
print("="*60 + "\n")
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|