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

Chat: automatic answers & translations #3051

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

svenseeberg
Copy link
Member

@svenseeberg svenseeberg commented Sep 14, 2024

Short description

Implement machine translations for chat & retrieval augmented answer generation

Proposed changes

  • Create a relation between chats, the region and language
  • Make the Zammad URL unique
  • Create a new end point for Zammad Webhooks, which is used to trigger translations and automatic answers
  • Add automatic translations for incoming and outgoing messages
  • Add a property that informs which chat messages were created automatically
  • Add automatic answers to app user messages

Side effects

  • Existing chats are not assigned to any region and therefore not accessible anymore. As we only had an alpha testing phase, this should be of no concern.

Resolved issues

Fixes: #3040


Pull Request Review Guidelines

@svenseeberg svenseeberg force-pushed the feature/chat-translations-and-answers branch 2 times, most recently from 05ecad7 to 4e732b2 Compare September 14, 2024 11:35
@@ -219,6 +219,7 @@
#: The url patterns of this module (see :doc:`django:topics/http/urls`)
urlpatterns: list[URLPattern] = [
path("api/v3/regions/", include(region_api_urlpatterns)),
path("api/v3/webhook/zammad/", user_chat.zammad_webhook, name="zammad_webhook"),
Copy link
Member Author

Choose a reason for hiding this comment

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

Please note: /api/v3/webhook/... is a generic new path for webhooks.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -417,6 +417,7 @@ class Region(AbstractBaseModel):
max_length=256,
blank=True,
default="",
unique=True,
Copy link
Member Author

@svenseeberg svenseeberg Sep 19, 2024

Choose a reason for hiding this comment

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

We cannot allow to regions to use the same Zammad server, because we need the reverse look up of the Zammad server IP during webhooks to get the region to which the Zammad belongs. One Zammad server per region is also good for privacy reasons as Zammad does not have a functionality to strictly separate regions (groups and roles are possible though), but admins are always global.

model_name="userchat",
name="language",
field=models.ForeignKey(
default=3,
Copy link
Member Author

Choose a reason for hiding this comment

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

All existing chat which were created during the first test phase, will be assigned the German language. There is no other good solution.

@svenseeberg svenseeberg force-pushed the feature/chat-translations-and-answers branch from f2582cd to dfcf067 Compare September 23, 2024 15:43
Copy link

codeclimate bot commented Sep 23, 2024

Code Climate has analyzed commit 5c0112a and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 55.7% (50% is the threshold).

This pull request will bring the total coverage in the repository to 82.6% (-0.1% change).

View more on Code Climate.

@svenseeberg svenseeberg force-pushed the feature/chat-translations-and-answers branch from 678caec to 1c447a3 Compare September 23, 2024 18:16
@svenseeberg svenseeberg marked this pull request as ready for review September 23, 2024 18:26
@svenseeberg svenseeberg requested a review from a team September 23, 2024 18:26
@svenseeberg svenseeberg changed the title Add automatic translation for incoming message Chat: automatic answers & translations Sep 23, 2024
Copy link
Member

@MizukiTemma MizukiTemma left a comment

Choose a reason for hiding this comment

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

🚀

@svenseeberg
Copy link
Member Author

This pull request will bring the total coverage in the repository to 82.6% (-0.2% change).

This hurts a bit, I guess 🙈

Copy link
Member

@david-venhoff david-venhoff left a comment

Choose a reason for hiding this comment

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

Not a full review, just some questions I got from a quick look.

Also, is there / should there be any protection in place to avoid unauthorized people using this api?

@@ -219,6 +219,7 @@
#: The url patterns of this module (see :doc:`django:topics/http/urls`)
urlpatterns: list[URLPattern] = [
path("api/v3/regions/", include(region_api_urlpatterns)),
path("api/v3/webhook/zammad/", user_chat.zammad_webhook, name="zammad_webhook"),
Copy link
Member

Choose a reason for hiding this comment

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

integreat_cms/api/v3/chat/user_chat.py Show resolved Hide resolved
@svenseeberg svenseeberg force-pushed the feature/chat-translations-and-answers branch 2 times, most recently from f8dcf79 to d4fd16e Compare September 24, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Machine translations for Integreat Chat messages
3 participants