Skip to content

Commit 623e45f

Browse files
使得其成为Amrita插件
1 parent 73642f1 commit 623e45f

12 files changed

Lines changed: 2724 additions & 1120 deletions

File tree

README.md

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<div align="center">
2-
<a href="https://github.com/JohnRichard4096/nonebot_plugin_omikuji/">
2+
<a href="https://github.com/JohnRichard4096/amrita_plugin_omikuji/">
33
<img src="https://github.com/user-attachments/assets/b5162036-5b17-4cf4-b0cb-8ec842a71bc6" width="200" alt="omikuji Logo">
44
</a>
55
<h1>Omikuji</h1>
6-
<h3>适用于SuggarChat的御神签插件!</h3>
6+
<h3>适用于AmritaBot的御神签插件!</h3>
77

88
<p>
99
<a href="https://pypi.org/project/nonebot-plugin-omikuji/">
@@ -16,47 +16,47 @@
1616
<img src="https://img.shields.io/badge/nonebot2-2.4.3+-blue?style=flat-square" alt="NoneBot Version">
1717
</a>
1818
<a href="LICENSE">
19-
<img src="https://img.shields.io/github/license/LiteSuggarDEV/nonebot_plugin_omikuji?style=flat-square" alt="License">
19+
<img src="https://img.shields.io/github/license/AmritaBot/amrita_plugin_omikuji?style=flat-square" alt="License">
2020
</a>
21-
<a href="https://qm.qq.com/q/PFcfb4296m">
22-
<img src="https://img.shields.io/badge/QQ%E7%BE%A4-1002495699-blue?style=flat-square" alt="QQ Group">
21+
<a href="https://qm.qq.com/q/5URbtujxx6">
22+
<img src="https://img.shields.io/badge/QQ%E7%BE%A4-1006893368-blue?style=flat-square" alt="QQ Group">
2323
</a>
2424
</p>
2525
</div>
2626

2727
## 🌸 简介
2828

