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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-githubmodels
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: API 调用 GitHub Models 的 GPT-4o 模型
5
5
  Home-page: https://github.com/lyqgzbl/nonebot-plugin-githubmodels
6
6
  License: MIT
@@ -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 TOKEN,MODEL_NAME,MAX_CONTEXT_LENGTH,Config
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 模型",
@@ -0,0 +1,7 @@
1
+ from typing import Optional
2
+ from pydantic import BaseModel, Field
3
+
4
+ class Config(BaseModel):
5
+ github_token: Optional[str] = None
6
+ ai_model_name: str = "gpt-4o-mini"
7
+ max_context_length: int = Field(20, gt=0)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "nonebot-plugin-githubmodels"
3
- version = "0.1.3"
3
+ version = "0.1.5"
4
4
  description = "API 调用 GitHub Models 的 GPT-4o 模型"
5
5
  authors = ["lyqgzbl <admin@lyqgzbl.com>"]
6
6
  license = "MIT"
@@ -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