nonebot-plugin-githubmodels 0.2.5__tar.gz → 0.2.7__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.
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-githubmodels
3
- Version: 0.2.5
4
- Summary: API 调用 GitHub Models 的大语言模型
3
+ Version: 0.2.7
4
+ Summary: 一个调用 GitHub Models 的 AI 对话插件
5
5
  Home-page: https://github.com/lyqgzbl/nonebot-plugin-githubmodels
6
6
  License: MIT
7
+ Keywords: nonebot2,GitHub Models
7
8
  Author: lyqgzbl
8
9
  Author-email: admin@lyqgzbl.com
9
10
  Requires-Python: >=3.8,<4.0
@@ -15,10 +16,11 @@ Classifier: Programming Language :: Python :: 3.10
15
16
  Classifier: Programming Language :: Python :: 3.11
16
17
  Classifier: Programming Language :: Python :: 3.12
17
18
  Classifier: Programming Language :: Python :: 3.13
18
- Requires-Dist: nonebot-plugin-alconna (>=0.53.0,<0.54.0)
19
+ Requires-Dist: nonebot-plugin-alconna (>=0.54.0,<0.55.0)
19
20
  Requires-Dist: nonebot-plugin-htmlrender (>=0.3.5,<0.4.0)
20
21
  Requires-Dist: nonebot2 (>=2.2.1,<3.0.0)
21
22
  Requires-Dist: openai (>=1.44.1,<2.0.0)
23
+ Project-URL: Documentation, https://github.com/lyqgzbl/nonebot-plugin-githubmodels#readme
22
24
  Project-URL: Repository, https://github.com/lyqgzbl/nonebot-plugin-githubmodels
23
25
  Description-Content-Type: text/markdown
24
26
 
@@ -1,13 +1,15 @@
1
+ import datetime
2
+ from pathlib import Path
3
+
1
4
  import nonebot
2
5
  from nonebot import require, get_plugin_config
3
6
  from nonebot.rule import Rule
4
7
  from nonebot.log import logger
5
- from nonebot.plugin import PluginMetadata
6
-
8
+ from nonebot.plugin import PluginMetadata, inherit_supported_adapters
7
9
  require("nonebot_plugin_alconna")
8
10
  require("nonebot_plugin_htmlrender")
9
11
  from openai import BadRequestError
10
- from arclet.alconna import Args, Option, Alconna, MultiVar
12
+ from arclet.alconna import Args, Option, Alconna, MultiVar, CommandMeta
11
13
  from nonebot_plugin_alconna import UniMessage, on_alconna, Match
12
14
  from nonebot_plugin_htmlrender import md_to_pic
13
15
 
@@ -16,6 +18,17 @@ from .GPT_handler import GPTHandler
16
18
  from .context_manager import ContextManager
17
19
 
18
20
 
21
+ __plugin_meta__ = PluginMetadata(
22
+ name="GitHub Models",
23
+ description="一个调用 GitHub Models 的 AI 对话插件",
24
+ usage="/AI Hello",
25
+ type="application",
26
+ homepage="https://github.com/lyqgzbl/nonebot-plugin-githubmodels",
27
+ config=Config,
28
+ supported_adapters=inherit_supported_adapters("nonebot_plugin_alconna"),
29
+ )
30
+
31
+
19
32
  plugin_config = get_plugin_config(Config)
20
33
  REPLY_IMAGE = plugin_config.ai_reply_image
21
34
 
