Skip to content

Commit

Permalink
fix: max tokens sent only when required
Browse files Browse the repository at this point in the history
  • Loading branch information
Patai5 committed Jul 30, 2024
1 parent 157b5ca commit 67d2ae2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions code/src/models/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ const wrapInOpenaiError = (error: LangchainError): OpenaiAPIError => {
export class OpenAIModelHandler extends GeneralModelHandler<OpenAIModelSettings> {
async processInstructions(options: ProcessInstructionsOptions<OpenAIModelSettings>) {
const { instructions, content, schema, schemaDescription, modelSettings, remainingTokens } = options;
const { modelName, limitGenerationTokens, maxTokens } = this.modelConfig;
const { modelName, limitGenerationTokens } = this.modelConfig;

log.debug(`Calling Openai API with model ${this.modelConfig.modelName}`);

const handleLLMEndCallback = this.handleLLMEndCallbackHandler();
const modelOptions = {
...modelSettings,
modelName,
maxTokens: limitGenerationTokens ? remainingTokens : maxTokens,
maxTokens: limitGenerationTokens && remainingTokens,
callbacks: [{ handleLLMEnd: handleLLMEndCallback.handleLLMEnd }],
};

Expand Down

0 comments on commit 67d2ae2

Please sign in to comment.