nonebot-plugin-copywrite 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nonebot_plugin_copywrite-0.2.2 → nonebot_plugin_copywrite-0.2.3}/PKG-INFO +64 -4
- {nonebot_plugin_copywrite-0.2.2 → nonebot_plugin_copywrite-0.2.3}/README.md +63 -3
- {nonebot_plugin_copywrite-0.2.2 → nonebot_plugin_copywrite-0.2.3}/nonebot_plugin_copywrite/__init__.py +19 -13
- {nonebot_plugin_copywrite-0.2.2 → nonebot_plugin_copywrite-0.2.3}/nonebot_plugin_copywrite/chat.py +11 -11
- nonebot_plugin_copywrite-0.2.3/nonebot_plugin_copywrite/utils.py +9 -0
- {nonebot_plugin_copywrite-0.2.2 → nonebot_plugin_copywrite-0.2.3}/pyproject.toml +1 -1
- {nonebot_plugin_copywrite-0.2.2 → nonebot_plugin_copywrite-0.2.3}/LICENSE +0 -0
- {nonebot_plugin_copywrite-0.2.2 → nonebot_plugin_copywrite-0.2.3}/nonebot_plugin_copywrite/config.py +0 -0
- {nonebot_plugin_copywrite-0.2.2 → nonebot_plugin_copywrite-0.2.3}/nonebot_plugin_copywrite/copywrite/__init__.py +0 -0
- {nonebot_plugin_copywrite-0.2.2 → nonebot_plugin_copywrite-0.2.3}/nonebot_plugin_copywrite/copywrite/default.delete.yaml +0 -0
- {nonebot_plugin_copywrite-0.2.2 → nonebot_plugin_copywrite-0.2.3}/nonebot_plugin_copywrite/copywrite/default.long.yaml +0 -0
- {nonebot_plugin_copywrite-0.2.2 → nonebot_plugin_copywrite-0.2.3}/nonebot_plugin_copywrite/copywrite/default.short.yaml +0 -0
- {nonebot_plugin_copywrite-0.2.2 → nonebot_plugin_copywrite-0.2.3}/nonebot_plugin_copywrite/copywrite/life.checkpoint.long.yaml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nonebot-plugin-copywrite
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary:
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: Yan
|
|
@@ -33,9 +33,9 @@ _✨ NoneBot 定型文生成器 ✨_
|
|
|
33
33
|
<a href="./LICENSE">
|
|
34
34
|
<img src="https://img.shields.io/github/license/Yan-Zero/nonebot-plugin-copywrite.svg" alt="license">
|
|
35
35
|
</a>
|
|
36
|
-
|
|
36
|
+
<a href="https://pypi.python.org/pypi/nonebot-plugin-copywrite">
|
|
37
37
|
<img src="https://img.shields.io/pypi/v/nonebot-plugin-copywrite.svg" alt="pypi">
|
|
38
|
-
</a>
|
|
38
|
+
</a>
|
|
39
39
|
<a href="https://www.python.org">
|
|
40
40
|
<img src="https://img.shields.io/badge/python-3.11+-blue.svg" alt="python">
|
|
41
41
|
</a>
|
|
@@ -51,7 +51,67 @@ _✨ NoneBot 定型文生成器 ✨_
|
|
|
51
51
|
|
|
52
52
|
</div>
|
|
53
53
|
|
|
54
|
-
## 介绍
|
|
54
|
+
## 📖 介绍
|
|
55
55
|
|
|
56
56
|
基于 LLM 的定型文生成器
|
|
57
57
|
|
|
58
|
+
## ⚙️ 数据配置
|
|
59
|
+
|
|
60
|
+
### 定型文
|
|
61
|
+
|
|
62
|
+
存放于 ./data/copywrite/ 下面
|
|
63
|
+
|
|
64
|
+
#### 例子
|
|
65
|
+
|
|
66
|
+
```yaml
|
|
67
|
+
__category__: 114514
|
|
68
|
+
|
|
69
|
+
鸣潮:
|
|
70
|
+
examples:
|
|
71
|
+
- 圆桌是这样的,亚瑟王只需要使用圣剑就行了,而圆桌骑士们需要考虑的就多了,什么时候和贵妇幽会,什么时候挑起内战,都需要深思熟虑
|
|
72
|
+
- 儿童节是这样的,大哥哥只需要在家等着被抓就行了,而小萝莉要考虑的事情就很多了,什么时候喊杂鱼杂鱼,什么时候掀裙子露内裤,什么时候拉响警报器,都需要经过深思熟虑
|
|
73
|
+
- 企业家是这样的,员工只需要完成工作任务就行了,而老板要考虑的事情就很多了,什么时候拖欠工资,什么时候增加工作时间,员工绩效怎么压,都需要深思熟虑
|
|
74
|
+
addition: "你回复的文案应该是辛辣讽刺的,例如老板考虑如何拖欠工资,学生考虑低分怎么辩解,游戏玩家考虑如何开挂。"
|
|
75
|
+
model: grok-beta
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
#### 解释
|
|
79
|
+
|
|
80
|
+
- __category__: 定型文的分类
|
|
81
|
+
- examples: 例子
|
|
82
|
+
- addition: 附加内容,用以约束 LLM 可能的输出
|
|
83
|
+
- model: 使用的模型
|
|
84
|
+
|
|
85
|
+
## 💬 指令
|
|
86
|
+
|
|
87
|
+
### 文案
|
|
88
|
+
|
|
89
|
+
> /文案 [Key] (Keywords)* [Topic]
|
|
90
|
+
> /文案 求真学生 吃饭
|
|
91
|
+
|
|
92
|
+
查看可用文案:
|
|
93
|
+
> /文案
|
|
94
|
+
|
|
95
|
+
查看帮助(如果有):
|
|
96
|
+
> /文案 [Key]
|
|
97
|
+
|
|
98
|
+
#### 保留关键字
|
|
99
|
+
|
|
100
|
+
1. reload: 重新加载定型文数据
|
|
101
|
+
2. fetch: !!慎用!! 调用 pip 更新 nonebot-plugin-copywrite,由于依赖问题,可能下一次bot就无法启动了。
|
|
102
|
+
|
|
103
|
+
#### 文案 Alias
|
|
104
|
+
|
|
105
|
+
- copywrite
|
|
106
|
+
|
|
107
|
+
### 汉语新解
|
|
108
|
+
|
|
109
|
+
> /汉语新解 [Word]
|
|
110
|
+
> /汉语新解 求真书院
|
|
111
|
+
|
|
112
|
+
著名的某图片生成prompt
|
|
113
|
+
|
|
114
|
+
#### 汉语新解 Alias
|
|
115
|
+
|
|
116
|
+
- new-meaning
|
|
117
|
+
|
|
@@ -13,9 +13,9 @@ _✨ NoneBot 定型文生成器 ✨_
|
|
|
13
13
|
<a href="./LICENSE">
|
|
14
14
|
<img src="https://img.shields.io/github/license/Yan-Zero/nonebot-plugin-copywrite.svg" alt="license">
|
|
15
15
|
</a>
|
|
16
|
-
|
|
16
|
+
<a href="https://pypi.python.org/pypi/nonebot-plugin-copywrite">
|
|
17
17
|
<img src="https://img.shields.io/pypi/v/nonebot-plugin-copywrite.svg" alt="pypi">
|
|
18
|
-
</a>
|
|
18
|
+
</a>
|
|
19
19
|
<a href="https://www.python.org">
|
|
20
20
|
<img src="https://img.shields.io/badge/python-3.11+-blue.svg" alt="python">
|
|
21
21
|
</a>
|
|
@@ -31,6 +31,66 @@ _✨ NoneBot 定型文生成器 ✨_
|
|
|
31
31
|
|
|
32
32
|
</div>
|
|
33
33
|
|
|
34
|
-
## 介绍
|
|
34
|
+
## 📖 介绍
|
|
35
35
|
|
|
36
36
|
基于 LLM 的定型文生成器
|
|
37
|
+
|
|
38
|
+
## ⚙️ 数据配置
|
|
39
|
+
|
|
40
|
+
### 定型文
|
|
41
|
+
|
|
42
|
+
存放于 ./data/copywrite/ 下面
|
|
43
|
+
|
|
44
|
+
#### 例子
|
|
45
|
+
|
|
46
|
+
```yaml
|
|
47
|
+
__category__: 114514
|
|
48
|
+
|
|
49
|
+
鸣潮:
|
|
50
|
+
examples:
|
|
51
|
+
- 圆桌是这样的,亚瑟王只需要使用圣剑就行了,而圆桌骑士们需要考虑的就多了,什么时候和贵妇幽会,什么时候挑起内战,都需要深思熟虑
|
|
52
|
+
- 儿童节是这样的,大哥哥只需要在家等着被抓就行了,而小萝莉要考虑的事情就很多了,什么时候喊杂鱼杂鱼,什么时候掀裙子露内裤,什么时候拉响警报器,都需要经过深思熟虑
|
|
53
|
+
- 企业家是这样的,员工只需要完成工作任务就行了,而老板要考虑的事情就很多了,什么时候拖欠工资,什么时候增加工作时间,员工绩效怎么压,都需要深思熟虑
|
|
54
|
+
addition: "你回复的文案应该是辛辣讽刺的,例如老板考虑如何拖欠工资,学生考虑低分怎么辩解,游戏玩家考虑如何开挂。"
|
|
55
|
+
model: grok-beta
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### 解释
|
|
59
|
+
|
|
60
|
+
- __category__: 定型文的分类
|
|
61
|
+
- examples: 例子
|
|
62
|
+
- addition: 附加内容,用以约束 LLM 可能的输出
|
|
63
|
+
- model: 使用的模型
|
|
64
|
+
|
|
65
|
+
## 💬 指令
|
|
66
|
+
|
|
67
|
+
### 文案
|
|
68
|
+
|
|
69
|
+
> /文案 [Key] (Keywords)* [Topic]
|
|
70
|
+
> /文案 求真学生 吃饭
|
|
71
|
+
|
|
72
|
+
查看可用文案:
|
|
73
|
+
> /文案
|
|
74
|
+
|
|
75
|
+
查看帮助(如果有):
|
|
76
|
+
> /文案 [Key]
|
|
77
|
+
|
|
78
|
+
#### 保留关键字
|
|
79
|
+
|
|
80
|
+
1. reload: 重新加载定型文数据
|
|
81
|
+
2. fetch: !!慎用!! 调用 pip 更新 nonebot-plugin-copywrite,由于依赖问题,可能下一次bot就无法启动了。
|
|
82
|
+
|
|
83
|
+
#### 文案 Alias
|
|
84
|
+
|
|
85
|
+
- copywrite
|
|
86
|
+
|
|
87
|
+
### 汉语新解
|
|
88
|
+
|
|
89
|
+
> /汉语新解 [Word]
|
|
90
|
+
> /汉语新解 求真书院
|
|
91
|
+
|
|
92
|
+
著名的某图片生成prompt
|
|
93
|
+
|
|
94
|
+
#### 汉语新解 Alias
|
|
95
|
+
|
|
96
|
+
- new-meaning
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import re
|
|
2
2
|
import sys
|
|
3
|
+
import functools
|
|
3
4
|
import itertools
|
|
4
5
|
import asyncio
|
|
5
6
|
import pathlib
|
|
@@ -22,12 +23,14 @@ from nonebot.log import logger
|
|
|
22
23
|
|
|
23
24
|
from .copywrite import generate_copywrite
|
|
24
25
|
from .copywrite import Pattern
|
|
26
|
+
from .utils import to_await
|
|
25
27
|
from .chat import chat
|
|
26
28
|
|
|
27
29
|
# from datetime import datetime
|
|
28
30
|
# from nonebot.adapters.onebot.v11 import GroupMessageEvent
|
|
29
31
|
# from .config import copywrite_config
|
|
30
32
|
|
|
33
|
+
|
|
31
34
|
m_copywrite = on_command(
|
|
32
35
|
"copywrite",
|
|
33
36
|
aliases={"文案"},
|
|
@@ -62,7 +65,7 @@ _COPY: dict[str, Pattern] = {}
|
|
|
62
65
|
_COPY_TYPE: dict[str, set] = {}
|
|
63
66
|
|
|
64
67
|
|
|
65
|
-
|
|
68
|
+
def load(clear: bool = False, **kwargs):
|
|
66
69
|
global _COPY, _COPY_TYPE
|
|
67
70
|
if clear:
|
|
68
71
|
_COPY = {}
|
|
@@ -89,18 +92,18 @@ async def load(clear: bool = False, **kwargs):
|
|
|
89
92
|
_COPY_TYPE[category].add(key)
|
|
90
93
|
_COPY[key] = Pattern.model_validate(v)
|
|
91
94
|
|
|
95
|
+
return "重新加载完成。"
|
|
96
|
+
|
|
92
97
|
|
|
93
98
|
async def fetch(diff: bool = False, **kwargs):
|
|
94
99
|
pip_path = next(pathlib.Path(sys.executable).parent.glob("pip*"))
|
|
95
100
|
if not pip_path:
|
|
96
101
|
return "没有找到 pip 路径哦"
|
|
97
102
|
ret = await asyncio.create_subprocess_exec(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"git+https://github.com/Yan-Zero/nonebot-plugin-copywrite.git",
|
|
103
|
-
],
|
|
103
|
+
pip_path.absolute(),
|
|
104
|
+
"install",
|
|
105
|
+
"--upgrade",
|
|
106
|
+
"nonebot-plugin-copywrite",
|
|
104
107
|
stdout=asyncio.subprocess.PIPE,
|
|
105
108
|
stderr=asyncio.subprocess.PIPE,
|
|
106
109
|
)
|
|
@@ -121,7 +124,8 @@ async def fetch(diff: bool = False, **kwargs):
|
|
|
121
124
|
await load(clear=True)
|
|
122
125
|
|
|
123
126
|
ret = ret[ret.find("Successfully installed nonebot-plugin-copywrite-") + 48 :]
|
|
124
|
-
ret =
|
|
127
|
+
ret = ret[: ret.find("\n")]
|
|
128
|
+
ret = f"已经更新 {ret}。\n"
|
|
125
129
|
if diff:
|
|
126
130
|
if not _c:
|
|
127
131
|
_c = {}
|
|
@@ -163,15 +167,15 @@ async def fetch(diff: bool = False, **kwargs):
|
|
|
163
167
|
return ret.strip()
|
|
164
168
|
|
|
165
169
|
|
|
166
|
-
RESERVED_WORD["reload"] = load
|
|
167
|
-
RESERVED_WORD["fetch"] =
|
|
170
|
+
RESERVED_WORD["reload"] = to_await(load)
|
|
171
|
+
RESERVED_WORD["fetch"] = functools.partial(fetch, diff=True)
|
|
172
|
+
load()
|
|
168
173
|
|
|
169
174
|
|
|
170
175
|
@m_copywrite.handle()
|
|
171
176
|
async def _(bot: Bot, event: MessageEvent, args=CommandArg()):
|
|
172
177
|
args = args.extract_plain_text().strip()
|
|
173
178
|
if not args:
|
|
174
|
-
ret = "请输入要仿写的文案名字"
|
|
175
179
|
if True:
|
|
176
180
|
ret = ""
|
|
177
181
|
for category, keys in _COPY_TYPE.items():
|
|
@@ -180,6 +184,8 @@ async def _(bot: Bot, event: MessageEvent, args=CommandArg()):
|
|
|
180
184
|
+ ", ".join(sorted(keys, key=lambda x: (-len(x), x)))
|
|
181
185
|
+ "\n"
|
|
182
186
|
)
|
|
187
|
+
if not ret:
|
|
188
|
+
ret = "好像一片空白?"
|
|
183
189
|
await m_copywrite.finish(ret)
|
|
184
190
|
|
|
185
191
|
args = args.split(maxsplit=1)
|
|
@@ -211,7 +217,7 @@ async def _(bot: Bot, event: MessageEvent, args=CommandArg()):
|
|
|
211
217
|
|
|
212
218
|
try:
|
|
213
219
|
rsp = await chat(
|
|
214
|
-
|
|
220
|
+
messages=[
|
|
215
221
|
{
|
|
216
222
|
"role": "user",
|
|
217
223
|
"content": generate_copywrite(
|
|
@@ -240,7 +246,7 @@ async def _(args=CommandArg()):
|
|
|
240
246
|
|
|
241
247
|
try:
|
|
242
248
|
rsp = await chat(
|
|
243
|
-
|
|
249
|
+
messages=[
|
|
244
250
|
{
|
|
245
251
|
"role": "user",
|
|
246
252
|
"content": r""";; 模型: Claude Sonnet
|
{nonebot_plugin_copywrite-0.2.2 → nonebot_plugin_copywrite-0.2.3}/nonebot_plugin_copywrite/chat.py
RENAMED
|
@@ -5,19 +5,19 @@ from openai import AsyncOpenAI
|
|
|
5
5
|
# from nonebot import get_plugin_config
|
|
6
6
|
# from .config import Config
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
OPENAI_ASYNC_CLIENT: dict[str, AsyncOpenAI] = {}
|
|
9
9
|
try:
|
|
10
10
|
with open("configs/chatgpt-vision/keys.yaml") as f:
|
|
11
11
|
for i in yaml.safe_load(f):
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
OPENAI_ASYNC_CLIENT[i.get("model")] = AsyncOpenAI(
|
|
13
|
+
api_key=i.get("key"),
|
|
14
|
+
base_url=i.get("url"),
|
|
15
|
+
)
|
|
16
16
|
except Exception:
|
|
17
17
|
pass
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
async def chat(
|
|
20
|
+
async def chat(messages: list, model: str, times: int = 3, temperature: int = 0.65):
|
|
21
21
|
"""
|
|
22
22
|
Chat with ChatGPT
|
|
23
23
|
|
|
@@ -30,11 +30,11 @@ async def chat(message: list, model: str, times: int = 3, temperature: int = 0.6
|
|
|
30
30
|
times : int
|
|
31
31
|
The times you want to try
|
|
32
32
|
"""
|
|
33
|
-
if model not in
|
|
33
|
+
if model not in OPENAI_ASYNC_CLIENT:
|
|
34
34
|
raise ValueError(f"The model {model} is not supported.")
|
|
35
35
|
try:
|
|
36
|
-
rsp = await
|
|
37
|
-
messages=
|
|
36
|
+
rsp = await OPENAI_ASYNC_CLIENT[model].chat.completions.create(
|
|
37
|
+
messages=messages, model=model, temperature=temperature
|
|
38
38
|
)
|
|
39
39
|
if not rsp:
|
|
40
40
|
raise ValueError("The Response is Null.")
|
|
@@ -46,8 +46,8 @@ async def chat(message: list, model: str, times: int = 3, temperature: int = 0.6
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
async def draw_image(model: str, prompt: str, size: str = "1024x1024", times: int = 3):
|
|
49
|
-
if model not in
|
|
49
|
+
if model not in OPENAI_ASYNC_CLIENT:
|
|
50
50
|
raise ValueError(f"The model {model} is not supported.")
|
|
51
|
-
return await
|
|
51
|
+
return await OPENAI_ASYNC_CLIENT[model].images.generate(
|
|
52
52
|
model=model, prompt=prompt, size=size
|
|
53
53
|
)
|
|
File without changes
|
{nonebot_plugin_copywrite-0.2.2 → nonebot_plugin_copywrite-0.2.3}/nonebot_plugin_copywrite/config.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|