From b8c97fa0129c2869a5028b52e45f2e672575dc6d Mon Sep 17 00:00:00 2001 From: Jun Siang Cheah Date: Mon, 6 May 2024 14:46:50 +0800 Subject: [PATCH] feat: restrict title gen output to 50 tokens --- src/lib/apis/ollama/index.ts | 6 +++++- src/lib/apis/openai/index.ts | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/apis/ollama/index.ts b/src/lib/apis/ollama/index.ts index a94aceace..ce05145d2 100644 --- a/src/lib/apis/ollama/index.ts +++ b/src/lib/apis/ollama/index.ts @@ -159,7 +159,11 @@ export const generateTitle = async ( body: JSON.stringify({ model: model, prompt: template, - stream: false + stream: false, + options: { + // Restrict the number of tokens generated to 50 + num_predict: 50, + } }) }) .then(async (res) => { diff --git a/src/lib/apis/openai/index.ts b/src/lib/apis/openai/index.ts index ac770e5b7..c7dd1366d 100644 --- a/src/lib/apis/openai/index.ts +++ b/src/lib/apis/openai/index.ts @@ -295,7 +295,9 @@ export const generateTitle = async ( content: template } ], - stream: false + stream: false, + // Restricting the max tokens to 50 to avoid long titles + max_tokens: 50, }) }) .then(async (res) => {