messaging
This commit is contained in:
parent
688b10bbd5
commit
680c984af7
4 changed files with 0 additions and 50 deletions
40
core/core.ts
40
core/core.ts
|
|
@ -37,7 +37,6 @@ import { TTS } from "./util/tts";
|
|||
|
||||
import {
|
||||
DiffLine,
|
||||
PromptLog,
|
||||
type ContextItemId,
|
||||
type IDE,
|
||||
type IndexingProgressUpdate,
|
||||
|
|
@ -496,45 +495,6 @@ export class Core {
|
|||
),
|
||||
);
|
||||
|
||||
async function* llmStreamComplete(
|
||||
configHandler: ConfigHandler,
|
||||
abortedMessageIds: Set<string>,
|
||||
msg: Message<ToCoreProtocol["llm/streamComplete"][0]>,
|
||||
): AsyncGenerator<string, PromptLog> {
|
||||
const model = await configHandler.llmFromTitle(msg.data.title);
|
||||
const gen = model.streamComplete(
|
||||
msg.data.prompt,
|
||||
new AbortController().signal,
|
||||
msg.data.completionOptions,
|
||||
);
|
||||
let next = await gen.next();
|
||||
while (!next.done) {
|
||||
if (abortedMessageIds.has(msg.messageId)) {
|
||||
abortedMessageIds.delete(msg.messageId);
|
||||
next = await gen.return({
|
||||
modelTitle: model.title ?? model.model,
|
||||
completion: "",
|
||||
prompt: "",
|
||||
completionOptions: {
|
||||
...msg.data.completionOptions,
|
||||
model: model.model,
|
||||
},
|
||||
});
|
||||
break;
|
||||
}
|
||||
yield next.value;
|
||||
next = await gen.next();
|
||||
}
|
||||
if (!next.done) {
|
||||
throw new Error("This will never happen");
|
||||
}
|
||||
return next.value;
|
||||
}
|
||||
|
||||
on("llm/streamComplete", (msg) =>
|
||||
llmStreamComplete(this.configHandler, this.abortedMessageIds, msg),
|
||||
);
|
||||
|
||||
on("llm/complete", async (msg) => {
|
||||
const model = await this.configHandler.llmFromTitle(msg.data.title);
|
||||
const completion = await model.complete(
|
||||
|
|
|
|||
|
|
@ -111,14 +111,6 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
string,
|
||||
];
|
||||
"llm/listModels": [{ title: string }, string[] | undefined];
|
||||
"llm/streamComplete": [
|
||||
{
|
||||
prompt: string;
|
||||
completionOptions: LLMFullCompletionOptions;
|
||||
title: string;
|
||||
},
|
||||
AsyncGenerator<string>,
|
||||
];
|
||||
"llm/streamChat": [
|
||||
{
|
||||
messages: ChatMessage[];
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"autocomplete/accept",
|
||||
"tts/kill",
|
||||
"llm/complete",
|
||||
"llm/streamComplete",
|
||||
"llm/streamChat",
|
||||
"llm/listModels",
|
||||
"streamDiffLines",
|
||||
|
|
|
|||
|
|
@ -105,7 +105,6 @@ class MessageTypes {
|
|||
"autocomplete/accept",
|
||||
"tts/kill",
|
||||
"llm/complete",
|
||||
"llm/streamComplete",
|
||||
"llm/streamChat",
|
||||
"llm/listModels",
|
||||
"streamDiffLines",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue