🎨 maxStopWords for Groq
This commit is contained in:
parent
cb1be8a8ac
commit
0dc7e1b9fe
5 changed files with 23 additions and 3 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
5
docs/static/schemas/config.json
vendored
5
docs/static/schemas/config.json
vendored
|
|
@ -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"],
|
||||
|
|
|
|||
|
|
@ -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"],
|
||||
|
|
|
|||
|
|
@ -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": [
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue