Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ› fix: fix parameter conditions for perplexity #1394

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/libs/agent-runtime/perplexity/index.ts
Expand Up @@ -26,14 +26,21 @@

async chat(payload: ChatStreamPayload) {
try {
// Set a default frequency penalty value greater than 0
const defaultFrequencyPenalty = 0.1;
const chatPayload = {
...payload,
frequency_penalty: payload.frequency_penalty || defaultFrequencyPenalty,
};
const modifiedPayload = { ...payload };
if (payload.presence_penalty !== 0) {
modifiedPayload.presence_penalty = payload.presence_penalty;
delete modifiedPayload.frequency_penalty; // Ensure frequency_penalty is not included
} else {
delete modifiedPayload.presence_penalty;
modifiedPayload.frequency_penalty =
(payload.frequency_penalty ?? defaultFrequencyPenalty) <= 0
? defaultFrequencyPenalty
: payload.frequency_penalty;
}

Check warning on line 41 in src/libs/agent-runtime/perplexity/index.ts

View check run for this annotation

Codecov / codecov/patch

src/libs/agent-runtime/perplexity/index.ts#L30-L41

Added lines #L30 - L41 were not covered by tests
const response = await this._llm.chat.completions.create(
chatPayload as unknown as OpenAI.ChatCompletionCreateParamsStreaming,
modifiedPayload as unknown as OpenAI.ChatCompletionCreateParamsStreaming,

Check warning on line 43 in src/libs/agent-runtime/perplexity/index.ts

View check run for this annotation

Codecov / codecov/patch

src/libs/agent-runtime/perplexity/index.ts#L43

Added line #L43 was not covered by tests
);

const stream = OpenAIStream(response);
Expand Down