MCPcopy
hub / github.com/di-sukharev/opencommit / _createChatCompletion

Method _createChatCompletion

out/cli.cjs:82442–82460  ·  view source on GitHub ↗
(client, params, options)

Source from the content-addressed store, hash-verified

82440 runner._run(() => runner._fromReadableStream(stream4));
82441 return runner;
82442 }
82443 static createChatCompletion(client, params, options) {
82444 const runner = new _ChatCompletionStream(params);
82445 runner._run(() => runner._runChatCompletion(client, { ...params, stream: true }, { ...options, headers: { ...options?.headers, "X-Stainless-Helper-Method": "stream" } }));
82446 return runner;
82447 }
82448 async _createChatCompletion(client, params, options) {
82449 super._createChatCompletion;
82450 const signal = options?.signal;
82451 if (signal) {
82452 if (signal.aborted)
82453 this.controller.abort();
82454 signal.addEventListener("abort", () => this.controller.abort());
82455 }
82456 __classPrivateFieldGet11(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
82457 const stream4 = await client.chat.completions.create({ ...params, stream: true }, { ...options, signal: this.controller.signal });
82458 this._connected();
82459 for await (const chunk of stream4) {
82460 __classPrivateFieldGet11(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_addChunk).call(this, chunk);
82461 }
82462 if (stream4.controller.signal?.aborted) {
82463 throw new APIUserAbortError3();

Callers

nothing calls this directly

Calls 5

__classPrivateFieldGet11Function · 0.85
_addChatCompletionMethod · 0.80
abortMethod · 0.45
createMethod · 0.45
_connectedMethod · 0.45

Tested by

no test coverage detected