nonebot-plugin-githubmodels 0.1.5__tar.gz → 0.1.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,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-githubmodels
3
- Version: 0.1.5
4
- Summary: API 调用 GitHub Models 的 GPT-4o 模型
3
+ Version: 0.1.7
4
+ Summary: API 调用 GitHub Models 的大语言模型
5
5
  Home-page: https://github.com/lyqgzbl/nonebot-plugin-githubmodels
6
6
  License: MIT
7
7
  Author: lyqgzbl
@@ -14,6 +14,9 @@ Classifier: Programming Language :: Python :: 3.9
14
14
  Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Requires-Dist: nonebot-plugin-alconna (>=0.52.0,<0.53.0)
19
+ Requires-Dist: nonebot-plugin-htmlrender (>=0.3.5,<0.4.0)
17
20
  Requires-Dist: nonebot2 (>=2.2.1,<3.0.0)
18
21
  Requires-Dist: openai (>=1.44.1,<2.0.0)
19
22
  Project-URL: Repository, https://github.com/lyqgzbl/nonebot-plugin-githubmodels
@@ -1,14 +1,16 @@
1
1
  import nonebot
2
2
  from openai import AsyncOpenAI
3
- from nonebot import on_command
4
- from nonebot import get_plugin_config
3
+ from nonebot import on_command, get_plugin_config, require
4
+ require("nonebot_plugin_alconna")
5
+ require("nonebot_plugin_htmlrender")
5
6
  from nonebot.adapters import Message
6
7
  from nonebot.params import CommandArg
7
8
  from nonebot.plugin import PluginMetadata
9
+ from nonebot_plugin_alconna import UniMessage, Image
10
+ from nonebot_plugin_htmlrender import md_to_pic
8
11
  from .config import Config
9
12
 
10
13
  plugin_config = get_plugin_config(Config)
11
-
12
14
  TOKEN = plugin_config.github_token
13
15
  MODEL_NAME = plugin_config.ai_model_name
14
16
  MAX_CONTEXT_LENGTH = plugin_config.max_context_length
@@ -18,19 +20,21 @@ client = AsyncOpenAI(
18
20
  base_url=endpoint,
19
21
  api_key=TOKEN,
20
22
  )
21
-
22
23
  shared_context = []
24
+
23
25
  AI = on_command("AI", priority=10, block=True)
24
26
 
25
27
  @AI.handle()
26
28
  async def handle_function(args: Message = CommandArg()):
27
29
  global shared_context
28
30
  user_input = args.extract_plain_text().strip()
31
+
29
32
  if user_input.lower() == "重置":
30
33
  shared_context = []
31
- await AI.finish("上下文已重置。请开始新的对话。")
34
+ await AI.finish("上下文已重置")
35
+
32
36
  if not user_input:
33
- await AI.finish("请输入有效的问题。")
37
+ await AI.finish("请输入有效的问题")
34
38
 
35
39
  shared_context.append({"role": "user", "content": user_input})
36
40
 
@@ -54,19 +58,16 @@ async def handle_function(args: Message = CommandArg()):
54
58
 
55
59
  reply = response.choices[0].message.content
56
60
  shared_context.append({"role": "assistant", "content": reply})
57
-
58
- if len(shared_context) > MAX_CONTEXT_LENGTH:
59
- shared_context = shared_context[-MAX_CONTEXT_LENGTH:]
60
-
61
- await AI.send(reply, reply_message=True)
62
- reply = response.choices[0].message.content
63
- shared_context.append({"role": "assistant", "content": reply})
64
-
61
+
62
+
63
+ pic = await md_to_pic(md=reply)
64
+ await UniMessage.image(raw=pic).send(reply_to=True)
65
+
65
66
  __plugin_meta__ = PluginMetadata(
66
67
  name="githubmodels",
67
- description="API 调用 GitHub Models 的 GPT-4o 模型",
68
+ description="API 调用 GitHub Models 的大语言模型",
68
69
  usage="AI",
69
70
  type="application",
70
71
  homepage="https://github.com/lyqgzbl/nonebot-plugin-githubmodels",
71
72
  supported_adapters=None,
72
- )
73
+ )
@@ -1,7 +1,7 @@
1
1
  [tool.poetry]
2
2
  name = "nonebot-plugin-githubmodels"
3
- version = "0.1.5"
4
- description = "API 调用 GitHub Models 的 GPT-4o 模型"
3
+ version = "0.1.7"
4
+ description = "API 调用 GitHub Models 的大语言模型"
5
5
  authors = ["lyqgzbl <admin@lyqgzbl.com>"]
6
6
  license = "MIT"
7
7
  homepage = "https://github.com/lyqgzbl/nonebot-plugin-githubmodels"
@@ -11,6 +11,8 @@ repository = "https://github.com/lyqgzbl/nonebot-plugin-githubmodels"
11
11
  python = "^3.8"
12
12
  nonebot2 = "^2.2.1"
13
13
  openai = "^1.44.1"
14
+ nonebot-plugin-htmlrender = "^0.3.5"
15
+ nonebot-plugin-alconna = "^0.52.0"
14
16
 
15
17
  [build-system]
16
18
  requires = ["poetry-core>=1.0.0"]
@@ -18,5 +20,5 @@ build-backend = "poetry.core.masonry.api"
18
20
 
19
21
  [tool.nonebot.plugin]
20
22
  name = "githubmodels"
21
- description = "API 调用 GitHub Models 的 GPT-4o 模型"
23
+ description = "API 调用 GitHub Models 的大语言模型"
22
24
  type = "application"