.
This commit is contained in:
1 parent
7fa293c9e8
commit
ae44aa03db
67 files changed
+6164
-243
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import type { ConversationMessage } from "@agent/types";
|
||||
import type { GarnetClient } from "@common/garnet";
|
||||
import { getRequestLogger } from "@obs/context";
|
||||
import {
|
||||
getBackgroundStreamMaxLen,
|
||||
getConversationTtlSeconds,
|
||||
@@ -52,17 +53,24 @@ export class ConversationStore {
|
||||
await this.garnetClient.setJson(key, trimmed, getConversationTtlSeconds());
|
||||
|
||||
if (trimmed.length > 5) {
|
||||
await this.garnetClient.appendStream(
|
||||
BACKGROUND_STREAM_KEY,
|
||||
{
|
||||
type: "summarize",
|
||||
chatroomId,
|
||||
userId,
|
||||
},
|
||||
{
|
||||
maxLen: getBackgroundStreamMaxLen(),
|
||||
},
|
||||
);
|
||||
void this.garnetClient
|
||||
.appendStream(
|
||||
BACKGROUND_STREAM_KEY,
|
||||
{
|
||||
type: "summarize",
|
||||
chatroomId,
|
||||
userId,
|
||||
},
|
||||
{
|
||||
maxLen: getBackgroundStreamMaxLen(),
|
||||
},
|
||||
)
|
||||
.catch((error) => {
|
||||
getRequestLogger().warn(
|
||||
{ err: error, chatroomId, userId },
|
||||
"[ConversationStore] Failed to publish summarize job",
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ function formatHistory(history: ConversationMessage[]): string {
|
||||
export async function summarizeConversation(
|
||||
llmClient: LlmClient,
|
||||
history: ConversationMessage[],
|
||||
existingSummary?: string | undefined,
|
||||
existingSummary?: string,
|
||||
): Promise<string> {
|
||||
if (!llmClient.hasEndpoints() || history.length === 0) {
|
||||
return existingSummary ?? "";
|
||||
|
||||
Reference in new issue
Block a user