Skip to content

fix: expand chat completion capability validation (#64 follow-up)#65

Open
Abhishek21g wants to merge 2 commits into
perplexityai:mainfrom
Abhishek21g:fix/model-capability-matrix
Open

fix: expand chat completion capability validation (#64 follow-up)#65
Abhishek21g wants to merge 2 commits into
perplexityai:mainfrom
Abhishek21g:fix/model-capability-matrix

Conversation

@Abhishek21g

Copy link
Copy Markdown

Summary

Extends the model capability matrix introduced in #64 to validate additional chat completion parameters before the HTTP request is sent:

  • reasoning_effort — allowed on sonar-deep-research, sonar-reasoning-pro
  • search_context_size — allowed on sonar-pro, sonar-reasoning-pro (including via web_search_options)
  • search_domain_filter — max 3 domains

Problem

Integrators hit silent API failures or confusing responses when passing parameters unsupported by their selected model (public report: perplexity-py#61, community api-discussion threads on model-specific search params).

Fix

  • validate_chat_completion_params() centralizes preflight checks
  • Sync + async chat.completions.create call it before _post
  • 9 pytest cases (return_images + new validators)

Verification

pytest tests/test_model_capabilities.py -q

Builds on #64 — can land independently or stack after merge.

Add model capability matrix, raise clear error for sonar + return_images=True,
and parse images on StreamChunk responses.
Validate reasoning_effort, search_context_size, and search_domain_filter limits per model before requests are sent.
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