MCPcopy Create free account
hub / github.com/continuedev/continue / streamFim

Function streamFim

core/llm/index.ts:587–701  ·  view source on GitHub ↗
(
    prefix: string,
    suffix: string,
    signal: AbortSignal,
    options: LLMFullCompletionOptions = {},
  )

Source from the content-addressed store, hash-verified

585 }
586
587 async *streamFim(
588 prefix: string,
589 suffix: string,
590 signal: AbortSignal,
591 options: LLMFullCompletionOptions = {},
592 ): AsyncGenerator<string> {
593 this.lastRequestId = undefined;
594 const { completionOptions, logEnabled } =
595 this._parseCompletionOptions(options);
596 const interaction = logEnabled
597 ? this.logger?.createInteractionLog()
598 : undefined;
599 let status: InteractionStatus = "in_progress";
600
601 const fimLog = `Prefix: ${prefix}\nSuffix: ${suffix}`;
602 if (logEnabled) {
603 interaction?.logItem({
604 kind: "startFim",
605 prefix,
606 suffix,
607 options: completionOptions,
608 provider: this.providerName,
609 });
610 if (this.llmRequestHook) {
611 this.llmRequestHook(completionOptions.model, fimLog);
612 }
613 }
614
615 let completion = "";
616 try {
617 if (this.shouldUseOpenAIAdapter("streamFim") && this.openaiAdapter) {
618 const stream = this.openaiAdapter.fimStream(
619 toFimBody(prefix, suffix, completionOptions),
620 signal,
621 );
622 for await (const chunk of stream) {
623 if (!this.lastRequestId && typeof (chunk as any).id === "string") {
624 this.lastRequestId = (chunk as any).id;
625 }
626 const result = fromChatCompletionChunk(chunk);
627 if (result) {
628 const content = renderChatMessage(result);
629 const formattedContent = this._formatChatMessage(result);
630 interaction?.logItem({
631 kind: "chunk",
632 chunk: formattedContent,
633 });
634
635 completion += formattedContent;
636 yield content;
637 }
638 }
639 } else {
640 for await (const chunk of this._streamFim(
641 prefix,
642 suffix,
643 signal,
644 completionOptions,

Callers

nothing calls this directly

Calls 8

toFimBodyFunction · 0.85
fromChatCompletionChunkFunction · 0.85
renderChatMessageFunction · 0.85
errorMethod · 0.80
createInteractionLogMethod · 0.65
logItemMethod · 0.65
fimStreamMethod · 0.65
_streamFimMethod · 0.45

Tested by

no test coverage detected