Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart replies for mail #8863

Merged
merged 1 commit into from
Jan 12, 2024
Merged

Smart replies for mail #8863

merged 1 commit into from
Jan 12, 2024

Conversation

hamza221
Copy link
Contributor

@hamza221 hamza221 commented Sep 13, 2023

Fixes #8505

Composer Message
image image
  • Add caching
  • Fix composer update
  • unit tests
  • Better prompt
  • Work on email body, not preview text

For now at least one prompt is executed for every opened message

  • Find a way to filter out Promotional / generated emails without the use of LLM

@ChristophWurst
Copy link
Member

ChristophWurst commented Jan 8, 2024

POC of #8505

What's missing for a MVP?

@hamza221
Copy link
Contributor Author

hamza221 commented Jan 8, 2024

What's missing for a MVC?

I'm still not confident about the method of detecting Personal vs non personal emails, aside from that, nothing ig

@JohannesGGE
Copy link
Contributor

Is there anything to consider while testing? I dont't get any reply suggestions. Tried simple mails like in your screenshot. http://nextcloud.local/index.php/apps/mail/api/messages/3/smartreply answers with 200, but empty response.

@hamza221
Copy link
Contributor Author

hamza221 commented Jan 8, 2024

Is there anything to consider while testing? I dont't get any reply suggestions. Tried simple mails like in your screenshot. http://nextcloud.local/index.php/apps/mail/api/messages/3/smartreply answers with 200, but empty response.

If you're getting 200 that means they're getting flagged as generated mails, for some reason. Can you please add a breakpoint and check if its because of isPersonalEmail() or LLM output ?

@hamza221
Copy link
Contributor Author

hamza221 commented Jan 8, 2024

image

I started getting this bug, I would say a way around it would be to prompt the LLM twice, once for each reply, what do you think @ChristophWurst ?

edit/further explanation:
the prompt I'm using
$prompt = "Suggest 2 quick replies a maximum of 25 character per answer for this email seperated by | :".$messageBody."";

I don't think we can trust it to give us a reply in that format every time

@ChristophWurst
Copy link
Member

IMO we can fine-tune the prompts as we test the feature. E.g. I tried Suggest 2 replies to the following email. Each reply should be 25 characters max. Separate the replies with "|", like for example "Yes! | No, I'm not available". Do not print anything else. The email contents are "<email>" and it gives a consistent output format.

@hamza221 hamza221 changed the title poc for smart replies Smart replies for mail Jan 8, 2024
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Like with thread summaries we should offer a way to turn this feature off by admins

lib/Service/AiIntegrations/AiIntegrationsService.php Outdated Show resolved Hide resolved
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Tested against chatgpt3.5 & works

The suggestions are OK, some are a bit absurd. But that's fine, we can improve the prompt 👍

lib/Service/AiIntegrations/AiIntegrationsService.php Outdated Show resolved Hide resolved
lib/Service/AiIntegrations/AiIntegrationsService.php Outdated Show resolved Hide resolved
lib/Service/AiIntegrations/AiIntegrationsService.php Outdated Show resolved Hide resolved
lib/Service/AiIntegrations/AiIntegrationsService.php Outdated Show resolved Hide resolved
@hamza221 hamza221 force-pushed the feat/suggest-replies branch 2 times, most recently from ff88183 to ac6b6c2 Compare January 10, 2024 19:17
@ChristophWurst
Copy link
Member

OCA\Mail\Tests\Unit\Service\AiIntegrationsServiceTest::testCached

This test did not perform any assertions

Signed-off-by: hamza221 <[email protected]>
Signed-off-by: hamza mahjoubi <[email protected]>
@hamza221 hamza221 merged commit 81e0746 into main Jan 12, 2024
37 checks passed
@hamza221 hamza221 deleted the feat/suggest-replies branch January 12, 2024 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggested replies for email
3 participants