nonebot-plugin-githubmodels 0.1.1__tar.gz → 0.1.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_githubmodels-0.1.1 → nonebot_plugin_githubmodels-0.1.3}/PKG-INFO +2 -2
- {nonebot_plugin_githubmodels-0.1.1 → nonebot_plugin_githubmodels-0.1.3}/nonebot_plugin_githubmodels/__init__.py +8 -6
- nonebot_plugin_githubmodels-0.1.3/nonebot_plugin_githubmodels/config.py +25 -0
- {nonebot_plugin_githubmodels-0.1.1 → nonebot_plugin_githubmodels-0.1.3}/pyproject.toml +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nonebot-plugin-githubmodels
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: API 调用 GitHub Models 的 GPT-4o 模型
|
|
5
5
|
Home-page: https://github.com/lyqgzbl/nonebot-plugin-githubmodels
|
|
6
6
|
License: MIT
|
|
@@ -14,6 +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: nonebot2 (>=2.
|
|
17
|
+
Requires-Dist: nonebot2 (>=2.2.1,<3.0.0)
|
|
18
18
|
Requires-Dist: openai (>=1.44.1,<2.0.0)
|
|
19
19
|
Project-URL: Repository, https://github.com/lyqgzbl/nonebot-plugin-githubmodels
|
|
@@ -4,17 +4,15 @@ from nonebot import on_command
|
|
|
4
4
|
from nonebot.adapters import Message
|
|
5
5
|
from nonebot.params import CommandArg
|
|
6
6
|
from nonebot.plugin import PluginMetadata
|
|
7
|
+
from .config import TOKEN,MODEL_NAME,MAX_CONTEXT_LENGTH,Config
|
|
7
8
|
|
|
8
|
-
config = nonebot.get_driver().config
|
|
9
|
-
token = config.github_token
|
|
10
9
|
endpoint = "https://models.inference.ai.azure.com"
|
|
11
|
-
model_name = "gpt-4o-mini"
|
|
12
10
|
client = AsyncOpenAI(
|
|
13
11
|
base_url=endpoint,
|
|
14
|
-
api_key=
|
|
12
|
+
api_key=TOKEN,
|
|
15
13
|
)
|
|
14
|
+
|
|
16
15
|
shared_context = []
|
|
17
|
-
MAX_CONTEXT_LENGTH = 20 # 上下文最大保留条数
|
|
18
16
|
AI = on_command("AI", priority=10, block=True)
|
|
19
17
|
|
|
20
18
|
@AI.handle()
|
|
@@ -41,7 +39,7 @@ async def handle_function(args: Message = CommandArg()):
|
|
|
41
39
|
|
|
42
40
|
response = await client.chat.completions.create(
|
|
43
41
|
messages=messages,
|
|
44
|
-
model=
|
|
42
|
+
model=MODEL_NAME,
|
|
45
43
|
temperature=1,
|
|
46
44
|
max_tokens=500,
|
|
47
45
|
top_p=1,
|
|
@@ -54,6 +52,9 @@ async def handle_function(args: Message = CommandArg()):
|
|
|
54
52
|
shared_context = shared_context[-MAX_CONTEXT_LENGTH:]
|
|
55
53
|
|
|
56
54
|
await AI.send(reply, reply_message=True)
|
|
55
|
+
reply = response.choices[0].message.content
|
|
56
|
+
shared_context.append({"role": "assistant", "content": reply})
|
|
57
|
+
|
|
57
58
|
|
|
58
59
|
|
|
59
60
|
__plugin_meta__ = PluginMetadata(
|
|
@@ -62,4 +63,5 @@ __plugin_meta__ = PluginMetadata(
|
|
|
62
63
|
usage="AI",
|
|
63
64
|
type="application",
|
|
64
65
|
homepage="https://github.com/lyqgzbl/nonebot-plugin-githubmodels",
|
|
66
|
+
supported_adapters=None,
|
|
65
67
|
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
from nonebot import get_driver
|
|
3
|
+
from nonebot import get_plugin_config
|
|
4
|
+
|
|
5
|
+
class Config:
|
|
6
|
+
def __init__(self):
|
|
7
|
+
try:
|
|
8
|
+
self.github_token = get_driver().config.github_token
|
|
9
|
+
except AttributeError:
|
|
10
|
+
self.github_token = None
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
self.model_name = get_driver().config.model_name
|
|
14
|
+
except AttributeError:
|
|
15
|
+
self.model_name = "gpt-4o-mini"
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
self.MAX_CONTEXT_LENGTH = get_driver().config.MAX_CONTEXT_LENGTH
|
|
19
|
+
except AttributeError:
|
|
20
|
+
self.MAX_CONTEXT_LENGTH = 20
|
|
21
|
+
|
|
22
|
+
config = Config()
|
|
23
|
+
TOKEN = config.github_token
|
|
24
|
+
MODEL_NAME = config.model_name
|
|
25
|
+
MAX_CONTEXT_LENGTH = config.MAX_CONTEXT_LENGTH
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "nonebot-plugin-githubmodels"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.3"
|
|
4
4
|
description = "API 调用 GitHub Models 的 GPT-4o 模型"
|
|
5
5
|
authors = ["lyqgzbl <admin@lyqgzbl.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -9,7 +9,7 @@ repository = "https://github.com/lyqgzbl/nonebot-plugin-githubmodels"
|
|
|
9
9
|
|
|
10
10
|
[tool.poetry.dependencies]
|
|
11
11
|
python = "^3.8"
|
|
12
|
-
nonebot2 = "^2.
|
|
12
|
+
nonebot2 = "^2.2.1"
|
|
13
13
|
openai = "^1.44.1"
|
|
14
14
|
|
|
15
15
|
[build-system]
|