Skip to content

fix(perplexity): send the system prompt and text chunks Perplexity accepts - #1063

Open
skybleak333 wants to merge 1 commit into
prism-php:mainfrom
skybleak333:fix/perplexity-system-prompt
Open

skybleak333 wants to merge 1 commit into
prism-php:mainfrom
skybleak333:fix/perplexity-system-prompt

Conversation

@skybleak333

Copy link
Copy Markdown

Description

withSystemPrompt() had no effect with Perplexity. buildHttpRequestPayload() passed only $request->messages() to MessagesMapper, and the system prompts are kept apart in $request->systemPrompts(), so text, structured and stream requests went out without them. A request with ->withSystemPrompt('Answer in French.') carried only the user message.

The system prompts now go in front of the messages, as MessagesMapper already sorts system messages first.

While there: system and assistant messages were sent as content chunks with "type": "system" and "type": "assistant". In Perplexity's API schema a chunk is text, image_url, file_url, pdf_url or video_url, so they're now text chunks, like the text of a user message.

New tests: the system prompt is the first message, and an earlier answer goes out as a text chunk; both fail without the change. The full suite, PHPStan, Pint and Rector pass. I didn't send these to the live API.

This branch has not been deployed

No deployments
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