Skip to content

fix: handle blocks-only SSE responses (fixes #19) - #20

Open
IPv777 wants to merge 1 commit into
jacob-bd:mainfrom
IPv777:fix/blocks-parsing
Open

fix: handle blocks-only SSE responses (fixes #19)#20
IPv777 wants to merge 1 commit into
jacob-bd:mainfrom
IPv777:fix/blocks-parsing

Conversation

@IPv777

@IPv777 IPv777 commented Aug 5, 2026

Copy link
Copy Markdown

Perplexity changed their SSE response format — responses now send blocks instead of text. The guard on line 608 allowed blocks-only data through but then tried to access data["text"] which raised KeyError.

This fix extracts the answer from blocks[i]["markdown_block"]["answer"] and search results from blocks[i]["web_result_block"]["web_results"].

Verified working with pwm ask and pwm ask --json.

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
@IPv777

IPv777 commented Aug 5, 2026

Copy link
Copy Markdown
Author

#19 (comment)

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.

1 participant