fix: incorrect Perplexity API parameter names (#9278)

Co-authored-by: Arvydas Jonusonis <arvydas@jonusonis.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com>
This commit is contained in:
Arvydas Jonusonis 2025-08-25 07:01:07 -07:00 committed by GitHub
commit 43812ceda6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 16 deletions

View file

@ -29,9 +29,8 @@ You can toggle parameters through the <Icon name="SlidersHorizontal" aria-hidden
| Name | Type | Description |
|------|------|-------------|
| model_name | String | Input parameter. The name of the Perplexity model to use. Options include various Llama 3.1 models. |
| max_output_tokens | Integer | Input parameter. The maximum number of tokens to generate. |
| max_tokens | Integer | Input parameter. The maximum number of tokens to generate. |
| api_key | SecretString | Input parameter. The Perplexity API Key for authentication. |
| temperature | Float | Input parameter. Controls randomness in the output. Default: 0.75. |
| top_p | Float | Input parameter. The maximum cumulative probability of tokens to consider when sampling (advanced). |
| n | Integer | Input parameter. Number of chat completions to generate for each prompt (advanced). |
| top_k | Integer | Input parameter. Number of top tokens to consider for top-k sampling. Must be positive (advanced). |
| n | Integer | Input parameter. Number of chat completions to generate for each prompt (advanced). |

View file

@ -31,9 +31,7 @@ class PerplexityComponent(LCModelComponent):
],
value="llama-3.1-sonar-small-128k-online",
),
IntInput(
name="max_output_tokens", display_name="Max Output Tokens", info="The maximum number of tokens to generate."
),
IntInput(name="max_tokens", display_name="Max Output Tokens", info="The maximum number of tokens to generate."),
SecretStrInput(
name="api_key",
display_name="Perplexity API Key",
@ -57,20 +55,13 @@ class PerplexityComponent(LCModelComponent):
"Note that the API may not return the full n completions if duplicates are generated.",
advanced=True,
),
IntInput(
name="top_k",
display_name="Top K",
info="Decode using top-k sampling: consider the set of top_k most probable tokens. Must be positive.",
advanced=True,
),
]
def build_model(self) -> LanguageModel: # type: ignore[type-var]
api_key = SecretStr(self.api_key).get_secret_value()
temperature = self.temperature
model = self.model_name
max_output_tokens = self.max_output_tokens
top_k = self.top_k
max_tokens = self.max_tokens
top_p = self.top_p
n = self.n
@ -78,8 +69,7 @@ class PerplexityComponent(LCModelComponent):
model=model,
temperature=temperature or 0.75,
pplx_api_key=api_key,
top_k=top_k or None,
top_p=top_p or None,
n=n or 1,
max_output_tokens=max_output_tokens,
max_tokens=max_tokens,
)