29-
**Omikuji(御神签)** 是一款基于大型语言模型(LLM)的 [NoneBot2](https://nonebot.dev/) 插件,专为 [SuggarChat](https://github.com/LiteSuggarDEV/SuggarChat) 框架设计。该插件为用户提供传统日本神社抽签体验的现代化数字版本,通过AI生成个性化、富有文化氛围的签文。
29+
**Omikuji(御神签)** 是一款基于大型语言模型(LLM)的 [NoneBot2](https://nonebot.dev/) 插件,专为 [AmritaBot](https://github.com/AmritaBot/Amrita) 框架设计。该插件为用户提供传统日本神社抽签体验的现代化数字版本,通过 AI 生成个性化、富有文化氛围的签文。
3030

31-
御神签(おみくじ)是日本神道教中一种传统的占卜方式,参拜者在神社或寺庙中摇动签筒,随机抽取一支签,上面写着对未来的预言或建议。本插件将这一传统文化与现代AI技术相结合,每次抽取都会根据主题和运势等级生成独特的签文内容。
31+
御神签(おみくじ)是日本神道教中一种传统的占卜方式,参拜者在神社或寺庙中摇动签筒,随机抽取一支签,上面写着对未来的预言或建议。本插件将这一传统文化与现代 AI 技术相结合,每次抽取都会根据主题和运势等级生成独特的签文内容。
3232

3333
### 🌟 特性
3434

35-
- **AI驱动签文生成**:利用大型语言模型生成富有创意和文化内涵的签文
35+
- **AI 驱动签文生成**:利用大型语言模型生成富有创意和文化内涵的签文
3636
- **多样化主题**:支持多个主题,包括综合运势、恋爱姻缘、学业考试、事业财运等
37-
- **智能缓存系统**:内置缓存机制,提高响应速度并减少API调用
38-
- **丰富的运势等级**从大吉到大凶共7个等级,增加占卜体验的真实感
37+
- **智能缓存系统**:内置缓存机制,提高响应速度并减少 API 调用
38+
- **丰富的运势等级**从大吉到大凶共 7 个等级,增加占卜体验的真实感
3939
- **灵活配置**:支持多种配置选项,可根据需求调整插件行为
40-
- **多平台支持**基于NoneBot2开发,支持多种聊天平台
40+
- **多平台支持**基于 NoneBot2 开发,支持多种聊天平台
4141

4242
## 🚀 安装
4343

4444
### 环境要求
4545

4646
- Python 3.10+
4747
- NoneBot2 2.4.3+
48-
- SuggarChat 框架
49-
- 支持的LLM服务(如OpenAI、Anthropic等
48+
- AmritaBot 框架
49+
- 支持的 LLM 服务(如 OpenAI、Anthropic 等
5050

51-
### 使用pip安装(推荐)
51+
### 使用 Amrita CLI 安装
5252

53-
```bash
54-
pip install nonebot-plugin-omikuji
53+
```shell
54+
amrita plugin install amrita_plugin_omikuji
5555
```
5656

57-
### 使用uv安装
57+
### 使用 uv 安装
5858

59-
```bash
59+
```shell
6060
uv add nonebot-plugin-omikuji
6161
```
6262

@@ -71,7 +71,7 @@ ENABLE_OMIKUJI=true
7171
# 是否交给模型进行二次响应(默认:False)
7272
OMIKUJI_SEND_BY_CHAT=false
7373
74-
# 是否加入SuggarChat的系统提示(默认:True)
74+
# 是否加入AmritaBot的系统提示(默认:True)
7575
OMIKUJI_ADD_SYSTEM_PROMPT=true
7676
7777
# 是否使用语料库的缓存(默认:True)
@@ -101,15 +101,19 @@ OMIKUJI_LONG_CACHE_UPDATE_MAX_COUNT=100
101101
### 命令触发
102102

103103
1. **随机主题抽签**
104+
104105
```
105106
/omikuji
106107
```
107108

108109
2. **指定主题抽签**
110+
109111
```
110112
/omikuji <主题>
111113
```
114+
112115
支持的主题包括:
116+
113117
- 综合运势
114118
- 恋爱姻缘
115119
- 学业考试
@@ -129,24 +133,27 @@ OMIKUJI_LONG_CACHE_UPDATE_MAX_COUNT=100
129133
### 别名触发
130134

131135
也可以使用以下别名触发抽签:
136+
132137
- `/御神签`
133138
- `/抽签`
134139

135140
### 聊天触发
136141

137-
在启用了SuggarChat的环境中,也可以通过自然语言触发,例如:
142+
在启用了 AmritaBot 的环境中,也可以通过自然语言触发,例如:
143+
138144
- "我想抽个签"
139145
- "给我来个御神签"
140146

141147
## 🧠 工作原理
142148

143149
1. 用户触发抽签命令或通过聊天触发
144150
2. 插件根据主题和随机运势等级生成请求
145-
3. 调用配置的LLM服务生成符合要求的签文内容
151+
3. 调用配置的 LLM 服务生成符合要求的签文内容
146152
4. 将生成的签文按照传统御神签格式进行排版
147153
5. 返回给用户完整的签文体验
148154

149155
签文通常包括:
156+
150157
- 签文编号
151158
- 天启名称
152159
- 运势等级和主题
@@ -156,7 +163,7 @@ OMIKUJI_LONG_CACHE_UPDATE_MAX_COUNT=100
156163

157164
## 📁 缓存机制
158165

159-
为了提高响应速度和减少API调用,插件实现了多层缓存机制:
166+
为了提高响应速度和减少 API 调用,插件实现了多层缓存机制:
160167

161168
1. **短期缓存**:临时存储用户最近一次抽签结果
162169
2. **语料库缓存**:存储已生成的签文内容,按主题和运势等级分类
@@ -167,7 +174,7 @@ OMIKUJI_LONG_CACHE_UPDATE_MAX_COUNT=100
167174
## 🤝 依赖
168175

169176
- [nonebot2](https://github.com/nonebot/nonebot2)
170-
- [nonebot-plugin-suggarchat](https://github.com/LiteSuggarDEV/SuggarChat)
177+
- [Amrita](https://github.com/AmritaBot/Amrita)
171178
- [nonebot-adapter-onebot](https://github.com/nonebot/adapter-onebot)
172179
- [nonebot-plugin-localstore](https://github.com/nonebot/nonebot-plugin-localstore)
173180
- [nonebot-plugin-orm](https://github.com/nonebot/nonebot-plugin-orm)
@@ -179,7 +186,8 @@ OMIKUJI_LONG_CACHE_UPDATE_MAX_COUNT=100
179186

180187
## 🙏 鸣谢
181188

182-
特别感谢以下项目和贡献者
189+
特别感谢以下项目的贡献者
183190

184191
- [NoneBot2](https://github.com/nonebot/nonebot2)
185-
- [SuggarChat](https://github.com/LiteSuggarDEV/SuggarChat)
192+
- [Amrita](https://github.com/AmritaBot/Amrita)
193+
- [nonebot-plugin-suggarchat](https://github.com/LiteSuggarDEV/nonebot-plugin-suggarchat)
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import contextlib
22
import os
33
from datetime import datetime
4+
from importlib import metadata
45

56
from nonebot import get_driver, logger
67
from nonebot.plugin import PluginMetadata, require
78

8-
require("nonebot_plugin_suggarchat")
9-
require("nonebot_plugin_localstore")
10-
require("nonebot_plugin_orm")
11-
from importlib import metadata
9+
require("amrita.plugins.chat")
10+
require("amrita.plugins.menu")
1211

13-
from nonebot_plugin_suggarchat.API import Menu, ToolsManager
12+
from amrita.plugins.chat.API import ToolsManager
1413

1514
from . import commands, llm_tool, sql_models
1615
from .cache import OmikujiCache
@@ -19,28 +18,25 @@
1918

2019
__plugin_meta__ = PluginMetadata(
2120
name="御神签",
22-
description="依赖SuggarChat的聊天御神签抽签插件模块",
21+
description="依赖AmritaBot的聊天御神签抽签插件模块",
2322
usage="/omikuji [板块]\n/omikuji 解签\n或者使用聊天直接抽签。",
2423
type="application",
25-
homepage="https://github.com/LiteSuggarDEV/nonebot_plugin_omikuji",
24+
homepage="https://github.com/AmritaBot/amrita_plugin_omikuji",
2625
supported_adapters={"~onebot.v11"},
2726
)
2827

29-
__all__ = ["commands", "llm_tool", "sql_models"]
30-
3128

3229
@get_driver().on_startup
3330
async def init():
3431
version = "Unknown"
3532
with contextlib.suppress(Exception):
36-
version = metadata.version("nonebot_plugin_omikuji")
33+
version = metadata.version("amrita_plugin_omikuji")
3734
if "dev" in version:
3835
logger.warning("当前版本为开发版本,可能存在不稳定情况!")
3936
logger.info(f"Loading OMIKUJI V{version}......")
4037
conf = get_config()
4138
if conf.enable_omikuji:
4239
ToolsManager().register_tool(TOOL_DATA)
43-
Menu().reg_menu("omikuji", "抽御神签", "[可选]主题")
4440
logger.info("正在初始化缓存数据......")
4541
os.makedirs(get_cache_dir(), exist_ok=True)
4642
for cache in get_cache_dir().glob("*.json"):
@@ -50,3 +46,6 @@ async def init():
5046
if not data.timestamp.date() == datetime.now().date():
5147
os.remove(str(cache))
5248
logger.info("缓存数据初始化完成!")
49+
50+
51+
__all__ = ["commands", "llm_tool", "sql_models"]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import random
22
import typing
33

4+
from amrita.plugins.menu import MatcherData
45
from nonebot import on_command
56
from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent, Message, MessageEvent
67
from nonebot.params import CommandArg
@@ -16,6 +17,9 @@
1617
priority=10,
1718
block=True,
1819
rule=lambda: get_config().enable_omikuji,
20+
state=MatcherData(
21+
name="omikuji", description="抽御神签", usage="/omikuji [主题]"
22+
).model_dump(),
1923
)
2024

2125

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
class Config(BaseModel):
1111
"""
12-
Configuration for nonebot_plugin_omikuji
12+
Configuration for amrita_plugin_omikuji
1313
"""
1414

1515
omikuji_send_by_chat: bool = False # 是否交给模型进行二次响应
1616
enable_omikuji: bool = True # 是否启用
1717
omikuji_add_system_prompt: bool = (
18-
True # 是否加入SuggarChat的系统提示(生成更符合角色设定的答案)
18+
True # 是否加入AmritaBot的系统提示(生成更符合角色设定的答案)
1919
)
2020
omikuji_use_cache: bool = True # 是否使用语料库的缓存(LLM生成后的缓存)
2121
omikuji_cache_expire_days: int = (
Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
import typing
22

3-
from nonebot import get_bot, logger
4-
from nonebot.adapters.onebot.v11 import MessageEvent
5-
from nonebot_plugin_suggarchat.API import (
6-
FunctionDefinitionSchema,
7-
FunctionParametersSchema,
8-
FunctionPropertySchema,
3+
from amrita.plugins.chat.API import (
94
ToolContext,
105
ToolData,
11-
ToolFunctionSchema,
126
)
7+
from nonebot import get_bot, logger
8+
from nonebot.adapters.onebot.v11 import MessageEvent
139

14-
from nonebot_plugin_omikuji.cache import cache_omikuji, get_cached_omikuji
10+
from amrita_plugin_omikuji.cache import cache_omikuji, get_cached_omikuji
1511

1612
from .config import get_config
17-
from .models import OMIKUJI_THEMES, OmikujiData
13+
from .models import FUNC_META, OmikujiData
1814
from .utils import generate_omikuji
1915

2016
LEVEL = ["大吉", "吉", "中吉", "小吉", "末吉", "凶", "大凶"]
@@ -58,23 +54,4 @@ async def omikuji(ctx: ToolContext):
5854
ctx.matcher.cancel_nonebot_process()
5955

6056

61-
FUNC_META = ToolFunctionSchema(
62-
strict=True,
63-
function=FunctionDefinitionSchema(
64-
name="御神签(omikuji)",
65-
description="抽取一个御神签",
66-
parameters=FunctionParametersSchema(
67-
type="object",
68-
properties={
69-
"theme": FunctionPropertySchema(
70-
type="string",
71-
description="御神签主题(如果包含不良内容则随机选择)",
72-
enum=OMIKUJI_THEMES,
73-
)
74-
},
75-
required=["theme"],
76-
),
77-
),
78-
)
79-
8057
TOOL_DATA = ToolData(data=FUNC_META, func=omikuji, custom_run=True)

nonebot_plugin_omikuji/migrations/c303c8b3d73b_init.py renamed to amrita_plugin_omikuji/migrations/c303c8b3d73b_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def upgrade(name: str = "") -> None:
3838
sa.Column("updated_date", sa.String(length=30), nullable=False),
3939
sa.PrimaryKeyConstraint("id", name=op.f("pk_omikuji_cache")),
4040
sa.UniqueConstraint("level", "theme", name="uq_omikuji_cache_level_theme"),
41-
info={"bind_key": "nonebot_plugin_omikuji"},
41+
info={"bind_key": "amrita_plugin_omikuji"},
4242
)
4343
with op.batch_alter_table("omikuji_cache", schema=None) as batch_op:
4444
batch_op.create_index(
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import random
44
from typing import Literal
55

6-
from nonebot_plugin_suggarchat.API import (
6+
from amrita.plugins.chat.API import (
77
FunctionDefinitionSchema,
88
FunctionParametersSchema,
99
FunctionPropertySchema,
@@ -125,9 +125,9 @@ class OmikujiData(BaseModel):
125125
)
126126

127127
FUNC_META = ToolFunctionSchema(
128-
strict=False,
128+
strict=True,
129129
function=FunctionDefinitionSchema(
130-
name="御神签(omikuji)",
130+
name="omikuji",
131131
description="抽取一个御神签",
132132
parameters=FunctionParametersSchema(
133133
type="object",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
from copy import deepcopy
44
from datetime import datetime, timedelta
55

6-
from nonebot import logger
7-
from nonebot_plugin_suggarchat.API import (
6+
from amrita.plugins.chat.API import (
87
config_manager,
98
tools_caller,
109
)
10+
from nonebot import logger
1111

1212
from .cache import OmikujiCacheData
1313
from .config import get_config

0 commit comments

Comments
 (0)