Skip to content

enhance: add LLM translation support with openai compatible API#15697

Open
ybw2016v wants to merge 9 commits intomisskey-dev:developfrom
ybw2016v:develop
Open

enhance: add LLM translation support with openai compatible API#15697
ybw2016v wants to merge 9 commits intomisskey-dev:developfrom
ybw2016v:develop

Conversation

@ybw2016v
Copy link
Copy Markdown
Contributor

What

Add LLM translation support with openai compatible API

Why

#15696

Additional info (optional)

  1. To achieve the best results, the control parameters and prompt words should be adapted to the model. For details, please refer to the model documentation.
  2. An optional redis cache switch is provided to cache API call results to reduce possible costs.

Checklist

  • Read the contribution guide
  • Test working in a local environment
  • (If needed) Add story of storybook
  • (If needed) Update CHANGELOG.md
  • (If possible) Add tests

@github-actions github-actions Bot added packages/frontend Client side specific issue/PR packages/backend Server side specific issue/PR labels Mar 22, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 22, 2025

このPRによるapi.jsonの差分

差分はこちら
--- base
+++ head
@@ -9993,6 +9993,63 @@
                       "items": {
                         "type": "string"
                       }
+                    },
+                    "enableLlmTranslator": {
+                      "type": "boolean"
+                    },
+                    "enableLlmTranslatorRedisCache": {
+                      "type": "boolean"
+                    },
+                    "llmTranslatorRedisCacheTtl": {
+                      "type": "number"
+                    },
+                    "llmTranslatorBaseUrl": {
+                      "type": [
+                        "string",
+                        "null"
+                      ]
+                    },
+                    "llmTranslatorApiKey": {
+                      "type": [
+                        "string",
+                        "null"
+                      ]
+                    },
+                    "llmTranslatorModel": {
+                      "type": [
+                        "string",
+                        "null"
+                      ]
+                    },
+                    "llmTranslatorTemperature": {
+                      "type": [
+                        "number",
+                        "null"
+                      ]
+                    },
+                    "llmTranslatorTopP": {
+                      "type": [
+                        "number",
+                        "null"
+                      ]
+                    },
+                    "llmTranslatorMaxTokens": {
+                      "type": [
+                        "number",
+                        "null"
+                      ]
+                    },
+                    "llmTranslatorSysPrompt": {
+                      "type": [
+                        "string",
+                        "null"
+                      ]
+                    },
+                    "llmTranslatorUserPrompt": {
+                      "type": [
+                        "string",
+                        "null"
+                      ]
                     }
                   },
                   "required": [
@@ -10108,7 +10165,18 @@
                     "urlPreviewUserAgent",
                     "urlPreviewSummaryProxyUrl",
                     "federation",
-                    "federationHosts"
+                    "federationHosts",
+                    "enableLlmTranslator",
+                    "enableLlmTranslatorRedisCache",
+                    "llmTranslatorRedisCacheTtl",
+                    "llmTranslatorBaseUrl",
+                    "llmTranslatorApiKey",
+                    "llmTranslatorModel",
+                    "llmTranslatorTemperature",
+                    "llmTranslatorTopP",
+                    "llmTranslatorMaxTokens",
+                    "llmTranslatorSysPrompt",
+                    "llmTranslatorUserPrompt"
                   ]
                 }
               }
@@ -17767,6 +17835,63 @@
                     "items": {
                       "type": "string"
                     }
+                  },
+                  "enableLlmTranslator": {
+                    "type": "boolean"
+                  },
+                  "enableLlmTranslatorRedisCache": {
+                    "type": "boolean"
+                  },
+                  "llmTranslatorRedisCacheTtl": {
+                    "type": "integer"
+                  },
+                  "llmTranslatorBaseUrl": {
+                    "type": [
+                      "string",
+                      "null"
+                    ]
+                  },
+                  "llmTranslatorApiKey": {
+                    "type": [
+                      "string",
+                      "null"
+                    ]
+                  },
+                  "llmTranslatorModel": {
+                    "type": [
+                      "string",
+                      "null"
+                    ]
+                  },
+                  "llmTranslatorTemperature": {
+                    "type": [
+                      "number",
+                      "null"
+                    ]
+                  },
+                  "llmTranslatorTopP": {
+                    "type": [
+                      "number",
+                      "null"
+                    ]
+                  },
+                  "llmTranslatorMaxTokens": {
+                    "type": [
+                      "integer",
+                      "null"
+                    ]
+                  },
+                  "llmTranslatorSysPrompt": {
+                    "type": [
+                      "string",
+                      "null"
+                    ]
+                  },
+                  "llmTranslatorUserPrompt": {
+                    "type": [
+                      "string",
+                      "null"
+                    ]
                   }
                 }
               }

Get diff files from Workflow Page

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 22, 2025

Codecov Report

❌ Patch coverage is 35.31157% with 218 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.12%. Comparing base (ed86b17) to head (b6d2f02).
⚠️ Report is 1544 commits behind head on develop.

Files with missing lines Patch % Lines
...ges/frontend/src/pages/admin/external-services.vue 0.00% 90 Missing ⚠️
...kend/src/server/api/endpoints/admin/update-meta.ts 14.66% 64 Missing ⚠️
...ackend/src/server/api/endpoints/notes/translate.ts 5.66% 49 Missing and 1 partial ⚠️
...ges/backend/src/server/api/endpoints/admin/meta.ts 78.57% 12 Missing ⚠️
...ges/backend/src/core/entities/MetaEntityService.ts 0.00% 1 Missing ⚠️
...ackages/frontend/src/components/MkNoteDetailed.vue 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #15697      +/-   ##
===========================================
+ Coverage    42.14%   44.12%   +1.97%     
===========================================
  Files         1683     1687       +4     
  Lines       171284   177779    +6495     
  Branches      4027     4219     +192     
===========================================
+ Hits         72195    78448    +6253     
- Misses       98595    98836     +241     
- Partials       494      495       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Collaborator

@KisaragiEffective KisaragiEffective left a comment

Choose a reason for hiding this comment

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

I don't see reasons to use LLM to translate user input over the old method... But I'd like to note some minor things:

Comment thread packages/frontend/src/pages/admin/external-services.vue Outdated
Comment thread CHANGELOG.md Outdated
Comment thread packages/backend/src/server/api/endpoints/notes/translate.ts
ybw2016v and others added 4 commits March 23, 2025 07:25
Co-authored-by: Kisaragi <48310258+KisaragiEffective@users.noreply.github.com>
Co-authored-by: Kisaragi <48310258+KisaragiEffective@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages/backend Server side specific issue/PR packages/frontend Client side specific issue/PR packages/misskey-js

Projects

Development

Successfully merging this pull request may close these issues.

2 participants