mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +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 { join } from "path-browserify";
|
||||||
import type OpenAI from "openai";
|
import type OpenAI from "openai";
|
||||||
import type { JSRuntimeFS } from "./JSRuntime";
|
import type { JSRuntimeFS } from "./JSRuntime";
|
||||||
|
import { isEmptyMessage } from "./isEmptyMessage";
|
||||||
|
|
||||||
/** AI message history manager and .git/ai directory utilities */
|
/** AI message history manager and .git/ai directory utilities */
|
||||||
export class DotAI {
|
export class DotAI {
|
||||||
@@ -46,6 +47,9 @@ export class DotAI {
|
|||||||
sessionName: string,
|
sessionName: string,
|
||||||
messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[],
|
messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[],
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
// Filter out empty assistant messages
|
||||||
|
messages = messages.filter((msg) => !isEmptyMessage(msg));
|
||||||
|
|
||||||
// Validate messages before saving
|
// Validate messages before saving
|
||||||
this.validateMessages(messages);
|
this.validateMessages(messages);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user