Conversation
Extract OCR text from RecognitionDetail using the Results field (which is already parsed by maa-framework-go) instead of manually parsing DetailJson. Add tryGetOCRText and tryGetOCRTexts helper functions for better readability.
|
摆了一段时间,忘记后面要改啥了,先这样吧(投降喵 |
There was a problem hiding this comment.
Hey - 我发现了 1 个问题,并留下了一些整体性的反馈:
- 新增的 helper
MoveMouseSafe在这个 diff 中被定义但没有在任何地方使用,建议要么把它集成进相关流程中,要么移除它以避免产生死代码。 processMaxRecord只有在Row >= 2时才会对Row减 1;如果你的意图是总是把最大记录归一到前一行,建议通过注释或对Row == 1做显式处理来澄清边界条件,从而让行为更容易理解。recognizeText函数在每次 OCR 成功时都会用Info级别打日志;如果在正常流程中调用频繁,建议将其降级为Debug,或者加上一定的控制(例如采样或开关),以避免线上日志过于嘈杂。
给 AI Agent 的提示词
Please address the comments from this code review:
## Overall Comments
- The new helper `MoveMouseSafe` is defined but not used anywhere in this diff, consider either integrating it into the relevant flow or removing it to avoid dead code.
- `processMaxRecord` subtracts 1 from `Row` only when `Row >= 2`; if the intent is to always normalize max records to the previous row, consider clarifying the boundary condition (e.g., with a comment or by handling `Row == 1` explicitly) to make the behavior easier to reason about.
- The `recognizeText` function logs at `Info` level on every successful OCR; if this runs frequently in normal flows, consider downgrading to `Debug` or gating the log to avoid noisy logs in production.
## Individual Comments
### Comment 1
<location path="agent/go-service/resell/quota_ocr.go" line_range="111-115" />
<code_context>
+ return ""
+ }
+
+ log.Info().
+ Str("node", nodeName).
+ Str("text", text).
+ Msg("recognition OCR text")
+ return text
+}
</code_context>
<issue_to_address>
**suggestion (performance):** Using Info-level logging for every successful OCR result may generate excessive log volume.
Since `recognizeText` may run frequently, logging every non-empty result at Info can create noisy, high-volume logs and make operational issues harder to detect. Consider lowering this to Debug or guarding it with sampling/feature flags unless Info-level visibility is explicitly required in production.
```suggestion
log.Debug().
Str("node", nodeName).
Str("text", text).
Msg("recognition OCR text")
return text
```
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的 Review。
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- The new helper
MoveMouseSafeis defined but not used anywhere in this diff, consider either integrating it into the relevant flow or removing it to avoid dead code. processMaxRecordsubtracts 1 fromRowonly whenRow >= 2; if the intent is to always normalize max records to the previous row, consider clarifying the boundary condition (e.g., with a comment or by handlingRow == 1explicitly) to make the behavior easier to reason about.- The
recognizeTextfunction logs atInfolevel on every successful OCR; if this runs frequently in normal flows, consider downgrading toDebugor gating the log to avoid noisy logs in production.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new helper `MoveMouseSafe` is defined but not used anywhere in this diff, consider either integrating it into the relevant flow or removing it to avoid dead code.
- `processMaxRecord` subtracts 1 from `Row` only when `Row >= 2`; if the intent is to always normalize max records to the previous row, consider clarifying the boundary condition (e.g., with a comment or by handling `Row == 1` explicitly) to make the behavior easier to reason about.
- The `recognizeText` function logs at `Info` level on every successful OCR; if this runs frequently in normal flows, consider downgrading to `Debug` or gating the log to avoid noisy logs in production.
## Individual Comments
### Comment 1
<location path="agent/go-service/resell/quota_ocr.go" line_range="111-115" />
<code_context>
+ return ""
+ }
+
+ log.Info().
+ Str("node", nodeName).
+ Str("text", text).
+ Msg("recognition OCR text")
+ return text
+}
</code_context>
<issue_to_address>
**suggestion (performance):** Using Info-level logging for every successful OCR result may generate excessive log volume.
Since `recognizeText` may run frequently, logging every non-empty result at Info can create noisy, high-volume logs and make operational issues harder to detect. Consider lowering this to Debug or guarding it with sampling/feature flags unless Info-level visibility is explicitly required in production.
```suggestion
log.Debug().
Str("node", nodeName).
Str("text", text).
Msg("recognition OCR text")
return text
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
请问有什么需要我帮忙的吗?目前 PR 中已完成了 resell 相关的 OCR 解析重构、配额识别辅助方法提取、完成动作新增等工作。如果你想继续某个方向(比如 Pipeline 补充、测试、文档等),可以告诉我具体需求,我来接着做。 |
There was a problem hiding this comment.
Pull request overview
本 PR 对 go-service 的 resell 模块做重构,拆分并优化 OCR 文本/数值解析与配额识别相关工具,提升识别结果提取的一致性,并补充流程结束动作的实现落点。
Changes:
- 将原
utils.go中的多类工具方法拆分为更聚焦的文件(OCR detail 提取、配额 OCR、文本整数解析、finish action 等)。 - 将成本价/好友出售价的数字提取替换为新的整数解析方法
extractIntegerFromText。 - 将“最高利润记录行索引归一化”的后处理逻辑移至
decide.go。
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| agent/go-service/resell/utils.go | 删除原聚合工具文件(相关逻辑迁移到多个新文件) |
| agent/go-service/resell/text_parse.go | 新增整数解析工具 extractIntegerFromText |
| agent/go-service/resell/scan_product.go | 成本/好友价格解析改用新整数解析;新增 MoveMouseSafe |
| agent/go-service/resell/quota_ocr.go | 新增配额 OCR + 解析流程与 recognizeText 封装 |
| agent/go-service/resell/ocr_detail.go | 新增统一的 OCR 文本提取工具 extractOCRText |
| agent/go-service/resell/finish.go | 抽出 ResellFinishAction 到独立文件 |
| agent/go-service/resell/decide.go | 增加 processMaxRecord 后处理函数 |
| // 优先从 Results 中查找 | ||
| if detail.Results != nil { | ||
| // 按优先级顺序尝试获取 OCR 文本 | ||
| if text := tryGetOCRText(detail.Results.Best); text != "" { | ||
| return text | ||
| } | ||
| if text := tryGetOCRTexts(detail.Results.Filtered); text != "" { | ||
| return text | ||
| } | ||
| if text := tryGetOCRTexts(detail.Results.All); text != "" { | ||
| return text | ||
| } | ||
| } | ||
|
|
||
| // 递归查找 CombinedResult(Or/And 节点) | ||
| for _, child := range detail.CombinedResult { | ||
| if text := extractOCRText(child); text != "" { | ||
| return text | ||
| } | ||
| } | ||
|
|
||
| return "" | ||
| } |
There was a problem hiding this comment.
extractOCRText 目前只从 Results/CombinedResult 提取文本,未再从 detail.DetailJson 做兜底解析;但同仓库中(如 quantizedsliding/ocr.go)存在必须从 DetailJson 提取 OCR text 的情况,且 resell 旧实现也包含该兜底。建议补回对 DetailJson 的解析(至少支持 Maa wrap 的 best.text / best.detail 结构),否则在某些 Or/OCR 返回仅含 DetailJson 时会取不到 OCR 文本。
There was a problem hiding this comment.
此处无需对DetailJson再进行解析,本质和go binding解析一样
改改代码喵
Summary by Sourcery
优化转售相关的 OCR 解析与工具方法,以更好地提取数值,并改进配额相关的识别,同时新增专门的完成动作。
New Features:
Bug Fixes:
Enhancements:
Original summary in English
Summary by Sourcery
Refine resell OCR parsing and utilities to better extract numeric values and handle quota-related recognition while adding a dedicated finish action.
New Features:
Bug Fixes:
Enhancements: