Skip to content

[WIP] Refactor intent-extraction logic into a single module - #304

Closed
gkhngyk with Copilot wants to merge 3 commits into
mainfrom
copilot/refactor-intent-extraction-module
Closed

gkhngyk with Copilot wants to merge 3 commits into
mainfrom
copilot/refactor-intent-extraction-module

Conversation

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Thanks for the feedback on #302. I've created this new PR, which merges into #302, to address your comment. I will work on the changes and keep this PR's description up to date as I make progress.

Original PR: #302
Triggering comment (#302 (comment)):

Thanks @copilot — addressed:

1. AI_VOLUME_MULTIPLIER NaN guard ✅ Fixed (c2f813c). Now parses then falls back to 0.15 when the value isn't finite, so a non-numeric/empty env var can't poison estAiVolume or persisted rows. Verified: abc → 0.15, 0.2 → 0.2, unset → 0.15.

2 & 3. System-prompt wording (missing other; "1–3 words strict" vs "never more than 4") — intentionally not changed in this PR. This prompt was moved verbatim from the existing production code; both quirks are pre-existing, not introduced here. This PR is a pure refactor whose stated contract is no behavior change to the volumes endpoints — production keeps its current prompt and schema. Editing the prompt text would change the LLM's output, which is out of scope. They're fair observations and can be picked up as a separate prompt-tuning change if the team wants to refine extraction behavior.

gkhngyk and others added 3 commits June 26, 2026 14:23
Extract intentKeywordSchema, INTENT_SYSTEM_PROMPT, AI_VOLUME_MULTIPLIER and a
new extractIntentKeywords() helper into server/src/lib/intent-extraction.js as
the single source of truth. Both volumes.js call sites (/analyze and
/analyze-batch) now collapse to one await extractIntentKeywords(), removing the
duplicated generateObject() calls and the unused ai/zod imports from the route.

No behavior change to the volumes endpoints.

Closes #241
parseFloat on a non-numeric or empty AI_VOLUME_MULTIPLIER yielded NaN, which
would propagate into estAiVolume and persisted rows. Fall back to the 0.15
default when the parsed value is not finite. (Copilot review on #302.)
Copilot AI requested a review from gkhngyk June 26, 2026 11:55
Base automatically changed from refactor/consolidate-intent-extraction to main June 26, 2026 11:59
@gkhngyk

gkhngyk commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Closing as redundant. This draft was auto-created in reaction to a review-reply comment on #302, but that comment was explaining review decisions, not requesting a new PR.

The actual work lives in #302:

The system-prompt wording points were intentionally left out (pure refactor, no behavior change). Nothing to do here; please track everything on #302.

@gkhngyk gkhngyk closed this Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants