Skip to content

Commit

Permalink
Add missing max_tokens option to TogetherAI (#3687)
Browse files Browse the repository at this point in the history
  • Loading branch information
skadefro authored Dec 17, 2023
1 parent facf820 commit b0137ba
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libs/langchain-community/src/llms/togetherai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ export interface TogetherAIInputs extends BaseLLMParams {
* Run an LLM-based input-output safeguard model on top of any model.
*/
safetyModel?: string;
/**
* Limit the number of tokens generated.
*/
maxTokens?: number;
}

export interface TogetherAICallOptions
Expand All @@ -105,6 +109,7 @@ export interface TogetherAICallOptions
| "repetitionPenalty"
| "logprobs"
| "safetyModel"
| "maxTokens"
> {}

export class TogetherAI extends LLM<TogetherAICallOptions> {
Expand All @@ -128,6 +133,8 @@ export class TogetherAI extends LLM<TogetherAICallOptions> {

logprobs?: number;

maxTokens?: number;

safetyModel?: string;

private apiKey: string;
Expand All @@ -154,6 +161,7 @@ export class TogetherAI extends LLM<TogetherAICallOptions> {
this.repetitionPenalty = inputs.repetitionPenalty ?? this.repetitionPenalty;
this.logprobs = inputs.logprobs;
this.safetyModel = inputs.safetyModel;
this.maxTokens = inputs.maxTokens;
}

_llmType() {
Expand All @@ -179,6 +187,7 @@ export class TogetherAI extends LLM<TogetherAICallOptions> {
logprobs: this?.logprobs ?? options?.logprobs,
stream_tokens: this?.streaming,
safety_model: this?.safetyModel ?? options?.safetyModel,
max_tokens: this?.maxTokens ?? options?.maxTokens,
};
return body;
}
Expand Down

0 comments on commit b0137ba

Please sign in to comment.