Skip to content

Commit

Permalink
feat: update summarizeGroupOpinions to return keyword strength and mo…
Browse files Browse the repository at this point in the history
…dify chatWithLLMByDocs to track subtask completion
  • Loading branch information
TakalaWang committed Dec 25, 2024
1 parent b5abcba commit 9ef5814
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/lib/server/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,12 @@ export async function summarizeGroupOpinions(student_opinion: StudentSpeak[]): P
);
const summary_group_opinion_schema = z.object({
group_summary: z.string(),
group_key_points: z.record(z.string(), z.number().min(1).max(5))
group_keywords: z.array(
z.object({
keyword: z.string(),
strength: z.number()
})
)
});

const response = await requestZodLLM(system_prompt, summary_group_opinion_schema);
Expand All @@ -427,11 +432,15 @@ export async function summarizeGroupOpinions(student_opinion: StudentSpeak[]): P
}

const message = response.message as z.infer<typeof summary_group_opinion_schema>;
const formatted_keywords = message.group_keywords.reduce(
(acc, keyword) => ({ ...acc, [keyword.keyword]: keyword.strength }),
{} as Record<string, number>
);

return {
success: true,
summary: message.group_summary,
keywords: message.group_key_points
keywords: formatted_keywords
};
} catch (error) {
console.error('Error in summarizeGroupOpinions:', error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ export const GET: RequestHandler = async ({ params, locals }) => {
const group_ref = getGroupRef(id, group_number);
const group_data = await getGroupData(group_ref);

const intro = await chatWithLLMByDocs([], task, subtasks, resources);
const intro = await chatWithLLMByDocs(
[],
task,
subtasks,
new Array(subtasks.length).fill(false),
resources
);
if (!intro) {
throw error(500, 'Error generating intro message');
}
Expand Down

0 comments on commit 9ef5814

Please sign in to comment.