nonebot-plugin-githubmodels 0.1.7__tar.gz → 0.1.8__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.
@@ -0,0 +1,19 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) 2024 lyqgzbl
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ this software and associated documentation files (the "Software"), to deal in
6
+ the Software without restriction, including without limitation the rights to
7
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
+ the Software, and to permit persons to whom the Software is furnished to do so,
9
+ subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-githubmodels
3
- Version: 0.1.7
3
+ Version: 0.1.8
4
4
  Summary: API 调用 GitHub Models 的大语言模型
5
5
  Home-page: https://github.com/lyqgzbl/nonebot-plugin-githubmodels
6
6
  License: MIT
@@ -1,18 +1,21 @@
1
1
  import nonebot
2
+ from .config import Config
3
+ from nonebot import require
2
4
  from openai import AsyncOpenAI
3
- from nonebot import on_command, get_plugin_config, require
5
+ from nonebot import on_command
4
6
  require("nonebot_plugin_alconna")
5
7
  require("nonebot_plugin_htmlrender")
6
8
  from nonebot.adapters import Message
9
+ from nonebot import get_plugin_config
7
10
  from nonebot.params import CommandArg
8
11
  from nonebot.plugin import PluginMetadata
9
- from nonebot_plugin_alconna import UniMessage, Image
10
12
  from nonebot_plugin_htmlrender import md_to_pic
11
- from .config import Config
13
+ from nonebot_plugin_alconna import UniMessage, Image
12
14
 
13
15
  plugin_config = get_plugin_config(Config)
14
16
  TOKEN = plugin_config.github_token
15
17
  MODEL_NAME = plugin_config.ai_model_name
18
+ REPLY_IMAGE = plugin_config.ai_reply_image
16
19
  MAX_CONTEXT_LENGTH = plugin_config.max_context_length
17
20
 
18
21
  endpoint = "https://models.inference.ai.azure.com"
@@ -59,10 +62,12 @@ async def handle_function(args: Message = CommandArg()):
59
62
  reply = response.choices[0].message.content
60
63
  shared_context.append({"role": "assistant", "content": reply})
61
64
 
62
-
63
- pic = await md_to_pic(md=reply)
64
- await UniMessage.image(raw=pic).send(reply_to=True)
65
-
65
+ if REPLY_IMAGE:
66
+ pic = await md_to_pic(md=reply)
67
+ await UniMessage.image(raw=pic).send(reply_to=True)
68
+ else:
69
+ await UniMessage.text(reply).send(reply_to=True)
70
+
66
71
  __plugin_meta__ = PluginMetadata(
67
72
  name="githubmodels",
68
73
  description="API 调用 GitHub Models 的大语言模型",
@@ -70,4 +75,4 @@ __plugin_meta__ = PluginMetadata(
70
75
  type="application",
71
76
  homepage="https://github.com/lyqgzbl/nonebot-plugin-githubmodels",
72
77
  supported_adapters=None,
73
- )
78
+ )
@@ -4,4 +4,5 @@ from pydantic import BaseModel, Field
4
4
  class Config(BaseModel):
5
5
  github_token: Optional[str] = None
6
6
  ai_model_name: str = "gpt-4o-mini"
7
- max_context_length: int = Field(20, gt=0)
7
+ max_context_length: int = Field(20, gt=0)
8
+ ai_reply_image: bool = False
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "nonebot-plugin-githubmodels"
3
- version = "0.1.7"
3
+ version = "0.1.8"
4
4
  description = "API 调用 GitHub Models 的大语言模型"
5
5
  authors = ["lyqgzbl <admin@lyqgzbl.com>"]
6
6
  license = "MIT"