🎨 maxStopWords for Groq

This commit is contained in:
Nate Sesti 2024-04-26 09:27:08 -07:00
parent cb1be8a8ac
commit 0dc7e1b9fe
5 changed files with 23 additions and 3 deletions

View file

@ -6,6 +6,7 @@ class Groq extends OpenAI {
static defaultOptions: Partial<LLMOptions> = {
apiBase: "https://api.groq.com/openai/v1/",
};
protected maxStopWords: number | undefined = 4;
private static modelConversion: { [key: string]: string } = {
"llama2-70b": "llama2-70b-4096",

View file

@ -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,
};

View file

@ -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"],

View file

@ -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"],

View file

@ -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": [