upadte and patches to client.py #66

Merged
dearrevils merged 2 commits from main into main 2025-09-03 10:52:41 -04:00
dearrevils commented 2025-09-03 09:43:46 -04:00 (Migrated from github.com)

i fixed the issue where the "text" key was expecting in every chunks of perplexity response but oerplexity doesn't show it in all chunks but in final chunks so i fixed it It wait for the text key to appear in content_json i also added support for new models gpt5 gpt5_thinking grok4 claude sonnet 4.0 thinking with alias perplexity uses "claude37somethinking"

i hope this will help these fixes only tested in own accounts option i am not aware if this issue occurs in emailnator option so try it if that option has the issue

i fixed the issue where the "text" key was expecting in every chunks of perplexity response but oerplexity doesn't show it in all chunks but in final chunks so i fixed it It wait for the text key to appear in content_json i also added support for new models gpt5 gpt5_thinking grok4 claude sonnet 4.0 thinking with alias perplexity uses "claude37somethinking" i hope this will help these fixes only tested in own accounts option i am not aware if this issue occurs in emailnator option so try it if that option has the issue
dearrevils commented 2025-09-03 09:47:57 -04:00 (Migrated from github.com)

Summary of Changes

This PR addresses a key issue in client.py where the "text" key was expected in every chunk of the Perplexity response. However, based on observed behavior, "text" only appears in the final chunk. This caused premature parsing failures or incomplete responses. The updated logic now waits for "text" to appear in content_json, ensuring more reliable and complete output.

Enhancements

  • Model Support Expansion: Added support for newer models including:
    • gpt5
    • gpt5_thinking
    • grok4
    • claude sonnet 4.0 thinking
  • Alias Handling: Perplexity uses internal aliases like "claude37somethinking" — this PR maps those to their readable counterparts for better clarity and control.

Notes

  • These changes were tested using personal account-based access. I haven’t verified behavior under the Emailnator-based account generation flow, so maintainers may want to test that path separately.
  • The patch is modular and backward-compatible with existing logic.
  • No external dependencies were added.

Why This Matters

  • Fixes a parsing bug that could silently fail or truncate responses.
  • Future-proofs the wrapper against Perplexity’s evolving model naming conventions.
  • Improves developer experience and reliability for downstream automation.

Let me know if you'd like me to break this into smaller commits or add test coverage. Happy to iterate!

### Summary of Changes This PR addresses a key issue in `client.py` where the `"text"` key was expected in every chunk of the Perplexity response. However, based on observed behavior, `"text"` only appears in the final chunk. This caused premature parsing failures or incomplete responses. The updated logic now waits for `"text"` to appear in `content_json`, ensuring more reliable and complete output. ### Enhancements - ✅ **Model Support Expansion**: Added support for newer models including: - `gpt5` - `gpt5_thinking` - `grok4` - `claude sonnet 4.0 thinking` - ✅ **Alias Handling**: Perplexity uses internal aliases like `"claude37somethinking"` — this PR maps those to their readable counterparts for better clarity and control. ### Notes - These changes were tested using personal account-based access. I haven’t verified behavior under the Emailnator-based account generation flow, so maintainers may want to test that path separately. - The patch is modular and backward-compatible with existing logic. - No external dependencies were added. ### Why This Matters - Fixes a parsing bug that could silently fail or truncate responses. - Future-proofs the wrapper against Perplexity’s evolving model naming conventions. - Improves developer experience and reliability for downstream automation. Let me know if you'd like me to break this into smaller commits or add test coverage. Happy to iterate!
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
helallao/perplexity-ai!66
No description provided.