empathy-framework 4.6.3__py3-none-any.whl → 4.6.5__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.
Files changed (65) hide show
  1. {empathy_framework-4.6.3.dist-info → empathy_framework-4.6.5.dist-info}/METADATA +53 -11
  2. {empathy_framework-4.6.3.dist-info → empathy_framework-4.6.5.dist-info}/RECORD +32 -57
  3. empathy_llm_toolkit/agent_factory/crews/health_check.py +7 -4
  4. empathy_llm_toolkit/agent_factory/decorators.py +3 -2
  5. empathy_llm_toolkit/agent_factory/memory_integration.py +6 -2
  6. empathy_llm_toolkit/contextual_patterns.py +5 -2
  7. empathy_llm_toolkit/git_pattern_extractor.py +8 -4
  8. empathy_llm_toolkit/providers.py +4 -3
  9. empathy_os/__init__.py +1 -1
  10. empathy_os/cli/__init__.py +306 -0
  11. empathy_os/cli/__main__.py +26 -0
  12. empathy_os/cli/commands/__init__.py +8 -0
  13. empathy_os/cli/commands/inspection.py +48 -0
  14. empathy_os/cli/commands/memory.py +56 -0
  15. empathy_os/cli/commands/provider.py +86 -0
  16. empathy_os/cli/commands/utilities.py +94 -0
  17. empathy_os/cli/core.py +32 -0
  18. empathy_os/cli.py +18 -6
  19. empathy_os/cli_unified.py +19 -3
  20. empathy_os/memory/short_term.py +12 -2
  21. empathy_os/project_index/scanner.py +151 -49
  22. empathy_os/socratic/visual_editor.py +9 -4
  23. empathy_os/workflows/bug_predict.py +70 -1
  24. empathy_os/workflows/pr_review.py +6 -0
  25. empathy_os/workflows/security_audit.py +13 -0
  26. empathy_os/workflows/tier_tracking.py +50 -2
  27. wizards/discharge_summary_wizard.py +4 -2
  28. wizards/incident_report_wizard.py +4 -2
  29. empathy_os/meta_workflows/agent_creator 2.py +0 -254
  30. empathy_os/meta_workflows/builtin_templates 2.py +0 -567
  31. empathy_os/meta_workflows/cli_meta_workflows 2.py +0 -1551
  32. empathy_os/meta_workflows/form_engine 2.py +0 -304
  33. empathy_os/meta_workflows/intent_detector 2.py +0 -298
  34. empathy_os/meta_workflows/pattern_learner 2.py +0 -754
  35. empathy_os/meta_workflows/session_context 2.py +0 -398
  36. empathy_os/meta_workflows/template_registry 2.py +0 -229
  37. empathy_os/meta_workflows/workflow 2.py +0 -980
  38. empathy_os/orchestration/pattern_learner 2.py +0 -699
  39. empathy_os/orchestration/real_tools 2.py +0 -938
  40. empathy_os/socratic/__init__ 2.py +0 -273
  41. empathy_os/socratic/ab_testing 2.py +0 -969
  42. empathy_os/socratic/blueprint 2.py +0 -532
  43. empathy_os/socratic/cli 2.py +0 -689
  44. empathy_os/socratic/collaboration 2.py +0 -1112
  45. empathy_os/socratic/domain_templates 2.py +0 -916
  46. empathy_os/socratic/embeddings 2.py +0 -734
  47. empathy_os/socratic/engine 2.py +0 -729
  48. empathy_os/socratic/explainer 2.py +0 -663
  49. empathy_os/socratic/feedback 2.py +0 -767
  50. empathy_os/socratic/forms 2.py +0 -624
  51. empathy_os/socratic/generator 2.py +0 -716
  52. empathy_os/socratic/llm_analyzer 2.py +0 -635
  53. empathy_os/socratic/mcp_server 2.py +0 -751
  54. empathy_os/socratic/session 2.py +0 -306
  55. empathy_os/socratic/storage 2.py +0 -635
  56. empathy_os/socratic/success 2.py +0 -719
  57. empathy_os/socratic/visual_editor 2.py +0 -812
  58. empathy_os/socratic/web_ui 2.py +0 -925
  59. empathy_os/workflows/batch_processing 2.py +0 -310
  60. empathy_os/workflows/release_prep_crew 2.py +0 -968
  61. empathy_os/workflows/test_coverage_boost_crew 2.py +0 -848
  62. {empathy_framework-4.6.3.dist-info → empathy_framework-4.6.5.dist-info}/WHEEL +0 -0
  63. {empathy_framework-4.6.3.dist-info → empathy_framework-4.6.5.dist-info}/entry_points.txt +0 -0
  64. {empathy_framework-4.6.3.dist-info → empathy_framework-4.6.5.dist-info}/licenses/LICENSE +0 -0
  65. {empathy_framework-4.6.3.dist-info → empathy_framework-4.6.5.dist-info}/top_level.txt +0 -0
