(
key: IntegrationTaskKey,
callback: (client: OpenAIApi, task: IOTask, io: IO) => Promise<TResult>,
options?: RunTaskOptions,
errorCallback?: RunTaskErrorCallback
)
| 99 | } |
| 100 | |
| 101 | runTask<T, TResult extends Json<T> | void>( |
| 102 | key: IntegrationTaskKey, |
| 103 | callback: (client: OpenAIApi, task: IOTask, io: IO) => Promise<TResult>, |
| 104 | options?: RunTaskOptions, |
| 105 | errorCallback?: RunTaskErrorCallback |
| 106 | ): Promise<TResult> { |
| 107 | if (!this._io) |
| 108 | throw new Error( |
| 109 | "Issue with running task: IO not found. It's possible that you forgot to prefix openai with io. inside a run" |
| 110 | ); |
| 111 | if (!this._connectionKey) throw new Error("No connection key"); |
| 112 | return this._io.runTask( |
| 113 | key, |
| 114 | (task, io) => { |
| 115 | if (!this._client) throw new Error("No client"); |
| 116 | return callback(this._client, task, io); |
| 117 | }, |
| 118 | { |
| 119 | icon: this._options.icon ?? "openai", |
| 120 | retry: retry.exponentialBackoff, |
| 121 | ...(options ?? {}), |
| 122 | connectionKey: this._connectionKey, |
| 123 | }, |
| 124 | errorCallback |
| 125 | ); |
| 126 | } |
| 127 | |
| 128 | get models() { |
| 129 | return new Models(this.runTask.bind(this)); |
no outgoing calls
no test coverage detected