fix: handle blocks-only SSE responses (fixes #19) - #20
Open
IPv777 wants to merge 1 commit into
Open
Conversation
Perplexity changed their SSE response format. Responses now send 'blocks' instead of 'text'. The guard allowed blocks-only data through but then tried to access data["text"] which raised KeyError. Handle the blocks format by extracting: - Answer text from blocks[i]["markdown_block"]["answer"] - Streaming chunks from blocks[i]["markdown_block"]["chunks"] - Search results from blocks[i]["web_result_block"]["web_results"] Fixes jacob-bd#19
Author
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.
Perplexity changed their SSE response format — responses now send
blocksinstead oftext. The guard on line 608 allowed blocks-only data through but then tried to accessdata["text"]which raisedKeyError.This fix extracts the answer from
blocks[i]["markdown_block"]["answer"]and search results fromblocks[i]["web_result_block"]["web_results"].Verified working with
pwm askandpwm ask --json.