@@ -1,304 +0,0 @@
1
- """Socratic form engine for requirements gathering.
2
-
3
- Uses AskUserQuestion tool to interactively collect user requirements
4
- through structured question flows.
5
-
6
- Created: 2026-01-17
7
- Updated: 2026-01-18 (v4.3.0 - Real AskUserQuestion integration)
8
- Purpose: Interactive requirements gathering for meta-workflows
9
- """
10
-
11
- import logging
12
- from collections.abc import Callable
13
- from typing import Any
14
-
15
- from empathy_os.meta_workflows.models import FormQuestion, FormResponse, FormSchema
16
-
17
- logger = logging.getLogger(__name__)
18
-
19
- # Type alias for the AskUserQuestion callback function
20
- AskUserQuestionCallback = Callable[[list[dict[str, Any]]], dict[str, Any]]
21
-
22
-
23
- class SocraticFormEngine:
24
- """Engine for collecting user requirements through Socratic questioning.
25
-
26
- Uses the AskUserQuestion tool to present forms to users and
27
- collect structured responses.
28
-
29
- The engine supports two modes:
30
- 1. **Interactive mode**: Provide an `ask_user_callback` to invoke the real
31
- AskUserQuestion tool (e.g., when running in Claude Code context)
32
- 2. **Default mode**: Uses default values from questions when no callback
33
- is provided (useful for testing or batch processing)
34
-
35
- Example:
36
- >>> # Interactive mode with callback
37
- >>> def my_callback(questions):
38
- ... # This would invoke the real AskUserQuestion tool
39
- ... return {"q1": "user answer"}
40
- >>> engine = SocraticFormEngine(ask_user_callback=my_callback)
41
-
42
- >>> # Default mode (no interaction)
43
- >>> engine = SocraticFormEngine()
44
- """
45
-
46
- def __init__(
47
- self,
48
- ask_user_callback: AskUserQuestionCallback | None = None,
49
- use_defaults_when_no_callback: bool = True,
50
- ):
51
- """Initialize the Socratic form engine.
52
-
53
- Args:
54
- ask_user_callback: Optional callback function that invokes the
55
- AskUserQuestion tool. When provided, enables interactive mode.
56
- The callback should accept a list of question dicts and return
57
- a dict mapping question IDs to user answers.
58
- use_defaults_when_no_callback: If True and no callback is provided,
59
- use default values from questions. If False, raise an error
60
- when trying to ask questions without a callback.
61
- """
62
- self.responses_cache: dict[str, FormResponse] = {}
63
- self._ask_user_callback = ask_user_callback
64
- self._use_defaults_when_no_callback = use_defaults_when_no_callback
65
-
66
- def ask_questions(
67
- self, form_schema: FormSchema, template_id: str
68
- ) -> FormResponse:
69
- """Ask all questions in the form schema and collect responses.
70
-
71
- Args:
72
- form_schema: Schema defining questions to ask
73
- template_id: ID of template these questions are for
74
-
75
- Returns:
76
- FormResponse with user's answers
77
-
78
- Raises:
79
- ValueError: If form_schema is invalid
80
- """
81
- if not form_schema.questions:
82
- logger.warning(f"Form schema for {template_id} has no questions")
83
- return FormResponse(template_id=template_id, responses={})
84
-
85
- # Batch questions (AskUserQuestion supports max 4 at once)
86
- batches = form_schema.get_question_batches(batch_size=4)
87
- all_responses = {}
88
-
89
- logger.info(
90
- f"Asking {len(form_schema.questions)} questions in {len(batches)} batch(es)"
91
- )
92
-
93
- for batch_idx, batch in enumerate(batches, 1):
94
- logger.debug(f"Processing batch {batch_idx}/{len(batches)}")
95
-
96
- # Convert batch to AskUserQuestion format
97
- batch_questions = self._convert_batch_to_ask_user_format(batch)
98
-
99
- # In real usage, this would call AskUserQuestion tool
100
- # For now, this is a placeholder that tests can mock
101
- batch_responses = self._ask_batch(batch_questions, template_id)
102
-
103
- # Merge responses
104
- all_responses.update(batch_responses)
105
-
106
- # Create FormResponse
107
- response = FormResponse(template_id=template_id, responses=all_responses)
108
-
109
- # Cache response
110
- self.responses_cache[response.response_id] = response
111
-
112
- logger.info(
113
- f"Collected {len(all_responses)} responses for template {template_id}"
114
- )
115
- return response
116
-
117
- def _convert_batch_to_ask_user_format(
118
- self, batch: list[FormQuestion]
119
- ) -> list[dict[str, Any]]:
120
- """Convert a batch of FormQuestions to AskUserQuestion format.
121
-
122
- Args:
123
- batch: List of FormQuestion objects
124
-
125
- Returns:
126
- List of question dictionaries compatible with AskUserQuestion
127
- """
128
- return [q.to_ask_user_format() for q in batch]
129
-
130
- def _ask_batch(
131
- self, questions: list[dict[str, Any]], template_id: str
132
- ) -> dict[str, Any]:
133
- """Ask a batch of questions using AskUserQuestion tool.
134
-
135
- Args:
136
- questions: Questions in AskUserQuestion format
137
- template_id: Template ID for context
138
-
139
- Returns:
140
- Dictionary mapping question_id → user's answer
141
-
142
- Raises:
143
- RuntimeError: If no callback is set and use_defaults_when_no_callback
144
- is False
145
-
146
- Note:
147
- When a callback is provided, invokes the real AskUserQuestion tool.
148
- Otherwise, uses default values from questions or raises an error.
149
- """
150
- logger.debug(f"_ask_batch called with {len(questions)} questions")
151
-
152
- # If we have a callback, use it for interactive mode
153
- if self._ask_user_callback is not None:
154
- try:
155
- logger.info(f"Invoking AskUserQuestion callback for {len(questions)} questions")
156
- result = self._ask_user_callback(questions)
157
- logger.debug(f"Received {len(result)} responses from callback")
158
- return result
159
- except Exception as e:
160
- logger.error(f"AskUserQuestion callback failed: {e}")
161
- if self._use_defaults_when_no_callback:
162
- logger.warning("Falling back to default values")
163
- return self._get_defaults_from_questions(questions)
164
- raise RuntimeError(f"AskUserQuestion callback failed: {e}") from e
165
-
166
- # No callback - use defaults or raise error
167
- if self._use_defaults_when_no_callback:
168
- logger.debug("No callback provided, using default values")
169
- return self._get_defaults_from_questions(questions)
170
-
171
- raise RuntimeError(
172
- "No AskUserQuestion callback provided and use_defaults_when_no_callback=False. "
173
- "Either provide a callback or set use_defaults_when_no_callback=True."
174
- )
175
-
176
- def _get_defaults_from_questions(
177
- self, questions: list[dict[str, Any]]
178
- ) -> dict[str, Any]:
179
- """Extract default values from question definitions.
180
-
181
- Args:
182
- questions: Questions in AskUserQuestion format
183
-
184
- Returns:
185
- Dictionary mapping question_id → default value
186
- """
187
- defaults = {}
188
- for q in questions:
189
- # Get question identifier - prefer question_id for agent rule matching
190
- key = q.get("question_id", q.get("header", q.get("question", "unknown")))
191
-
192
- # Check for explicit default value first
193
- if "default" in q and q["default"]:
194
- defaults[key] = q["default"]
195
- logger.debug(f"Default for '{key}': {defaults[key]} (explicit)")
196
- continue
197
-
198
- # Get default from options (first option is typically recommended)
199
- options = q.get("options", [])
200
- if options:
201
- # Use first option's label as default
202
- first_option = options[0]
203
- if isinstance(first_option, dict):
204
- defaults[key] = first_option.get("label", "")
205
- else:
206
- defaults[key] = str(first_option)
207
- else:
208
- defaults[key] = ""
209
-
210
- logger.debug(f"Default for '{key}': {defaults[key]} (from options)")
211
-
212
- return defaults
213
-
214
- def set_callback(self, callback: AskUserQuestionCallback | None) -> None:
215
- """Set or update the AskUserQuestion callback.
216
-
217
- Args:
218
- callback: The callback function to use, or None to disable
219
- """
220
- self._ask_user_callback = callback
221
- logger.debug(f"AskUserQuestion callback {'set' if callback else 'cleared'}")
222
-
223
- def get_cached_response(self, response_id: str) -> FormResponse | None:
224
- """Retrieve a cached response by ID.
225
-
226
- Args:
227
- response_id: ID of response to retrieve
228
-
229
- Returns:
230
- FormResponse if found, None otherwise
231
- """
232
- return self.responses_cache.get(response_id)
233
-
234
- def clear_cache(self) -> None:
235
- """Clear the response cache."""
236
- self.responses_cache.clear()
237
- logger.debug("Response cache cleared")
238
-
239
-
240
- # =============================================================================
241
- # Helper functions for converting between formats
242
- # =============================================================================
243
-
244
-
245
- def convert_ask_user_response_to_form_response(
246
- ask_user_result: dict[str, Any], template_id: str
247
- ) -> FormResponse:
248
- """Convert AskUserQuestion tool result to FormResponse.
249
-
250
- Args:
251
- ask_user_result: Result from AskUserQuestion tool
252
- template_id: Template ID
253
-
254
- Returns:
255
- FormResponse object
256
-
257
- Example:
258
- >>> result = {"q1": "Answer 1", "q2": ["Option A", "Option B"]}
259
- >>> response = convert_ask_user_response_to_form_response(result, "test")
260
- >>> response.get("q1")
261
- 'Answer 1'
262
- """
263
- return FormResponse(template_id=template_id, responses=ask_user_result)
264
-
265
-
266
- def create_header_from_question(question: FormQuestion) -> str:
267
- """Create a short header for a question (max 12 chars for AskUserQuestion).
268
-
269
- Args:
270
- question: FormQuestion to create header for
271
-
272
- Returns:
273
- Short header string (≤12 chars)
274
-
275
- Example:
276
- >>> q = FormQuestion(id="has_tests", text="Do you have tests?", type=QuestionType.BOOLEAN)
277
- >>> create_header_from_question(q)
278
- 'Tests'
279
- """
280
- # Extract key words from question text
281
- text = question.text.lower()
282
-
283
- # Common patterns
284
- if "test" in text:
285
- return "Tests"
286
- elif "coverage" in text:
287
- return "Coverage"
288
- elif "version" in text:
289
- return "Version"
290
- elif "publish" in text:
291
- return "Publishing"
292
- elif "quality" in text:
293
- return "Quality"
294
- elif "security" in text:
295
- return "Security"
296
- elif "name" in text:
297
- return "Name"
298
- elif "changelog" in text:
299
- return "Changelog"
300
- elif "git" in text:
301
- return "Git"
302
-
303
- # Fallback: use question ID (truncated to 12 chars)
304
- return question.id[:12].title()
@@ -1,298 +0,0 @@
1
- """Intent detection for automatic agent team creation.
2
-
3
- Analyzes user requests and suggests appropriate meta-workflow templates.
4
-
5
- Created: 2026-01-18
6
- Purpose: Enable natural discovery of agent teams based on user intent
7
- """
8
-
9
- import logging
10
- import re
11
- from dataclasses import dataclass, field
12
- from typing import Any
13
-
14
- from empathy_os.meta_workflows.builtin_templates import BUILTIN_TEMPLATES
15
-
16
- logger = logging.getLogger(__name__)
17
-
18
-
19
- @dataclass
20
- class IntentMatch:
21
- """A detected intent match with confidence score.
22
-
23
- Attributes:
24
- template_id: ID of matching template
25
- template_name: Human-readable name
26
- confidence: Match confidence (0.0 to 1.0)
27
- matched_keywords: Keywords that triggered the match
28
- description: What this template does
29
- """
30
-
31
- template_id: str
32
- template_name: str
33
- confidence: float
34
- matched_keywords: list[str] = field(default_factory=list)
35
- description: str = ""
36
-
37
-
38
- # Intent patterns for each template
39
- INTENT_PATTERNS = {
40
- "release-prep": {
41
- "keywords": [
42
- "release", "deploy", "publish", "ship", "launch",
43
- "ready", "readiness", "checklist", "preparation",
44
- "security scan", "vulnerability", "audit",
45
- "production", "go live", "version bump",
46
- "pre-release", "before release", "quality check",
47
- "code review", "final check"
48
- ],
49
- "phrases": [
50
- r"ready (for|to) (release|deploy|publish)",
51
- r"(check|verify|validate) (for )?release",
52
- r"(prepare|preparing) (for )?(a )?(release|deployment)",
53
- r"security (scan|check|audit)",
54
- r"(is|are) (we|it) ready",
55
- r"release (check|prep|preparation)",
56
- r"prepare for (a )?release",
57
- r"need to release",
58
- r"before (we )?(release|deploy|publish|ship|launch)",
59
- r"quality (check|audit|review)",
60
- r"ready to (ship|deploy|launch|publish)",
61
- ],
62
- "weight": 1.0,
63
- },
64
- "test-coverage-boost": {
65
- "keywords": [
66
- "test coverage", "coverage", "tests", "testing",
67
- "unit tests", "improve coverage", "boost coverage",
68
- "generate tests", "missing tests", "coverage gap",
69
- "80%", "90%", "percent coverage", "more tests",
70
- "add tests", "write tests", "create tests"
71
- ],
72
- "phrases": [
73
- r"(improve|increase|boost) (test )?coverage",
74
- r"(generate|create|write|add) (more )?tests",
75
- r"coverage (is )?(too )?low",
76
- r"(find|identify) (coverage )?gaps",
77
- r"(need|want) more tests",
78
- r"test generation",
79
- r"my (test )?coverage",
80
- r"improve.*coverage",
81
- ],
82
- "weight": 1.0,
83
- },
84
- "test-maintenance": {
85
- "keywords": [
86
- "test maintenance", "stale tests", "outdated tests",
87
- "flaky tests", "test health", "test cleanup",
88
- "test lifecycle", "maintain tests", "fix tests",
89
- "broken tests", "failing tests"
90
- ],
91
- "phrases": [
92
- r"(fix|update|maintain) tests",
93
- r"(stale|outdated|old) tests",
94
- r"test (maintenance|health|cleanup)",
95
- r"tests (are )?(failing|flaky|broken)",
96
- r"clean up tests",
97
- r"test.*broken",
98
- r"failing test",
99
- ],
100
- "weight": 1.0,
101
- },
102
- "manage-docs": {
103
- "keywords": [
104
- "documentation", "docs", "docstrings", "readme",
105
- "api docs", "missing docs", "update docs",
106
- "document", "documenting", "undocumented",
107
- "up to date", "sync", "stale docs", "outdated docs"
108
- ],
109
- "phrases": [
110
- r"(update|improve|fix|add) (the )?doc(s|umentation)?",
111
- r"missing (doc)?strings",
112
- r"(check|verify) documentation",
113
- r"(readme|api docs?) (is )?(outdated|stale|missing)",
114
- r"document (the )?(code|api|functions)",
115
- r"documentation.*(up to date|sync|current|fresh)",
116
- r"(is|are).*(doc|documentation).*(up to date|current|sync)",
117
- r"doc.*(stale|outdated|old)",
118
- ],
119
- "weight": 1.0,
120
- },
121
- }
122
-
123
-
124
- class IntentDetector:
125
- """Detects user intent and suggests appropriate agent teams.
126
-
127
- Uses keyword matching and phrase patterns to identify what the user
128
- is trying to accomplish and maps it to available meta-workflow templates.
129
- """
130
-
131
- def __init__(self):
132
- """Initialize the intent detector."""
133
- self.patterns = INTENT_PATTERNS
134
- self.templates = BUILTIN_TEMPLATES
135
-
136
- def detect(self, user_input: str, threshold: float = 0.3) -> list[IntentMatch]:
137
- """Detect user intent from natural language input.
138
-
139
- Args:
140
- user_input: User's natural language request
141
- threshold: Minimum confidence score to include (default: 0.3)
142
-
143
- Returns:
144
- List of IntentMatch objects, sorted by confidence (highest first)
145
- """
146
- if not user_input or not isinstance(user_input, str):
147
- return []
148
-
149
- user_input_lower = user_input.lower().strip()
150
- matches = []
151
-
152
- for template_id, pattern_config in self.patterns.items():
153
- confidence, matched_keywords = self._calculate_match_score(
154
- user_input_lower, pattern_config
155
- )
156
-
157
- if confidence >= threshold:
158
- template = self.templates.get(template_id)
159
- matches.append(
160
- IntentMatch(
161
- template_id=template_id,
162
- template_name=template.name if template else template_id,
163
- confidence=confidence,
164
- matched_keywords=matched_keywords,
165
- description=template.description if template else "",
166
- )
167
- )
168
-
169
- # Sort by confidence (highest first)
170
- matches.sort(key=lambda m: m.confidence, reverse=True)
171
- return matches
172
-
173
- def _calculate_match_score(
174
- self, user_input: str, pattern_config: dict[str, Any]
175
- ) -> tuple[float, list[str]]:
176
- """Calculate match score for a template.
177
-
178
- Args:
179
- user_input: Lowercase user input
180
- pattern_config: Pattern configuration for a template
181
-
182
- Returns:
183
- Tuple of (confidence score, list of matched keywords)
184
- """
185
- keywords = pattern_config.get("keywords", [])
186
- phrases = pattern_config.get("phrases", [])
187
- weight = pattern_config.get("weight", 1.0)
188
-
189
- matched_keywords = []
190
- keyword_score = 0.0
191
- phrase_score = 0.0
192
-
193
- # Check keyword matches
194
- for keyword in keywords:
195
- if keyword.lower() in user_input:
196
- matched_keywords.append(keyword)
197
- # Longer keywords are weighted more
198
- keyword_score += len(keyword.split()) * 0.1
199
-
200
- # Check phrase matches (more specific, higher weight)
201
- for phrase in phrases:
202
- if re.search(phrase, user_input, re.IGNORECASE):
203
- phrase_score += 0.3
204
- # Extract matched text for debugging
205
- match = re.search(phrase, user_input, re.IGNORECASE)
206
- if match:
207
- matched_keywords.append(f"[{match.group()}]")
208
-
209
- # Combine scores (cap at 1.0)
210
- total_score = min((keyword_score + phrase_score) * weight, 1.0)
211
-
212
- return total_score, matched_keywords
213
-
214
- def get_suggestion_text(self, matches: list[IntentMatch]) -> str:
215
- """Generate a user-friendly suggestion message.
216
-
217
- Args:
218
- matches: List of intent matches
219
-
220
- Returns:
221
- Formatted suggestion text
222
- """
223
- if not matches:
224
- return ""
225
-
226
- lines = ["I detected the following agent teams that might help:\n"]
227
-
228
- for i, match in enumerate(matches[:3], 1): # Top 3 suggestions
229
- confidence_pct = int(match.confidence * 100)
230
- lines.append(
231
- f" {i}. **{match.template_name}** ({confidence_pct}% match)"
232
- )
233
- lines.append(f" {match.description}")
234
- lines.append(f" Run with: `empathy meta-workflow run {match.template_id}`")
235
- lines.append("")
236
-
237
- return "\n".join(lines)
238
-
239
- def should_suggest(self, user_input: str, min_confidence: float = 0.4) -> bool:
240
- """Check if we should suggest agent teams for this input.
241
-
242
- Args:
243
- user_input: User's input text
244
- min_confidence: Minimum confidence to trigger suggestion
245
-
246
- Returns:
247
- True if we should suggest agent teams
248
- """
249
- matches = self.detect(user_input, threshold=min_confidence)
250
- return len(matches) > 0
251
-
252
- def get_best_match(self, user_input: str) -> IntentMatch | None:
253
- """Get the best matching template for user input.
254
-
255
- Args:
256
- user_input: User's natural language request
257
-
258
- Returns:
259
- Best matching IntentMatch or None if no good match
260
- """
261
- matches = self.detect(user_input, threshold=0.4)
262
- return matches[0] if matches else None
263
-
264
-
265
- def detect_and_suggest(user_input: str) -> str:
266
- """Convenience function to detect intent and return suggestion.
267
-
268
- Args:
269
- user_input: User's natural language request
270
-
271
- Returns:
272
- Suggestion text or empty string if no matches
273
- """
274
- detector = IntentDetector()
275
- matches = detector.detect(user_input)
276
- return detector.get_suggestion_text(matches)
277
-
278
-
279
- def auto_detect_template(user_input: str) -> str | None:
280
- """Auto-detect the best template for a user request.
281
-
282
- Args:
283
- user_input: User's natural language request
284
-
285
- Returns:
286
- Template ID if confident match, None otherwise
287
- """
288
- detector = IntentDetector()
289
- match = detector.get_best_match(user_input)
290
-
291
- if match and match.confidence >= 0.6:
292
- logger.info(
293
- f"Auto-detected template: {match.template_id} "
294
- f"(confidence: {match.confidence:.0%})"
295
- )
296
- return match.template_id
297
-
298
- return None