Main - #87
Open
98654561111 wants to merge 4 commits into
Open
Conversation
…chip frames The response parser picked the longest text found anywhere in the StreamGenerate response (single-file: the last text). A Gemini Web response also contains thought summaries, alternative drafts and follow-up/image frames; when the real answer was short (e.g. replying to '??'), a longer unrelated frame won and the API returned content that had nothing to do with the user's question. - Frame-aware parser: only the primary candidate of the main answer frame (the one carrying conversation/response ids) is used; answer segments are joined instead of returning the longest fragment; longest joined candidate kept as protocol-drift fallback - Streaming: same strict frame selection; no more splicing unrelated texts (t[len(prev):] without prefix check) and no more spurious 'content changed' retries; freezes on mid-stream rewrites; rescans buffered response as fallback; retries only when nothing was emitted - _reqid: process-wide browser-like incrementing counter (+100000 per call) instead of timestamp; concurrent requests (cronjob + chat) no longer send identical request ids; fresh id on every retry attempt - Applied to both the package (gemini_web2api/gemini.py) and the single-file build (gemini_web2api.py) - Add tests/test_response_parsing.py with simulated multi-frame wire payloads covering all failure modes (36 tests total, all pass) Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
The Cloudflare Worker port had the same three bugs fixed in the Python version: - extractResponseText used 'last non-empty text anywhere' -- a thought summary / follow-up chip frame appearing after the answer won and the API returned content unrelated to the question - streaming emitted t.slice(prevText.length) with only a length check, splicing unrelated frames into the output - _reqid came from a timestamp, so concurrent requests sent identical ids Port the fixes: frame-aware parser (main answer frame only, joined segments, fallback tiers), strict streaming with freeze-on-rewrite and end-of-stream fallback rescan, process-wide incrementing _reqid. Adds tests/worker_parsing.test.js (Node, 12 checks). Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Cloudflare's 'Connect Git repository' flow runs 'npx wrangler deploy' as the build command, which failed because the repo had no wrangler config. Add wrangler.toml pointing main at cloudflare/worker.js (validated with 'npx wrangler@latest deploy --dry-run', 48.58 KiB bundle, no errors) and document the flow plus the Access/non-prod-build toggles in cloudflare/README.MD. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
fix: 只回传主答案框架(修复答非所问)+ Cloudflare 部署支持
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.