nonebot-plugin-githubmodels 0.1.3__tar.gz → 0.1.5__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.3 → nonebot_plugin_githubmodels-0.1.5}/PKG-INFO +1 -1
- {nonebot_plugin_githubmodels-0.1.3 → nonebot_plugin_githubmodels-0.1.5}/nonebot_plugin_githubmodels/__init__.py +8 -3
- nonebot_plugin_githubmodels-0.1.5/nonebot_plugin_githubmodels/config.py +7 -0
- {nonebot_plugin_githubmodels-0.1.3 → nonebot_plugin_githubmodels-0.1.5}/pyproject.toml +1 -1
- nonebot_plugin_githubmodels-0.1.3/nonebot_plugin_githubmodels/config.py +0 -25
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import nonebot
|
|
2
2
|
from openai import AsyncOpenAI
|
|
3
3
|
from nonebot import on_command
|
|
4
|
+
from nonebot import get_plugin_config
|
|
4
5
|
from nonebot.adapters import Message
|
|
5
6
|
from nonebot.params import CommandArg
|
|
6
7
|
from nonebot.plugin import PluginMetadata
|
|
7
|
-
from .config import
|
|
8
|
+
from .config import Config
|
|
9
|
+
|
|
10
|
+
plugin_config = get_plugin_config(Config)
|
|
11
|
+
|
|
12
|
+
TOKEN = plugin_config.github_token
|
|
13
|
+
MODEL_NAME = plugin_config.ai_model_name
|
|
14
|
+
MAX_CONTEXT_LENGTH = plugin_config.max_context_length
|
|
8
15
|
|
|
9
16
|
endpoint = "https://models.inference.ai.azure.com"
|
|
10
17
|
client = AsyncOpenAI(
|
|
@@ -55,8 +62,6 @@ async def handle_function(args: Message = CommandArg()):
|
|
|
55
62
|
reply = response.choices[0].message.content
|
|
56
63
|
shared_context.append({"role": "assistant", "content": reply})
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
|
|
60
65
|
__plugin_meta__ = PluginMetadata(
|
|
61
66
|
name="githubmodels",
|
|
62
67
|
description="API 调用 GitHub Models 的 GPT-4o 模型",
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|