Skip to content

Commit

Permalink
Fix the bug where Azure is not compatible with function role
Browse files Browse the repository at this point in the history
  • Loading branch information
yym68686 committed May 27, 2024
1 parent 9b16f0e commit 0d4ddae
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
# for text in bot.ask_stream("英伟达最早支持杜比视界的显卡是哪一代"):
# for text in bot.ask_stream("100个斐波纳切数列的和是多少"):
# for text in bot.ask_stream("上海有哪些好玩的地方?"):
for text in bot.ask_stream("https://arxiv.org/abs/2404.02041 这篇论文讲了啥?"):
# for text in bot.ask_stream("https://arxiv.org/abs/2404.02041 这篇论文讲了啥?"):
# for text in bot.ask_stream("今天伊朗总统目前的情况怎么样?"):
# for text in bot.ask_stream("just say test"):
# for text in bot.ask_stream("hi"):
for text in bot.ask_stream("画一只猫猫"):
print(text, end="")

# print("\n bot tokens usage", bot.tokens_usage)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name="modelmerge",
version="0.6.0",
version="0.6.1",
description="modelmerge is a multi-large language model API aggregator.",
long_description=Path.open(Path("README.md"), encoding="utf-8").read(),
long_description_content_type="text/markdown",
Expand Down
8 changes: 8 additions & 0 deletions src/ModelMerge/models/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,14 @@ def ask_stream(
"role": mess["role"],
"content": mess["content"][0]["text"]
}
if "'function' is not an allowed role" in response.text:
if json_post["messages"][-1]["role"] == "function":
mess = json_post["messages"][-1]
json_post["messages"][-1] = {
"role": "assistant",
"name": mess["name"],
"content": mess["content"]
}
else:
if "function_call" in json_post:
del json_post["function_call"]
Expand Down

0 comments on commit 0d4ddae

Please sign in to comment.