mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-07 07:55:16 +02:00
22 lines
517 B
TypeScript
22 lines
517 B
TypeScript
|
|
import type { ConversationItem } from "./types";
|
||
|
|
|
||
|
|
export function formatConversationValue(value: unknown) {
|
||
|
|
if (value == null) {
|
||
|
|
return "None";
|
||
|
|
}
|
||
|
|
if (typeof value === "string") {
|
||
|
|
return value;
|
||
|
|
}
|
||
|
|
try {
|
||
|
|
return JSON.stringify(value, null, 2);
|
||
|
|
} catch {
|
||
|
|
return String(value);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export function countConversationMessages(items: ConversationItem[]) {
|
||
|
|
return items.filter(
|
||
|
|
(item) => item.kind === "message" && item.tone !== "muted",
|
||
|
|
).length;
|
||
|
|
}
|