nonebot-plugin-githubmodels 0.2.2__tar.gz → 0.2.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.2.2 → nonebot_plugin_githubmodels-0.2.3}/PKG-INFO +1 -1
- {nonebot_plugin_githubmodels-0.2.2 → nonebot_plugin_githubmodels-0.2.3}/nonebot_plugin_githubmodels/__init__.py +23 -17
- {nonebot_plugin_githubmodels-0.2.2 → nonebot_plugin_githubmodels-0.2.3}/nonebot_plugin_githubmodels/config.py +1 -1
- {nonebot_plugin_githubmodels-0.2.2 → nonebot_plugin_githubmodels-0.2.3}/pyproject.toml +1 -1
- {nonebot_plugin_githubmodels-0.2.2 → nonebot_plugin_githubmodels-0.2.3}/LICENSE +0 -0
- {nonebot_plugin_githubmodels-0.2.2 → nonebot_plugin_githubmodels-0.2.3}/README.md +0 -0
|
@@ -54,19 +54,22 @@ async def handle_function(user_input: Match[tuple[str]]):
|
|
|
54
54
|
|
|
55
55
|
@ai.got_path("user_input", prompt="请输入有效问题")
|
|
56
56
|
async def got_location(user_input: str):
|
|
57
|
-
global shared_context
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
shared_context
|
|
57
|
+
global shared_context, REPLY_IMAGE
|
|
58
|
+
if MAX_CONTEXT_LENGTH > 0:
|
|
59
|
+
shared_context.append({"role": "user", "content": user_input})
|
|
60
|
+
if len(shared_context) > MAX_CONTEXT_LENGTH:
|
|
61
|
+
shared_context = shared_context[-MAX_CONTEXT_LENGTH:]
|
|
61
62
|
|
|
62
63
|
messages = [
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
{"role": "system", "content": "回答尽量简练,请始终用中文回答"}
|
|
65
|
+
]
|
|
66
|
+
if MAX_CONTEXT_LENGTH > 0:
|
|
67
|
+
messages += shared_context
|
|
68
|
+
else:
|
|
69
|
+
messages.append({"role": "user", "content": user_input})
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
try:
|
|
72
|
+
response = await client.chat.completions.create(
|
|
70
73
|
messages=messages,
|
|
71
74
|
model=MODEL_NAME,
|
|
72
75
|
temperature=1,
|
|
@@ -74,14 +77,17 @@ async def got_location(user_input: str):
|
|
|
74
77
|
top_p=1,
|
|
75
78
|
)
|
|
76
79
|
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
reply = response.choices[0].message.content
|
|
81
|
+
if MAX_CONTEXT_LENGTH > 0:
|
|
82
|
+
shared_context.append({"role": "assistant", "content": reply})
|
|
79
83
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
if REPLY_IMAGE:
|
|
85
|
+
pic = await md_to_pic(md=reply)
|
|
86
|
+
await UniMessage.image(raw=pic).send(reply_to=True)
|
|
87
|
+
else:
|
|
88
|
+
await UniMessage.text(reply).send(reply_to=True)
|
|
89
|
+
finally:
|
|
90
|
+
REPLY_IMAGE = plugin_config.ai_reply_image
|
|
85
91
|
|
|
86
92
|
__plugin_meta__ = PluginMetadata(
|
|
87
93
|
name="githubmodels",
|
|
File without changes
|
|
File without changes
|