@@ -10,6 +10,9 @@ import { generateTitle } from "@/src/lib/ollama/title";
1010 /**
1111 * Extracts tool name counts from an array of tool calls.
1212 * Returns a JSON string of the format: {"tool_name": count, ...}
13+ *
14+ * @param toolCalls - Array of tool calls to count
15+ * @returns JSON string of tool name counts, or null if empty
1316 */
1417 export function extractToolCounts(toolCalls: ToolCall[]): string | null {
1518 if (toolCalls.length === 0) return null;
@@ -35,6 +38,15 @@ export interface SaveMessageParams {
3538 /**
3639 * Saves an assistant message to the database and updates the thread's updatedAt timestamp.
3740 * Also generates and updates the thread title from the message history.
41+ *
42+ * @param params - Object containing message data
43+ * @param params.threadId - Thread ID to save message to
44+ * @param params.content - Message content
45+ * @param params.model - Model used for generation
46+ * @param params.maxPromptLength - Max prompt length setting
47+ * @param params.generationTimeMs - Generation time in milliseconds
48+ * @param params.toolCallCounts - JSON string of tool call counts
49+ * @returns Promise that resolves when message is saved
3850 */
3951 export async function saveAssistantMessage(params: SaveMessageParams): Promise<void> {
4052 const { threadId, content, model, maxPromptLength, generationTimeMs, toolCallCounts } = params;