@@ -48,8 +61,14 @@ ai = on_alconna(
48
61
  Alconna(
49
62
  "AI",
50
63
  Args["user_input?", MultiVar(str)],
51
- Option("-r|--reset"),
52
- Option("-i|--image"),
64
+ Option("-r|--reset", help_text="重置上下文记忆"),
65
+ Option("-i|--image", help_text="临时启用图片回复"),
66
+ meta=CommandMeta(
67
+ description="AI 对话插件",
68
+ usage=__plugin_meta__.usage,
69
+ example="/AI Hello; /AI -i Hello; /AI -r",
70
+ compact=True,
71
+ ),
53
72
  ),
54
73
  rule=is_enable(),
55
74
  use_cmd_start=True,
@@ -88,7 +107,12 @@ async def got_location(user_input: str):
88
107
  reply = await GPT_handler.get_response(messages)
89
108
  context_manager.add_message("assistant", reply)
90
109
  if REPLY_IMAGE:
91
- pic = await md_to_pic(md=reply)
110
+ current_hour = datetime.datetime.now().hour
111
+ is_dark_mode = 18 <= current_hour or current_hour < 6
112
+ css_file = (
113
+ Path(__file__).parent / "css" / ("dark.css" if is_dark_mode else "light.css")
114
+ )
115
+ pic = await md_to_pic(md=reply, css_path=str(css_file))
92
116
  await UniMessage.image(raw=pic).send(reply_to=True)
93
117
  else:
94
118
  await UniMessage.text(reply).send(reply_to=True)
@@ -96,14 +120,4 @@ async def got_location(user_input: str):
96
120
  logger.opt(colors=True).error(f"<red>API 请求失败: {e}</red>")
97
121
  await ai.send("问题触发了内容过滤策略,请修改问题后重试")
98
122
  finally:
99
- REPLY_IMAGE = plugin_config.ai_reply_image
100
-
101
-
102
- __plugin_meta__ = PluginMetadata(
103
- name="githubmodels",
104
- description="API 调用 GitHub Models 的大语言模型",
105
- usage="AI",
106
- type="application",
107
- homepage="https://github.com/lyqgzbl/nonebot-plugin-githubmodels",
108
- supported_adapters=None,
109
- )
123
+ REPLY_IMAGE = plugin_config.ai_reply_image
@@ -0,0 +1,57 @@
1
+ body {
2
+ background-color: #1e1e2f; /* 深色背景 */
3
+ color: #d4d4d4; /* 浅色文字 */
4
+ font-family: Arial, Helvetica, sans-serif;
5
+ line-height: 1.6;
6
+ margin: 0;
7
+ padding: 1rem;
8
+ }
9
+
10
+ h1, h2, h3, h4, h5, h6 {
11
+ color: #ffffff; /* 标题白色 */
12
+ border-bottom: 1px solid #444; /* 标题下的分隔线 */
13
+ }
14
+
15
+ a {
16
+ color: #569cd6; /* 链接蓝色 */
17
+ text-decoration: none;
18
+ }
19
+
20
+ a:hover {
21
+ text-decoration: underline;
22
+ }
23
+
24
+ code, pre {
25
+ background-color: #2d2d3a; /* 代码块背景 */
26
+ color: #dcdcaa; /* 代码块文字颜色 */
27
+ border-radius: 5px;
28
+ padding: 0.2rem 0.4rem;
29
+ }
30
+
31
+ blockquote {
32
+ border-left: 4px solid #444; /* 引用的边框 */
33
+ padding-left: 1rem;
34
+ color: #999;
35
+ font-style: italic;
36
+ }
37
+
38
+ table {
39
+ width: 100%;
40
+ border-collapse: collapse;
41
+ margin: 1rem 0;
42
+ background-color: #2d2d3a;
43
+ }
44
+
45
+ table th, table td {
46
+ border: 1px solid #444;
47
+ padding: 0.5rem;
48
+ text-align: left;
49
+ color: #d4d4d4;
50
+ }
51
+
52
+ hr {
53
+ border: 0;
54
+ height: 1px;
55
+ background: #444;
56
+ margin: 2rem 0;
57
+ }
@@ -0,0 +1,57 @@
1
+ body {
2
+ background-color: #ffffff; /* 亮色背景 */
3
+ color: #333333; /* 深色文字 */
4
+ font-family: Arial, Helvetica, sans-serif;
5
+ line-height: 1.6;
6
+ margin: 0;
7
+ padding: 1rem;
8
+ }
9
+
10
+ h1, h2, h3, h4, h5, h6 {
11
+ color: #000000; /* 标题黑色 */
12
+ border-bottom: 1px solid #ccc; /* 标题下的分隔线 */
13
+ }
14
+
15
+ a {
16
+ color: #007acc; /* 链接蓝色 */
17
+ text-decoration: none;
18
+ }
19
+
20
+ a:hover {
21
+ text-decoration: underline;
22
+ }
23
+
24
+ code, pre {
25
+ background-color: #f4f4f4; /* 代码块背景 */
26
+ color: #d14; /* 代码块文字颜色 */
27
+ border-radius: 5px;
28
+ padding: 0.2rem 0.4rem;
29
+ }
30
+
31
+ blockquote {
32
+ border-left: 4px solid #ccc; /* 引用的边框 */
33
+ padding-left: 1rem;
34
+ color: #666;
35
+ font-style: italic;
36
+ }
37
+
38
+ table {
39
+ width: 100%;
40
+ border-collapse: collapse;
41
+ margin: 1rem 0;
42
+ background-color: #f9f9f9;
43
+ }
44
+
45
+ table th, table td {
46
+ border: 1px solid #ccc;
47
+ padding: 0.5rem;
48
+ text-align: left;
49
+ color: #333;
50
+ }
51
+
52
+ hr {
53
+ border: 0;
54
+ height: 1px;
55
+ background: #ccc;
56
+ margin: 2rem 0;
57
+ }
@@ -1,25 +1,22 @@
1
1
  [tool.poetry]
2
2
  name = "nonebot-plugin-githubmodels"
3
- version = "0.2.5"
4
- description = "API 调用 GitHub Models 的大语言模型"
3
+ version = "0.2.7"
4
+ description = "一个调用 GitHub Models 的 AI 对话插件"
5
5
  readme = "README.md"
6
6
  authors = ["lyqgzbl <admin@lyqgzbl.com>"]
7
7
  license = "MIT"
8
8
  homepage = "https://github.com/lyqgzbl/nonebot-plugin-githubmodels"
9
9
  repository = "https://github.com/lyqgzbl/nonebot-plugin-githubmodels"
10
+ documentation = "https://github.com/lyqgzbl/nonebot-plugin-githubmodels#readme"
11
+ keywords = ["nonebot2", "GitHub Models"]
10
12
 
11
13
  [tool.poetry.dependencies]
12
14
  python = "^3.8"
13
15
  nonebot2 = "^2.2.1"
14
16
  openai = "^1.44.1"
15
17
  nonebot-plugin-htmlrender = "^0.3.5"
16
- nonebot-plugin-alconna = "^0.53.0"
18
+ nonebot-plugin-alconna = "^0.54.0"
17
19
 
18
20
  [build-system]
19
21
  requires = ["poetry-core>=1.0.0"]
20
- build-backend = "poetry.core.masonry.api"
21
-
22
- [tool.nonebot.plugin]
23
- name = "githubmodels"
24
- description = "API 调用 GitHub Models 的大语言模型"
25
- type = "application"
22
+ build-backend = "poetry.core.masonry.api"