Fix a ReferenceError when using OpenAI.backgroundCreateChatCompletion

This commit is contained in:
Eric Allam
2023-11-03 22:41:23 +00:00
parent 330ddb3311
commit 02e453c3b5
2 changed files with 23 additions and 8 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@trigger.dev/openai": patch
---
Fix a ReferenceError when using backgroundCreateChatCompletion
+18 -8
View File
@@ -10,15 +10,15 @@ import {
type TriggerIntegration,
} from "@trigger.dev/sdk";
import OpenAIApi from "openai";
import { Models } from "./models";
import { OpenAIIntegrationOptions } from "./types";
import { Completions } from "./completions";
import { Chat } from "./chat";
import { Completions } from "./completions";
import { Edits } from "./edits";
import { Images } from "./images";
import { Embeddings } from "./embeddings";
import { Files } from "./files";
import { FineTunes } from "./fineTunes";
import { Images } from "./images";
import { Models } from "./models";
import { OpenAIIntegrationOptions } from "./types";
export type OpenAIRunTask = InstanceType<typeof OpenAI>["runTask"];
@@ -153,19 +153,29 @@ export class OpenAI implements TriggerIntegration {
return new FineTunes(this.runTask.bind(this));
}
// this provides backwards compatibility for the old API
retrieveModel = this.models.retrieve;
listModels = this.models.list;
deleteModel = this.models.delete;
deleteFineTune = this.models.delete;
createCompletion = this.completions.create;
backgroundCreateCompletion = this.completions.backgroundCreate;
createChatCompletion = this.chat.completions.create;
backgroundCreateChatCompletion = this.chat.completions.backgroundCreate;
/**
* @deprecated The Edits API is deprecated; please use Chat Completions instead.
* @deprecated Please use openai.completions.backgroundCreate instead
*/
async backgroundCreateCompletion(...args: Parameters<typeof this.completions.backgroundCreate>) {
return this.completions.backgroundCreate(...args);
}
/**
* @deprecated Please use openai.chat.completions.backgroundCreate instead
*/
async backgroundCreateChatCompletion(
...args: Parameters<typeof this.chat.completions.backgroundCreate>
) {
return this.chat.completions.backgroundCreate(...args);
}
createEdit = this.edits.create;
generateImage = this.images.generate;
createImage = this.images.generate;