nonebot-plugin-githubmodels 0.1.0__tar.gz → 0.1.1__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.1.0
3
+ Version: 0.1.1
4
4
  Summary: API 调用 GitHub Models 的 GPT-4o 模型
5
5
  Home-page: https://github.com/lyqgzbl/nonebot-plugin-githubmodels
6
6
  License: MIT
@@ -14,7 +14,6 @@ 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
- Requires-Dist: nonebot-adapter-onebot (>=2.0.0,<3.0.0)
18
- Requires-Dist: nonebot2[fastapi] (>=2.0.0,<3.0.0)
17
+ Requires-Dist: nonebot2 (>=2.0.0,<3.0.0)
19
18
  Requires-Dist: openai (>=1.44.1,<2.0.0)
20
19
  Project-URL: Repository, https://github.com/lyqgzbl/nonebot-plugin-githubmodels
@@ -1,5 +1,5 @@
1
1
  import nonebot
2
- from openai import OpenAI
2
+ from openai import AsyncOpenAI
3
3
  from nonebot import on_command
4
4
  from nonebot.adapters import Message
5
5
  from nonebot.params import CommandArg
@@ -9,12 +9,12 @@ config = nonebot.get_driver().config
9
9
  token = config.github_token
10
10
  endpoint = "https://models.inference.ai.azure.com"
11
11
  model_name = "gpt-4o-mini"
12
- client = OpenAI(
12
+ client = AsyncOpenAI(
13
13
  base_url=endpoint,
14
14
  api_key=token,
15
15
  )
16
16
  shared_context = []
17
- MAX_CONTEXT_LENGTH = 20 # 设置上下文最大保留条数
17
+ MAX_CONTEXT_LENGTH = 20 # 上下文最大保留条数
18
18
  AI = on_command("AI", priority=10, block=True)
19
19
 
20
20
  @AI.handle()
@@ -29,7 +29,6 @@ async def handle_function(args: Message = CommandArg()):
29
29
 
30
30
  shared_context.append({"role": "user", "content": user_input})
31
31
 
32
- # 保持上下文列表的最大长度
33
32
  if len(shared_context) > MAX_CONTEXT_LENGTH:
34
33
  shared_context = shared_context[-MAX_CONTEXT_LENGTH:]
35
34
 
@@ -39,27 +38,28 @@ async def handle_function(args: Message = CommandArg()):
39
38
  "content": "回答尽量简练,请始终用中文回答。",
40
39
  }
41
40
  ] + shared_context
42
- response = client.chat.completions.create(
41
+
42
+ response = await client.chat.completions.create(
43
43
  messages=messages,
44
44
  model=model_name,
45
45
  temperature=1,
46
46
  max_tokens=500,
47
47
  top_p=1,
48
48
  )
49
+
49
50
  reply = response.choices[0].message.content
50
51
  shared_context.append({"role": "assistant", "content": reply})
51
52
 
52
- # 保持上下文列表的最大长度
53
53
  if len(shared_context) > MAX_CONTEXT_LENGTH:
54
54
  shared_context = shared_context[-MAX_CONTEXT_LENGTH:]
55
55
 
56
56
  await AI.send(reply, reply_message=True)
57
57
 
58
+
58
59
  __plugin_meta__ = PluginMetadata(
59
60
  name="githubmodels",
60
61
  description="API 调用 GitHub Models 的 GPT-4o 模型",
61
62
  usage="AI",
62
63
  type="application",
63
64
  homepage="https://github.com/lyqgzbl/nonebot-plugin-githubmodels",
64
- supported_adapters={"~onebot.v11"},
65
- )
65
+ )
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "nonebot-plugin-githubmodels"
3
- version = "0.1.0"
3
+ version = "0.1.1"
4
4
  description = "API 调用 GitHub Models 的 GPT-4o 模型"
5
5
  authors = ["lyqgzbl <admin@lyqgzbl.com>"]
6
6
  license = "MIT"
@@ -9,9 +9,8 @@ repository = "https://github.com/lyqgzbl/nonebot-plugin-githubmodels"
9
9
 
10
10
  [tool.poetry.dependencies]
11
11
  python = "^3.8"
12
- nonebot2 = { version = "^2.0.0", extras = ["fastapi"] }
12
+ nonebot2 = "^2.0.0"
13
13
  openai = "^1.44.1"
14
- nonebot-adapter-onebot = "^2.0.0"
15
14
 
16
15
  [build-system]
17
16
  requires = ["poetry-core>=1.0.0"]
@@ -21,4 +20,3 @@ build-backend = "poetry.core.masonry.api"
21
20
  name = "githubmodels"
22
21
  description = "API 调用 GitHub Models 的 GPT-4o 模型"
23
22
  type = "application"
24
- supported_adapters = ["~onebot.v11"]