jay77721
fe02c9b95f
feat(go-models): unify OpenAI-compatible token usage extraction (#17634)
## Summary
Relate to #17284 .
- Add `usage_parser.go`: `extractOpenAIUsage` /
`extractOpenAIStreamUsage`
with multi-field fallback (`prompt_tokens`/`input_tokens`,
`completion_tokens`/`output_tokens`).
- Add `parser_config.go`: `ParserConfig` struct and
`OpenAIParserConfig`.
- Add `response_handler.go`: `HandleNonStreamingResponse` /
`HandleStreamingResponse` as single entry points that extract usage,
populate `chatConfig.UsageResult`, and emit a `StreamUsage` log.
- Extend `base_model.go` with `doRequest` / `doStreamRequest`.
- Migrate `deepseek` driver to shared handlers, cutting ~100 lines.
- Add `usage_parser_test.go`.
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Haruko386 <tryeverypossible@163.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-07-31 18:32:07 +08:00
..
2026-07-31 18:32:07 +08:00
2026-06-08 16:26:27 +08:00
2026-07-24 22:00:09 +08:00
2026-07-07 16:32:11 +08:00
2026-06-17 11:26:13 +08:00
2026-07-22 21:27:08 +08:00
2026-07-16 16:00:56 +08:00
2026-07-16 16:00:56 +08:00
2026-07-16 16:00:56 +08:00
2026-07-30 19:58:49 +08:00
2026-07-16 20:20:29 +08:00
2026-03-27 19:25:18 +08:00
2026-07-16 16:00:56 +08:00
2026-03-27 19:25:18 +08:00
2026-07-13 16:32:34 +08:00
2026-07-15 23:05:06 +08:00
2026-07-31 11:25:26 +08:00
2026-03-27 19:25:18 +08:00
2026-07-15 23:05:06 +08:00
2026-07-16 16:00:56 +08:00
2026-03-27 19:25:18 +08:00
2026-07-08 18:02:11 +08:00
2026-03-27 19:25:18 +08:00
2026-07-22 21:27:08 +08:00
2026-07-08 18:02:11 +08:00
2026-06-29 09:45:16 +08:00
2026-05-14 13:46:46 +08:00
2026-03-27 19:25:18 +08:00
2026-07-16 16:00:56 +08:00
2026-07-16 16:00:56 +08:00
2026-04-02 20:20:35 +08:00
2026-04-02 20:20:35 +08:00
2026-06-02 13:24:53 +08:00
2026-04-02 20:20:35 +08:00
2026-07-08 18:02:11 +08:00
2026-07-16 16:00:56 +08:00
2026-03-27 19:25:18 +08:00
2026-07-17 13:05:22 +08:00
2026-07-16 16:00:56 +08:00
2026-07-16 16:00:56 +08:00