fix(actions): bump smart mind map to 0.9.2
Align mind map language rule with input text Update plugin docs and README versions
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# Smart Mind Map
|
# Smart Mind Map
|
||||||
|
|
||||||
<span class="category-badge action">Action</span>
|
<span class="category-badge action">Action</span>
|
||||||
<span class="version-badge">v0.9.1</span>
|
<span class="version-badge">v0.9.2</span>
|
||||||
|
|
||||||
Intelligently analyzes text content and generates interactive mind maps for better visualization and understanding.
|
Intelligently analyzes text content and generates interactive mind maps for better visualization and understanding.
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ The Smart Mind Map plugin transforms text content into beautiful, interactive mi
|
|||||||
- :material-gesture-swipe: **Rich Controls**: Zoom, reset view, expand level selector (All/2/3) and fullscreen
|
- :material-gesture-swipe: **Rich Controls**: Zoom, reset view, expand level selector (All/2/3) and fullscreen
|
||||||
- :material-palette: **Theme Aware**: Auto-detects OpenWebUI light/dark theme with manual toggle
|
- :material-palette: **Theme Aware**: Auto-detects OpenWebUI light/dark theme with manual toggle
|
||||||
- :material-download: **One-Click Export**: Download high-res PNG, copy SVG, or copy Markdown source
|
- :material-download: **One-Click Export**: Download high-res PNG, copy SVG, or copy Markdown source
|
||||||
- :material-translate: **Multi-language**: Adapts output language to the user context
|
- :material-translate: **Multi-language**: Matches output language to the input text
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Smart Mind Map(智能思维导图)
|
# Smart Mind Map(智能思维导图)
|
||||||
|
|
||||||
<span class="category-badge action">Action</span>
|
<span class="category-badge action">Action</span>
|
||||||
<span class="version-badge">v0.9.1</span>
|
<span class="version-badge">v0.9.2</span>
|
||||||
|
|
||||||
智能分析文本内容,生成交互式思维导图,帮助你更直观地理解信息结构。
|
智能分析文本内容,生成交互式思维导图,帮助你更直观地理解信息结构。
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ Smart Mind Map 会将文本转换成漂亮的交互式思维导图。插件会
|
|||||||
- :material-gesture-swipe: **丰富控制**:缩放/重置、展开层级(全部/2/3 级)与全屏
|
- :material-gesture-swipe: **丰富控制**:缩放/重置、展开层级(全部/2/3 级)与全屏
|
||||||
- :material-palette: **主题感知**:自动检测 OpenWebUI 亮/暗色主题并支持手动切换
|
- :material-palette: **主题感知**:自动检测 OpenWebUI 亮/暗色主题并支持手动切换
|
||||||
- :material-download: **一键导出**:下载高分辨率 PNG、复制 SVG 或 Markdown
|
- :material-download: **一键导出**:下载高分辨率 PNG、复制 SVG 或 Markdown
|
||||||
- :material-translate: **多语言**:根据用户语言自动输出
|
- :material-translate: **多语言**:输出语言与输入文本一致
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ OpenWebUI supports four types of plugins, each serving a different purpose:
|
|||||||
|
|
||||||
| Plugin | Type | Description | Version |
|
| Plugin | Type | Description | Version |
|
||||||
|--------|------|-------------|---------|
|
|--------|------|-------------|---------|
|
||||||
| [Smart Mind Map](actions/smart-mind-map.md) | Action | Generate interactive mind maps from text | 0.9.1 |
|
| [Smart Mind Map](actions/smart-mind-map.md) | Action | Generate interactive mind maps from text | 0.9.2 |
|
||||||
| [Smart Infographic](actions/smart-infographic.md) | Action | Transform text into professional infographics | 1.4.9 |
|
| [Smart Infographic](actions/smart-infographic.md) | Action | Transform text into professional infographics | 1.4.9 |
|
||||||
| [Flash Card](actions/flash-card.md) | Action | Create beautiful learning flashcards | 0.2.4 |
|
| [Flash Card](actions/flash-card.md) | Action | Create beautiful learning flashcards | 0.2.4 |
|
||||||
| [Export to Excel](actions/export-to-excel.md) | Action | Export chat history to Excel files | 0.3.7 |
|
| [Export to Excel](actions/export-to-excel.md) | Action | Export chat history to Excel files | 0.3.7 |
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ OpenWebUI 支持四种类型的插件,每种都有不同的用途:
|
|||||||
|
|
||||||
| 插件 | 类型 | 描述 | 版本 |
|
| 插件 | 类型 | 描述 | 版本 |
|
||||||
|--------|------|-------------|---------|
|
|--------|------|-------------|---------|
|
||||||
| [Smart Mind Map(智能思维导图)](actions/smart-mind-map.md) | Action | 从文本生成交互式思维导图 | 0.9.1 |
|
| [Smart Mind Map(智能思维导图)](actions/smart-mind-map.md) | Action | 从文本生成交互式思维导图 | 0.9.2 |
|
||||||
| [Smart Infographic(智能信息图)](actions/smart-infographic.md) | Action | 将文本转成专业信息图 | 1.4.9 |
|
| [Smart Infographic(智能信息图)](actions/smart-infographic.md) | Action | 将文本转成专业信息图 | 1.4.9 |
|
||||||
| [Flash Card(闪记卡)](actions/flash-card.md) | Action | 生成精美学习卡片 | 0.2.4 |
|
| [Flash Card(闪记卡)](actions/flash-card.md) | Action | 生成精美学习卡片 | 0.2.4 |
|
||||||
| [Export to Excel(导出到 Excel)](actions/export-to-excel.md) | Action | 导出聊天记录为 Excel | 0.3.7 |
|
| [Export to Excel(导出到 Excel)](actions/export-to-excel.md) | Action | 导出聊天记录为 Excel | 0.3.7 |
|
||||||
|
|||||||
@@ -2,17 +2,14 @@
|
|||||||
|
|
||||||
Smart Mind Map is a powerful OpenWebUI action plugin that intelligently analyzes long-form text content and automatically generates interactive mind maps, helping users structure and visualize knowledge.
|
Smart Mind Map is a powerful OpenWebUI action plugin that intelligently analyzes long-form text content and automatically generates interactive mind maps, helping users structure and visualize knowledge.
|
||||||
|
|
||||||
**Author:** [Fu-Jie](https://github.com/Fu-Jie/awesome-openwebui) | **Version:** 0.9.1 | **Project:** [Awesome OpenWebUI](https://github.com/Fu-Jie/awesome-openwebui) | **License:** MIT
|
**Author:** [Fu-Jie](https://github.com/Fu-Jie/awesome-openwebui) | **Version:** 0.9.2 | **Project:** [Awesome OpenWebUI](https://github.com/Fu-Jie/awesome-openwebui) | **License:** MIT
|
||||||
|
|
||||||
## What's New in v0.9.1
|
## What's New in v0.9.2
|
||||||
|
|
||||||
**New Feature: Image Output Mode**
|
**Language Rule Alignment**
|
||||||
|
|
||||||
- **Static Image Support**: Added `OUTPUT_MODE` configuration parameter.
|
- **Input Language First**: Mind map output now strictly matches the input text language.
|
||||||
- `html` (default): Interactive HTML mind map.
|
- **Consistent Behavior**: Matches the infographic language rule for predictable multilingual output.
|
||||||
- `image`: Static SVG image embedded directly in Markdown (**No HTML code output**, cleaner chat history).
|
|
||||||
- **Efficient Storage**: Image mode uploads SVG to `/api/v1/files`, avoiding huge base64 strings in chat history.
|
|
||||||
- **Smart Features**: Auto-responsive width and automatic theme detection (light/dark) for generated images.
|
|
||||||
|
|
||||||
## Key Features 🔑
|
## Key Features 🔑
|
||||||
|
|
||||||
|
|||||||
@@ -2,17 +2,14 @@
|
|||||||
|
|
||||||
思维导图是一个强大的 OpenWebUI 动作插件,能够智能分析长篇文本内容,自动生成交互式思维导图,帮助用户结构化和可视化知识。
|
思维导图是一个强大的 OpenWebUI 动作插件,能够智能分析长篇文本内容,自动生成交互式思维导图,帮助用户结构化和可视化知识。
|
||||||
|
|
||||||
**作者:** [Fu-Jie](https://github.com/Fu-Jie/awesome-openwebui) | **版本:** 0.9.1 | **项目:** [Awesome OpenWebUI](https://github.com/Fu-Jie/awesome-openwebui) | **许可证:** MIT
|
**作者:** [Fu-Jie](https://github.com/Fu-Jie/awesome-openwebui) | **版本:** 0.9.2 | **项目:** [Awesome OpenWebUI](https://github.com/Fu-Jie/awesome-openwebui) | **许可证:** MIT
|
||||||
|
|
||||||
## v0.9.1 更新亮点
|
## v0.9.2 更新亮点
|
||||||
|
|
||||||
**新功能:图片输出模式**
|
**语言规则对齐**
|
||||||
|
|
||||||
- **静态图片支持**:新增 `OUTPUT_MODE` 配置参数。
|
- **输入语言优先**:导图输出严格与输入文本语言一致。
|
||||||
- `html`(默认):交互式 HTML 思维导图。
|
- **一致性提升**:与信息图语言规则保持一致,多语言输出更可预期。
|
||||||
- `image`:静态 SVG 图片直接嵌入 Markdown(**不输出 HTML 代码**,聊天记录更简洁)。
|
|
||||||
- **高效存储**:图片模式将 SVG 上传至 `/api/v1/files`,避免聊天记录中出现超长 Base64 字符串。
|
|
||||||
- **智能特性**:生成的图片支持自动响应式宽度和自动主题检测(亮色/暗色)。
|
|
||||||
|
|
||||||
## 核心特性 🔑
|
## 核心特性 🔑
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ author: Fu-Jie
|
|||||||
author_url: https://github.com/Fu-Jie/awesome-openwebui
|
author_url: https://github.com/Fu-Jie/awesome-openwebui
|
||||||
funding_url: https://github.com/open-webui
|
funding_url: https://github.com/open-webui
|
||||||
funding_url: https://github.com/Fu-Jie/awesome-openwebui
|
funding_url: https://github.com/Fu-Jie/awesome-openwebui
|
||||||
version: 0.9.1
|
version: 0.9.2
|
||||||
openwebui_id: 3094c59a-b4dd-4e0c-9449-15e2dd547dc4
|
openwebui_id: 3094c59a-b4dd-4e0c-9449-15e2dd547dc4
|
||||||
icon_url: data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxyZWN0IHg9IjE2IiB5PSIxNiIgd2lkdGg9IjYiIGhlaWdodD0iNiIgcng9IjEiLz48cmVjdCB4PSIyIiB5PSIxNiIgd2lkdGg9IjYiIGhlaWdodD0iNiIgcng9IjEiLz48cmVjdCB4PSI5IiB5PSIyIiB3aWR0aD0iNiIgaGVpZ2h0PSI2IiByeD0iMSIvPjxwYXRoIGQ9Ik01IDE2di0zYTEgMSAwIDAgMSAxLTFoMTJhMSAxIDAgMCAxIDEgMXYzIi8+PHBhdGggZD0iTTEyIDEyVjgiLz48L3N2Zz4=
|
icon_url: data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxyZWN0IHg9IjE2IiB5PSIxNiIgd2lkdGg9IjYiIGhlaWdodD0iNiIgcng9IjEiLz48cmVjdCB4PSIyIiB5PSIxNiIgd2lkdGg9IjYiIGhlaWdodD0iNiIgcng9IjEiLz48cmVjdCB4PSI5IiB5PSIyIiB3aWR0aD0iNiIgaGVpZ2h0PSI2IiByeD0iMSIvPjxwYXRoIGQ9Ik01IDE2di0zYTEgMSAwIDAgMSAxLTFoMTJhMSAxIDAgMCAxIDEgMXYzIi8+PHBhdGggZD0iTTEyIDEyVjgiLz48L3N2Zz4=
|
||||||
description: Intelligently analyzes text content and generates interactive mind maps to help users structure and visualize knowledge.
|
description: Intelligently analyzes text content and generates interactive mind maps to help users structure and visualize knowledge.
|
||||||
@@ -33,7 +33,8 @@ SYSTEM_PROMPT_MINDMAP_ASSISTANT = """
|
|||||||
You are a professional mind map generation assistant, capable of efficiently analyzing long-form text provided by users and structuring its core themes, key concepts, branches, and sub-branches into standard Markdown list syntax for rendering by Markmap.js.
|
You are a professional mind map generation assistant, capable of efficiently analyzing long-form text provided by users and structuring its core themes, key concepts, branches, and sub-branches into standard Markdown list syntax for rendering by Markmap.js.
|
||||||
|
|
||||||
Please strictly follow these guidelines:
|
Please strictly follow these guidelines:
|
||||||
- **Language**: All output must be in the language specified by the user.
|
- **Language**: All output must be in the exact same language as the input text (the text you are analyzing).
|
||||||
|
- **Format Consistency**: Even if this system prompt is in English, if the user input is in Chinese, the mind map content must be in Chinese. If input is Japanese, output Japanese.
|
||||||
- **Format**: Your output must strictly be in Markdown list format, wrapped with ```markdown and ```.
|
- **Format**: Your output must strictly be in Markdown list format, wrapped with ```markdown and ```.
|
||||||
- Use `#` to define the central theme (root node).
|
- Use `#` to define the central theme (root node).
|
||||||
- Use `-` with two-space indentation to represent branches and sub-branches.
|
- Use `-` with two-space indentation to represent branches and sub-branches.
|
||||||
@@ -811,7 +812,11 @@ class Action:
|
|||||||
"Sunday": "Sunday",
|
"Sunday": "Sunday",
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_user_context(self, __user__: Optional[Dict[str, Any]]) -> Dict[str, str]:
|
async def _get_user_context(
|
||||||
|
self,
|
||||||
|
__user__: Optional[Dict[str, Any]],
|
||||||
|
__event_call__: Optional[Callable[[Any], Awaitable[None]]] = None,
|
||||||
|
) -> Dict[str, str]:
|
||||||
"""Extract basic user context with safe fallbacks."""
|
"""Extract basic user context with safe fallbacks."""
|
||||||
if isinstance(__user__, (list, tuple)):
|
if isinstance(__user__, (list, tuple)):
|
||||||
user_data = __user__[0] if __user__ else {}
|
user_data = __user__[0] if __user__ else {}
|
||||||
@@ -820,10 +825,32 @@ class Action:
|
|||||||
else:
|
else:
|
||||||
user_data = {}
|
user_data = {}
|
||||||
|
|
||||||
|
user_id = user_data.get("id", "unknown_user")
|
||||||
|
user_name = user_data.get("name", "User")
|
||||||
|
user_language = user_data.get("language", "en-US")
|
||||||
|
|
||||||
|
if __event_call__:
|
||||||
|
try:
|
||||||
|
js_code = """
|
||||||
|
return (
|
||||||
|
localStorage.getItem('locale') ||
|
||||||
|
localStorage.getItem('language') ||
|
||||||
|
navigator.language ||
|
||||||
|
'en-US'
|
||||||
|
);
|
||||||
|
"""
|
||||||
|
frontend_lang = await __event_call__(
|
||||||
|
{"type": "execute", "data": {"code": js_code}}
|
||||||
|
)
|
||||||
|
if frontend_lang and isinstance(frontend_lang, str):
|
||||||
|
user_language = frontend_lang
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Failed to retrieve frontend language: {e}")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"user_id": user_data.get("id", "unknown_user"),
|
"user_id": user_id,
|
||||||
"user_name": user_data.get("name", "User"),
|
"user_name": user_name,
|
||||||
"user_language": user_data.get("language", "en-US"),
|
"user_language": user_language,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_chat_context(
|
def _get_chat_context(
|
||||||
@@ -1369,8 +1396,8 @@ class Action:
|
|||||||
__metadata__: Optional[dict] = None,
|
__metadata__: Optional[dict] = None,
|
||||||
__request__: Optional[Request] = None,
|
__request__: Optional[Request] = None,
|
||||||
) -> Optional[dict]:
|
) -> Optional[dict]:
|
||||||
logger.info("Action: Smart Mind Map (v0.9.1) started")
|
logger.info("Action: Smart Mind Map (v0.9.2) started")
|
||||||
user_ctx = self._get_user_context(__user__)
|
user_ctx = await self._get_user_context(__user__, __event_call__)
|
||||||
user_language = user_ctx["user_language"]
|
user_language = user_ctx["user_language"]
|
||||||
user_name = user_ctx["user_name"]
|
user_name = user_ctx["user_name"]
|
||||||
user_id = user_ctx["user_id"]
|
user_id = user_ctx["user_id"]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ title: 思维导图
|
|||||||
author: Fu-Jie
|
author: Fu-Jie
|
||||||
author_url: https://github.com/Fu-Jie/awesome-openwebui
|
author_url: https://github.com/Fu-Jie/awesome-openwebui
|
||||||
funding_url: https://github.com/open-webui
|
funding_url: https://github.com/open-webui
|
||||||
version: 0.9.1
|
version: 0.9.2
|
||||||
openwebui_id: 8d4b097b-219b-4dd2-b509-05fbe6388335
|
openwebui_id: 8d4b097b-219b-4dd2-b509-05fbe6388335
|
||||||
icon_url: data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxyZWN0IHg9IjE2IiB5PSIxNiIgd2lkdGg9IjYiIGhlaWdodD0iNiIgcng9IjEiLz48cmVjdCB4PSIyIiB5PSIxNiIgd2lkdGg9IjYiIGhlaWdodD0iNiIgcng9IjEiLz48cmVjdCB4PSI5IiB5PSIyIiB3aWR0aD0iNiIgaGVpZ2h0PSI2IiByeD0iMSIvPjxwYXRoIGQ9Ik01IDE2di0zYTEgMSAwIDAgMSAxLTFoMTJhMSAxIDAgMCAxIDEgMXYzIi8+PHBhdGggZD0iTTEyIDEyVjgiLz48L3N2Zz4=
|
icon_url: data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxyZWN0IHg9IjE2IiB5PSIxNiIgd2lkdGg9IjYiIGhlaWdodD0iNiIgcng9IjEiLz48cmVjdCB4PSIyIiB5PSIxNiIgd2lkdGg9IjYiIGhlaWdodD0iNiIgcng9IjEiLz48cmVjdCB4PSI5IiB5PSIyIiB3aWR0aD0iNiIgaGVpZ2h0PSI2IiByeD0iMSIvPjxwYXRoIGQ9Ik01IDE2di0zYTEgMSAwIDAgMSAxLTFoMTJhMSAxIDAgMCAxIDEgMXYzIi8+PHBhdGggZD0iTTEyIDEyVjgiLz48L3N2Zz4=
|
||||||
description: 智能分析文本内容,生成交互式思维导图,帮助用户结构化和可视化知识。
|
description: 智能分析文本内容,生成交互式思维导图,帮助用户结构化和可视化知识。
|
||||||
@@ -32,7 +32,8 @@ SYSTEM_PROMPT_MINDMAP_ASSISTANT = """
|
|||||||
你是一个专业的思维导图生成助手,能够高效地分析用户提供的长篇文本,并将其核心主题、关键概念、分支和子分支结构化为标准的Markdown列表语法,以便Markmap.js进行渲染。
|
你是一个专业的思维导图生成助手,能够高效地分析用户提供的长篇文本,并将其核心主题、关键概念、分支和子分支结构化为标准的Markdown列表语法,以便Markmap.js进行渲染。
|
||||||
|
|
||||||
请严格遵循以下指导原则:
|
请严格遵循以下指导原则:
|
||||||
- **语言**: 所有输出必须使用用户指定的语言。
|
- **语言**: 所有输出必须与输入文本(正在分析的文本)保持完全一致的语言。
|
||||||
|
- **格式一致性**: 即使系统提示词是中文,只要用户输入是英文,导图内容必须是英文;若输入为日文,则输出日文。
|
||||||
- **格式**: 你的输出必须严格为Markdown列表格式,并用```markdown 和 ``` 包裹。
|
- **格式**: 你的输出必须严格为Markdown列表格式,并用```markdown 和 ``` 包裹。
|
||||||
- 使用 `#` 定义中心主题(根节点)。
|
- 使用 `#` 定义中心主题(根节点)。
|
||||||
- 使用 `-` 和两个空格的缩进表示分支和子分支。
|
- 使用 `-` 和两个空格的缩进表示分支和子分支。
|
||||||
@@ -809,7 +810,11 @@ class Action:
|
|||||||
"Sunday": "星期日",
|
"Sunday": "星期日",
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_user_context(self, __user__: Optional[Dict[str, Any]]) -> Dict[str, str]:
|
async def _get_user_context(
|
||||||
|
self,
|
||||||
|
__user__: Optional[Dict[str, Any]],
|
||||||
|
__event_call__: Optional[Callable[[Any], Awaitable[None]]] = None,
|
||||||
|
) -> Dict[str, str]:
|
||||||
"""Extract basic user context with safe fallbacks."""
|
"""Extract basic user context with safe fallbacks."""
|
||||||
if isinstance(__user__, (list, tuple)):
|
if isinstance(__user__, (list, tuple)):
|
||||||
user_data = __user__[0] if __user__ else {}
|
user_data = __user__[0] if __user__ else {}
|
||||||
@@ -818,10 +823,32 @@ class Action:
|
|||||||
else:
|
else:
|
||||||
user_data = {}
|
user_data = {}
|
||||||
|
|
||||||
|
user_id = user_data.get("id", "unknown_user")
|
||||||
|
user_name = user_data.get("name", "User")
|
||||||
|
user_language = user_data.get("language", "en-US")
|
||||||
|
|
||||||
|
if __event_call__:
|
||||||
|
try:
|
||||||
|
js_code = """
|
||||||
|
return (
|
||||||
|
localStorage.getItem('locale') ||
|
||||||
|
localStorage.getItem('language') ||
|
||||||
|
navigator.language ||
|
||||||
|
'en-US'
|
||||||
|
);
|
||||||
|
"""
|
||||||
|
frontend_lang = await __event_call__(
|
||||||
|
{"type": "execute", "data": {"code": js_code}}
|
||||||
|
)
|
||||||
|
if frontend_lang and isinstance(frontend_lang, str):
|
||||||
|
user_language = frontend_lang
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Failed to retrieve frontend language: {e}")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"user_id": user_data.get("id", "unknown_user"),
|
"user_id": user_id,
|
||||||
"user_name": user_data.get("name", "用户"),
|
"user_name": user_name,
|
||||||
"user_language": user_data.get("language", "zh-CN"),
|
"user_language": user_language,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_chat_context(
|
def _get_chat_context(
|
||||||
@@ -1348,8 +1375,8 @@ class Action:
|
|||||||
__metadata__: Optional[dict] = None,
|
__metadata__: Optional[dict] = None,
|
||||||
__request__: Optional[Request] = None,
|
__request__: Optional[Request] = None,
|
||||||
) -> Optional[dict]:
|
) -> Optional[dict]:
|
||||||
logger.info("Action: 思维导图 (v0.9.1) started")
|
logger.info("Action: 思维导图 (v0.9.2) started")
|
||||||
user_ctx = self._get_user_context(__user__)
|
user_ctx = await self._get_user_context(__user__, __event_call__)
|
||||||
user_language = user_ctx["user_language"]
|
user_language = user_ctx["user_language"]
|
||||||
user_name = user_ctx["user_name"]
|
user_name = user_ctx["user_name"]
|
||||||
user_id = user_ctx["user_id"]
|
user_id = user_ctx["user_id"]
|
||||||
|
|||||||
Reference in New Issue
Block a user