From 0dc7e1b9fe2fcac0832dbbf48233ce4d881b0f87 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 26 Apr 2024 09:27:08 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20maxStopWords=20for=20Groq?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/llm/llms/Groq.ts | 1 + core/llm/llms/OpenAI.ts | 10 +++++++--- docs/static/schemas/config.json | 5 +++++ .../intellij/src/main/resources/config_schema.json | 5 +++++ extensions/vscode/continue_rc_schema.json | 5 +++++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/core/llm/llms/Groq.ts b/core/llm/llms/Groq.ts index 9f5e6f896..bbb23051e 100644 --- a/core/llm/llms/Groq.ts +++ b/core/llm/llms/Groq.ts @@ -6,6 +6,7 @@ class Groq extends OpenAI { static defaultOptions: Partial = { apiBase: "https://api.groq.com/openai/v1/", }; + protected maxStopWords: number | undefined = 4; private static modelConversion: { [key: string]: string } = { "llama2-70b": "llama2-70b-4096", diff --git a/core/llm/llms/OpenAI.ts b/core/llm/llms/OpenAI.ts index d8f4214ac..560dbd043 100644 --- a/core/llm/llms/OpenAI.ts +++ b/core/llm/llms/OpenAI.ts @@ -40,6 +40,8 @@ const CHAT_ONLY_MODELS = [ class OpenAI extends BaseLLM { public useLegacyCompletionsEndpoint: boolean | undefined = undefined; + protected maxStopWords: number | undefined = undefined; + constructor(options: LLMOptions) { super(options); this.useLegacyCompletionsEndpoint = options.useLegacyCompletionsEndpoint; @@ -87,9 +89,11 @@ class OpenAI extends BaseLLM { presence_penalty: options.presencePenalty, stop: // Jan + Azure OpenAI don't truncate and will throw an error - url.port === "1337" || - url.host === "api.openai.com" || - this.apiType === "azure" + this.maxStopWords !== undefined + ? options.stop?.slice(0, this.maxStopWords) + : url.port === "1337" || + url.host === "api.openai.com" || + this.apiType === "azure" ? options.stop?.slice(0, 4) : options.stop, }; diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 553cefaa4..c5f011a5c 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1735,6 +1735,11 @@ }, "apiBase": { "type": "string" + }, + "requestOptions": { + "title": "Request Options", + "description": "Request options to be used in any fetch requests made by the embeddings provider", + "$ref": "#/definitions/RequestOptions" } }, "required": ["provider"], diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 553cefaa4..c5f011a5c 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -1735,6 +1735,11 @@ }, "apiBase": { "type": "string" + }, + "requestOptions": { + "title": "Request Options", + "description": "Request options to be used in any fetch requests made by the embeddings provider", + "$ref": "#/definitions/RequestOptions" } }, "required": ["provider"], diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 45b08da76..f0e53cad3 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -1926,6 +1926,11 @@ }, "apiBase": { "type": "string" + }, + "requestOptions": { + "title": "Request Options", + "description": "Request options to be used in any fetch requests made by the embeddings provider", + "$ref": "#/definitions/RequestOptions" } }, "required": [