fix(openai/completions): use old method for instruct/davinci/text gen models (#1166)

This commit is contained in:
Danny Avila 2023-11-10 10:33:56 -05:00 committed by GitHub
parent d5259e1525
commit 9ca84edb9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -367,7 +367,7 @@ If your reverse proxy is compatible to OpenAI specs in every other way, it may s
let streamResult = null; let streamResult = null;
this.modelOptions.user = this.user; this.modelOptions.user = this.user;
const invalidBaseUrl = this.completionsUrl && extractBaseURL(this.completionsUrl) === null; const invalidBaseUrl = this.completionsUrl && extractBaseURL(this.completionsUrl) === null;
const useOldMethod = !!(this.azure || invalidBaseUrl); const useOldMethod = !!(this.azure || invalidBaseUrl || !this.isChatCompletion);
if (typeof opts.onProgress === 'function' && useOldMethod) { if (typeof opts.onProgress === 'function' && useOldMethod) {
await this.getCompletion( await this.getCompletion(
payload, payload,
@ -702,9 +702,10 @@ ${convo}
if (typeof onProgress === 'function') { if (typeof onProgress === 'function') {
modelOptions.stream = true; modelOptions.stream = true;
} }
if (this.isChatGptModel) { if (this.isChatCompletion) {
modelOptions.messages = payload; modelOptions.messages = payload;
} else { } else {
// TODO: unreachable code. Need to implement completions call for non-chat models
modelOptions.prompt = payload; modelOptions.prompt = payload;
} }