Skip to content

Commit

Permalink
Merge pull request #829 from RockChinQ/version/3.2.3
Browse files Browse the repository at this point in the history
Release 3.2.3
  • Loading branch information
RockChinQ authored Jun 26, 2024
2 parents 9e6a01f + ec8bd49 commit 76434b2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkg/pipeline/resprule/resprule.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ async def process(self, query: core_entities.Query, stage_inst_name: str) -> ent

use_rule = rules['default']

if str(query.launcher_id) in use_rule:
use_rule = use_rule[str(query.launcher_id)]
if str(query.launcher_id) in rules:
use_rule = rules[str(query.launcher_id)]

for rule_matcher in self.rule_matchers: # 任意一个匹配就放行
res = await rule_matcher.match(str(query.message_chain), query.message_chain, use_rule, query)
Expand Down
9 changes: 6 additions & 3 deletions pkg/pipeline/resprule/rules/prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ async def match(
for prefix in prefixes:
if message_text.startswith(prefix):

# 查找第一个plain元素
for me in message_chain:
if isinstance(me, mirai.Plain):
me.text = me.text[len(prefix):]

return entities.RuleJudgeResult(
matching=True,
replacement=mirai.MessageChain([
mirai.Plain(message_text[len(prefix):])
]),
replacement=message_chain,
)

return entities.RuleJudgeResult(
Expand Down
13 changes: 10 additions & 3 deletions pkg/provider/modelmgr/apis/chatcmpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,16 @@ async def call(
messages: typing.List[llm_entities.Message],
funcs: typing.List[tools_entities.LLMFunction] = None,
) -> llm_entities.Message:
req_messages = [ # req_messages 仅用于类内,外部同步由 query.messages 进行
m.dict(exclude_none=True) for m in messages
]
req_messages = [] # req_messages 仅用于类内,外部同步由 query.messages 进行
for m in messages:
msg_dict = m.dict(exclude_none=True)
content = msg_dict.get("content")
if isinstance(content, list):
# 检查 content 列表中是否每个部分都是文本
if all(isinstance(part, dict) and part.get("type") == "text" for part in content):
# 将所有文本部分合并为一个字符串
msg_dict["content"] = "\n".join(part["text"] for part in content)
req_messages.append(msg_dict)

try:
return await self._closure(req_messages, model, funcs)
Expand Down

0 comments on commit 76434b2

Please sign in to comment.