Skip to content

Commit

Permalink
Merge pull request #277 from elie222/simplify-ai-fix-rule
Browse files Browse the repository at this point in the history
Simplify fix rule flow
  • Loading branch information
elie222 authored Dec 22, 2024
2 parents b63cc36 + a13733e commit 6fadf47
Show file tree
Hide file tree
Showing 6 changed files with 546 additions and 360 deletions.
26 changes: 13 additions & 13 deletions apps/web/__tests__/ai-rule-fix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ describe.skipIf(!isAiTest)("aiRuleFix", () => {
});

const result = await aiRuleFix({
incorrectRule: rule,
correctRule: null,
actualRule: rule,
expectedRule: null,
email: salesEmail,
user: getUser(),
});

console.log(result);

expect(result).toBeDefined();
expect(result.rule).toBe("matched_rule");
expect(result.rule).toBe("actual_rule");
expect(result.fixedInstructions).toContain("sales");
expect(result.fixedInstructions).not.toBe(rule.instructions);
// The new instructions should be more specific to exclude sales pitches
Expand All @@ -51,10 +51,10 @@ describe.skipIf(!isAiTest)("aiRuleFix", () => {
});

test("should fix rules when email matched wrong rule instead of correct rule", async () => {
const incorrectRule = {
const actualRule = {
instructions: "Match emails about technical support and bug reports",
};
const correctRule = {
const expectedRule = {
instructions: "Match emails about product feedback and feature requests",
};

Expand All @@ -72,8 +72,8 @@ describe.skipIf(!isAiTest)("aiRuleFix", () => {
});

const result = await aiRuleFix({
incorrectRule,
correctRule,
actualRule,
expectedRule,
email: feedbackEmail,
user: getUser(),
});
Expand All @@ -90,7 +90,7 @@ describe.skipIf(!isAiTest)("aiRuleFix", () => {
});

test("should fix rule when email matched but shouldn't match any rules", async () => {
const incorrectRule = {
const actualRule = {
instructions: "Match emails about marketing collaborations",
};

Expand All @@ -108,16 +108,16 @@ describe.skipIf(!isAiTest)("aiRuleFix", () => {
});

const result = await aiRuleFix({
incorrectRule,
correctRule: null,
actualRule,
expectedRule: null,
email: newsletterEmail,
user: getUser(),
});

console.log(result);

expect(result).toBeDefined();
expect(result.rule).toBe("matched_rule");
expect(result.rule).toBe("actual_rule");
expect(result.fixedInstructions).toContain("collaboration");
// The fixed rule should exclude newsletters and automated updates
expect(result.fixedInstructions.toLowerCase()).toMatch(
Expand All @@ -144,8 +144,8 @@ describe.skipIf(!isAiTest)("aiRuleFix", () => {
});

const result = await aiRuleFix({
incorrectRule: null,
correctRule,
actualRule: null,
expectedRule: correctRule,
email: priceRequestEmail,
user: getUser(),
});
Expand Down
Loading

1 comment on commit 6fadf47

@vercel
Copy link

@vercel vercel bot commented on 6fadf47 Dec 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.