mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Filter out empty assistant messages when saving the history file
This commit is contained in:
1 file changed
+4
@@ -1,6 +1,7 @@
|
||||
import { join } from "path-browserify";
|
||||
import type OpenAI from "openai";
|
||||
import type { JSRuntimeFS } from "./JSRuntime";
|
||||
import { isEmptyMessage } from "./isEmptyMessage";
|
||||
|
||||
/** AI message history manager and .git/ai directory utilities */
|
||||
export class DotAI {
|
||||
@@ -46,6 +47,9 @@ export class DotAI {
|
||||
sessionName: string,
|
||||
messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[],
|
||||
): Promise<void> {
|
||||
// Filter out empty assistant messages
|
||||
messages = messages.filter((msg) => !isEmptyMessage(msg));
|
||||
|
||||
// Validate messages before saving
|
||||
this.validateMessages(messages);
|
||||
|
||||
|
||||
Reference in new issue
Block a user