feat: Enhance result analysis and error display

This commit is contained in:
AG
2025-10-11 17:38:31 +03:00
parent 4c420acc08
commit 641caf74eb
8 changed files with 56 additions and 103 deletions

View File

@@ -10,11 +10,11 @@ interface DesireSet {
interface Decision {
goTo: string[];
alsoGood: string[];
considerable: string[];
noGoes: string[];
needsDiscussion: string[];
goTo: string;
alsoGood: string;
considerable: string;
noGoes: string;
needsDiscussion: string;
}
export class LLMService {
@@ -28,24 +28,24 @@ export class LLMService {
async analyzeDesires(desireSets: DesireSet[]): Promise<Decision> {
const prompt = `
You are an AI assistant that analyzes and categorizes user desires from a session. Given a list of desire sets from multiple participants, your task is to categorize them into the following groups: "goTo", "alsoGood", "considerable", "noGoes", and "needsDiscussion".
You are an AI assistant that analyzes and synthesizes cooperative decisions from a group's desires. Given a list of desire sets from multiple participants, your task is to generate a concise, synthesized text for each of the following categories, reflecting the collective opinion:
Here are the rules for categorization:
- "goTo": Items that ALL participants want.
- "alsoGood": Items that at least one participant wants, and all other participants accept.
- "considerable": Items that are wanted or accepted by some, but not all, participants, and are not "noGoes" for anyone.
- "noGoes": Items that at least ONE participant does not want. These items must be excluded from all other categories.
- "needsDiscussion": Items where there is a direct conflict (e.g., one participant wants it, another does not want it).
Here are the rules for categorization and synthesis:
- "goTo": Synthesize a text describing what ALL participants want without contradictions. This should be a clear, affirmative statement of shared desire.
- "alsoGood": Synthesize a text describing what at least one participant wants, and all other participants accept, and is not a "noGoes" for anyone. This should reflect a generally agreeable outcome.
- "considerable": Synthesize a text describing what is wanted or accepted by some, but not all, participants, and is not a "noGoes" for anyone. This should highlight areas of partial agreement or options that could be explored.
- "noGoes": Synthesize a text describing what at least ONE participant does not want. This should clearly state the collective exclusions.
- "needsDiscussion": Synthesize a text describing where there is a direct conflict (e.g., one participant wants it, another does not want it). This should highlight areas requiring further negotiation.
The input will be a JSON object containing a list of desire sets. Each desire set has a participantId and three arrays of strings: "wants", "accepts", and "noGoes".
The output should be a JSON object with the following structure:
The output should be a JSON object with the following structure, where each category contains a single synthesized text:
{
"goTo": ["item1", "item2"],
"alsoGood": ["item3"],
"considerable": ["item4"],
"noGoes": ["item5"],
"needsDiscussion": ["item6"]
"goTo": "Synthesized text for go-to items.",
"alsoGood": "Synthesized text for also good items.",
"considerable": "Synthesized text for considerable items.",
"noGoes": "Synthesized text for no-goes items.",
"needsDiscussion": "Synthesized text for needs discussion items."
}
Here is the input data:
@@ -76,7 +76,7 @@ export class LLMService {
async checkForInnerContradictions(desireSet: DesireSet): Promise<boolean> {
const prompt = `
You are an AI assistant that detects contradictions in a list of desires. Given a JSON object with three lists of desires (wants, accepts, noGoes), determine if there are any contradictions WITHIN each list. For example, "I want a dog" and "I don't want any pets" in the same "wants" list is a contradiction. Respond with only "true" if a contradiction is found, and "false" otherwise.
You are an AI assistant that detects contradictions in a list of desires. Given a JSON object with three lists of desires (wants, accepts, noGoes), determine if there are any contradictions WITHIN each list and across the lists. For example, "I want a dog" and "I don't want any pets" in the same "wants" list is a contradiction; "Pizza" in "wants" and "food" in "do not want" is a contradiction. Respond with only "true" if a contradiction is found, and "false" otherwise.
Here is the desire set:
${JSON.stringify(desireSet)}
@@ -88,9 +88,8 @@ export class LLMService {
const text = response.text().trim().toLowerCase();
return text === 'true';
} catch (error) {
console.error("Error calling Gemini API for contradiction check:", error);
throw error;
}
}
}
console.error("Error calling Gemini API for contradiction check:", error);
throw error;
}
}
}

View File

@@ -4,11 +4,11 @@ import { v4 as uuidv4 } from 'uuid';
// Types from the frontend
interface Decision {
goTo: string[];
alsoGood: string[];
considerable: string[];
noGoes: string[];
needsDiscussion: string[];
goTo: string;
alsoGood: string;
considerable: string;
noGoes: string;
needsDiscussion: string;
}
// Define the SessionState enum