nonebot-plugin-githubmodels 0.2.7__tar.gz → 0.2.8__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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-githubmodels
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: 一个调用 GitHub Models 的 AI 对话插件
5
5
  Home-page: https://github.com/lyqgzbl/nonebot-plugin-githubmodels
6
6
  License: MIT
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
19
  Requires-Dist: nonebot-plugin-alconna (>=0.54.0,<0.55.0)
20
- Requires-Dist: nonebot-plugin-htmlrender (>=0.3.5,<0.4.0)
20
+ Requires-Dist: nonebot-plugin-htmlrender (>=0.5.0,<0.6.0)
21
21
  Requires-Dist: nonebot2 (>=2.2.1,<3.0.0)
22
22
  Requires-Dist: openai (>=1.44.1,<2.0.0)
23
23
  Project-URL: Documentation, https://github.com/lyqgzbl/nonebot-plugin-githubmodels#readme
@@ -38,15 +38,17 @@ Description-Content-Type: text/markdown
38
38
 
39
39
  # nonebot-plugin-githubmodels
40
40
 
41
- _✨ API调用GitHub models大语言模型 ✨_
41
+ _✨ 一个调用 GitHub Models 的 AI 对话插件 ✨_
42
42
 
43
- <a href ="https://raw.githubusercontent.com/lyqgzbl/nonebot-plugin-githubmodels/refs/heads/main/LICENSE"><img src="https://img.shields.io/pypi/l/nonebot-plugin-githubmodels"> </a>
44
- <a href="https://pypi.python.org/pypi/nonebot-plugin-githubmodels"> <img src="https://img.shields.io/pypi/v/nonebot-plugin-githubmodels.svg" alt="pypi"></a>
45
- <img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="python">
43
+ ![License](https://img.shields.io/pypi/l/nonebot-plugin-githubmodels)
44
+ ![PyPI](https://img.shields.io/pypi/v/nonebot-plugin-githubmodels.svg)
45
+ ![Python](https://img.shields.io/badge/python-3.8+-blue.svg)
46
+ [![NoneBot Registry](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin%2Fnonebot-plugin-githubmodels)](https://registry.nonebot.dev/plugin/nonebot-plugin-githubmodels:nonebot_plugin_githubmodels)
47
+ [![Supported Adapters](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin-adapters%2Fnonebot-plugin-alconna)](https://registry.nonebot.dev/plugin/nonebot-plugin-alconna:nonebot_plugin_alconna)
46
48
 
47
49
  </div>
48
50
 
49
- # 安装
51
+ ## 安装
50
52
  使用nb-cli [推荐]
51
53
  ```shell
52
54
  nb plugin install nonebot-plugin-githubmodels
@@ -56,13 +58,55 @@ nb plugin install nonebot-plugin-githubmodels
56
58
  pip install nonebot-plugin-githubmodels
57
59
  ```
58
60
 
59
- # 使用
61
+ ## 使用
60
62
  命令需要加 [NoneBot 命令前缀](https://nonebot.dev/docs/appendices/config#command-start-和-command-separator) (默认为`/`)
61
63
  使用命令`AI`/`ai`触发插件
62
64
  命令选项`-r` 重置上下文记忆
63
65
  命令选项`-i` 临时启用图片回复
64
66
 
65
- # 配置
67
+ ## 配置项
66
68
 
67
- 配置参见 [.env.example](https://github.com/lyqgzbl/nonebot-plugin-githubmodels/blob/main/.env.example)
69
+ 配置方式:直接在 NoneBot 全局配置文件中添加以下配置项即可
68
70
 
71
+ ### github_token [必填]
72
+
73
+ - 类型:`str`
74
+ - 默认值:`None`
75
+ - 说明:用于访问 GitHub Models 的 GitHub token
76
+
77
+ ### max_context_length [选填]
78
+
79
+ - 类型:`int`
80
+ - 默认值:`20`
81
+ - 说明:记忆的上下文数量的最大值
82
+
83
+ ### ai_reply_image [选填]
84
+
85
+
86
+ - 类型: `bool`
87
+ - 默认: `False`
88
+ - 说明: 是否以图片的形式回复
89
+
90
+ ### ai_model_name [选填]
91
+
92
+ - 类型: `str`
93
+ - 默认: `gpt-4o-mini`
94
+ - 说明: 所使用的模型
95
+
96
+ ### ai_temperature [选填]
97
+
98
+ - 类型: `float`
99
+ - 默认: `1.0`
100
+ - 说明: 生成的文本的多样性和连贯性
101
+
102
+ ### ai_max_tokens [选填]
103
+
104
+ - 类型: `int`
105
+ - 默认: `1024`
106
+ - 说明: 模型生成文本的字数
107
+
108
+ ## ai_top_p [选填]
109
+
110
+ - 类型: `float`
111
+ - 默认: `1.0`
112
+ - 说明: 生成文本随机性
@@ -0,0 +1,86 @@
1
+ <!-- markdownlint-disable MD033 MD036 MD041 -->
2
+
3
+ <div align="center">
4
+
5
+ <a href="https://v2.nonebot.dev/store">
6
+ <img src="https://raw.githubusercontent.com/A-kirami/nonebot-plugin-template/resources/nbp_logo.png" width="180" height="180" alt="NoneBotPluginLogo">
7
+ </a>
8
+
9
+ <p>
10
+ <img src="https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/template/plugin.svg" alt="NoneBotPluginText">
11
+ </p>
12
+
13
+ # nonebot-plugin-githubmodels
14
+
15
+ _✨ 一个调用 GitHub Models 的 AI 对话插件 ✨_
16
+
17
+ ![License](https://img.shields.io/pypi/l/nonebot-plugin-githubmodels)
18
+ ![PyPI](https://img.shields.io/pypi/v/nonebot-plugin-githubmodels.svg)
19
+ ![Python](https://img.shields.io/badge/python-3.8+-blue.svg)
20
+ [![NoneBot Registry](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin%2Fnonebot-plugin-githubmodels)](https://registry.nonebot.dev/plugin/nonebot-plugin-githubmodels:nonebot_plugin_githubmodels)
21
+ [![Supported Adapters](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin-adapters%2Fnonebot-plugin-alconna)](https://registry.nonebot.dev/plugin/nonebot-plugin-alconna:nonebot_plugin_alconna)
22
+
23
+ </div>
24
+
25
+ ## 安装
26
+ 使用nb-cli [推荐]
27
+ ```shell
28
+ nb plugin install nonebot-plugin-githubmodels
29
+ ```
30
+ 使用pip
31
+ ```shell
32
+ pip install nonebot-plugin-githubmodels
33
+ ```
34
+
35
+ ## 使用
36
+ 命令需要加 [NoneBot 命令前缀](https://nonebot.dev/docs/appendices/config#command-start-和-command-separator) (默认为`/`)
37
+ 使用命令`AI`/`ai`触发插件
38
+ 命令选项`-r` 重置上下文记忆
39
+ 命令选项`-i` 临时启用图片回复
40
+
41
+ ## 配置项
42
+
43
+ 配置方式:直接在 NoneBot 全局配置文件中添加以下配置项即可
44
+
45
+ ### github_token [必填]
46
+
47
+ - 类型:`str`
48
+ - 默认值:`None`
49
+ - 说明:用于访问 GitHub Models 的 GitHub token
50
+
51
+ ### max_context_length [选填]
52
+
53
+ - 类型:`int`
54
+ - 默认值:`20`
55
+ - 说明:记忆的上下文数量的最大值
56
+
57
+ ### ai_reply_image [选填]
58
+
59
+
60
+ - 类型: `bool`
61
+ - 默认: `False`
62
+ - 说明: 是否以图片的形式回复
63
+
64
+ ### ai_model_name [选填]
65
+
66
+ - 类型: `str`
67
+ - 默认: `gpt-4o-mini`
68
+ - 说明: 所使用的模型
69
+
70
+ ### ai_temperature [选填]
71
+
72
+ - 类型: `float`
73
+ - 默认: `1.0`
74
+ - 说明: 生成的文本的多样性和连贯性
75
+
76
+ ### ai_max_tokens [选填]
77
+
78
+ - 类型: `int`
79
+ - 默认: `1024`
80
+ - 说明: 模型生成文本的字数
81
+
82
+ ## ai_top_p [选填]
83
+
84
+ - 类型: `float`
85
+ - 默认: `1.0`
86
+ - 说明: 生成文本随机性
@@ -14,7 +14,7 @@ from nonebot_plugin_alconna import UniMessage, on_alconna, Match
14
14
  from nonebot_plugin_htmlrender import md_to_pic
15
15
 
16
16
  from .config import Config
17
- from .GPT_handler import GPTHandler
17
+ from .openai_handler import OPENAI_Handler
18
18
  from .context_manager import ContextManager
19
19
 
20
20
 
@@ -35,9 +35,9 @@ REPLY_IMAGE = plugin_config.ai_reply_image
35
35
 
36
36
  if not plugin_config.github_token:
37
37
  logger.opt(colors=True).warning("<yellow>缺失必要配置项 'github_token',已禁用该插件</yellow>")
38
- GPT_handler = None
38
+ openai_handler = None
39
39
  else:
40
- GPT_handler = GPTHandler(
40
+ openai_handler = OPENAI_Handler(
41
41
  api_key=plugin_config.github_token,
42
42
  endpoint="https://models.inference.ai.azure.com",
43
43
  model_name=plugin_config.ai_model_name,
@@ -63,7 +63,7 @@ ai = on_alconna(
63
63
  Args["user_input?", MultiVar(str)],
64
64
  Option("-r|--reset", help_text="重置上下文记忆"),
65
65
  Option("-i|--image", help_text="临时启用图片回复"),
66
- meta=CommandMeta(
66
+ meta=CommandMeta(
67
67
  description="AI 对话插件",
68
68
  usage=__plugin_meta__.usage,
69
69
  example="/AI Hello; /AI -i Hello; /AI -r",
@@ -104,7 +104,7 @@ async def got_location(user_input: str):
104
104
  messages = [{"role": "system", "content": "回答尽量简练,请始终用中文回答"}]
105
105
  context_manager.add_message("user", user_input)
106
106
  messages += context_manager.get_context()
107
- reply = await GPT_handler.get_response(messages)
107
+ reply = await openai_handler.get_response(messages)
108
108
  context_manager.add_message("assistant", reply)
109
109
  if REPLY_IMAGE:
110
110
  current_hour = datetime.datetime.now().hour
@@ -1,19 +1,23 @@
1
1
  body {
2
- background-color: #1e1e2f; /* 深色背景 */
3
- color: #d4d4d4; /* 浅色文字 */
4
- font-family: Arial, Helvetica, sans-serif;
5
- line-height: 1.6;
2
+ background-color: #1e1e2f;
3
+ color: #d4d4d4;
4
+ font-family: -apple-system, BlinkMacSystemFont, "Microsoft Yahei", "Noto Sans", sans-serif, monospace;
5
+ line-height: 1.8;
6
6
  margin: 0;
7
7
  padding: 1rem;
8
+ overflow-wrap: break-word;
9
+ text-rendering: optimizeLegibility;
10
+ -webkit-font-smoothing: antialiased;
11
+ font-size: 16px;
8
12
  }
9
13
 
10
14
  h1, h2, h3, h4, h5, h6 {
11
- color: #ffffff; /* 标题白色 */
12
- border-bottom: 1px solid #444; /* 标题下的分隔线 */
15
+ color: #ffffff;
16
+ border-bottom: 1px solid #444;
13
17
  }
14
18
 
15
19
  a {
16
- color: #569cd6; /* 链接蓝色 */
20
+ color: #569cd6;
17
21
  text-decoration: none;
18
22
  }
19
23
 
@@ -22,14 +26,14 @@ a:hover {
22
26
  }
23
27
 
24
28
  code, pre {
25
- background-color: #2d2d3a; /* 代码块背景 */
26
- color: #dcdcaa; /* 代码块文字颜色 */
29
+ background-color: #2d2d3a;
30
+ color: #d4d4d4;
27
31
  border-radius: 5px;
28
32
  padding: 0.2rem 0.4rem;
29
33
  }
30
34
 
31
35
  blockquote {
32
- border-left: 4px solid #444; /* 引用的边框 */
36
+ border-left: 4px solid #444;
33
37
  padding-left: 1rem;
34
38
  color: #999;
35
39
  font-style: italic;
@@ -0,0 +1,61 @@
1
+ body {
2
+ background-color: #f9f9f9;
3
+ color: #333333;
4
+ font-family: -apple-system, BlinkMacSystemFont, "Microsoft Yahei", "Noto Sans", sans-serif, monospace;
5
+ line-height: 1.8;
6
+ margin: 0;
7
+ padding: 1rem;
8
+ overflow-wrap: break-word;
9
+ text-rendering: optimizeLegibility;
10
+ -webkit-font-smoothing: antialiased;
11
+ font-size: 16px;
12
+ }
13
+
14
+ h1, h2, h3, h4, h5, h6 {
15
+ color: #000000;
16
+ border-bottom: 1px solid #cccccc;
17
+ }
18
+
19
+ a {
20
+ color: #0066cc;
21
+ text-decoration: none;
22
+ }
23
+
24
+ a:hover {
25
+ text-decoration: underline;
26
+ }
27
+
28
+ code, pre {
29
+ background-color: #e5e5e5;
30
+ color: #333333;
31
+ border-radius: 5px;
32
+ padding: 0.2rem 0.4rem;
33
+ }
34
+
35
+ blockquote {
36
+ border-left: 4px solid #cccccc;
37
+ padding-left: 1rem;
38
+ color: #666666;
39
+ font-style: italic;
40
+ }
41
+
42
+ table {
43
+ width: 100%;
44
+ border-collapse: collapse;
45
+ margin: 1rem 0;
46
+ background-color: #ffffff;
47
+ }
48
+
49
+ table th, table td {
50
+ border: 1px solid #cccccc;
51
+ padding: 0.5rem;
52
+ text-align: left;
53
+ color: #333333;
54
+ }
55
+
56
+ hr {
57
+ border: 0;
58
+ height: 1px;
59
+ background: #cccccc;
60
+ margin: 2rem 0;
61
+ }
@@ -1,6 +1,6 @@
1
1
  from openai import AsyncOpenAI
2
2
 
3
- class GPTHandler:
3
+ class OPENAI_Handler:
4
4
  def __init__(
5
5
  self,
6
6
  api_key: str,
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "nonebot-plugin-githubmodels"
3
- version = "0.2.7"
3
+ version = "0.2.8"
4
4
  description = "一个调用 GitHub Models 的 AI 对话插件"
5
5
  readme = "README.md"
6
6
  authors = ["lyqgzbl <admin@lyqgzbl.com>"]
@@ -14,7 +14,7 @@ keywords = ["nonebot2", "GitHub Models"]
14
14
  python = "^3.8"
15
15
  nonebot2 = "^2.2.1"
16
16
  openai = "^1.44.1"
17
- nonebot-plugin-htmlrender = "^0.3.5"
17
+ nonebot-plugin-htmlrender = "^0.5.0"
18
18
  nonebot-plugin-alconna = "^0.54.0"
19
19
 
20
20
  [build-system]
@@ -1,41 +0,0 @@
1
- <!-- markdownlint-disable MD033 MD036 MD041 -->
2
-
3
- <div align="center">
4
-
5
- <a href="https://v2.nonebot.dev/store">
6
- <img src="https://raw.githubusercontent.com/A-kirami/nonebot-plugin-template/resources/nbp_logo.png" width="180" height="180" alt="NoneBotPluginLogo">
7
- </a>
8
-
9
- <p>
10
- <img src="https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/template/plugin.svg" alt="NoneBotPluginText">
11
- </p>
12
-
13
- # nonebot-plugin-githubmodels
14
-
15
- _✨ API调用GitHub models大语言模型 ✨_
16
-
17
- <a href ="https://raw.githubusercontent.com/lyqgzbl/nonebot-plugin-githubmodels/refs/heads/main/LICENSE"><img src="https://img.shields.io/pypi/l/nonebot-plugin-githubmodels"> </a>
18
- <a href="https://pypi.python.org/pypi/nonebot-plugin-githubmodels"> <img src="https://img.shields.io/pypi/v/nonebot-plugin-githubmodels.svg" alt="pypi"></a>
19
- <img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="python">
20
-
21
- </div>
22
-
23
- # 安装
24
- 使用nb-cli [推荐]
25
- ```shell
26
- nb plugin install nonebot-plugin-githubmodels
27
- ```
28
- 使用pip
29
- ```shell
30
- pip install nonebot-plugin-githubmodels
31
- ```
32
-
33
- # 使用
34
- 命令需要加 [NoneBot 命令前缀](https://nonebot.dev/docs/appendices/config#command-start-和-command-separator) (默认为`/`)
35
- 使用命令`AI`/`ai`触发插件
36
- 命令选项`-r` 重置上下文记忆
37
- 命令选项`-i` 临时启用图片回复
38
-
39
- # 配置
40
-
41
- 配置参见 [.env.example](https://github.com/lyqgzbl/nonebot-plugin-githubmodels/blob/main/.env.example)
@@ -1,57 +0,0 @@
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
- }