Skip to content

Commit

Permalink
🐛 Bug: Fix the bug where tools continue to be called when the tools j…
Browse files Browse the repository at this point in the history
…son returned by OpenAI is empty.

💻 Code: Upgrade ModelMerge version to 0.11.46
  • Loading branch information
yym68686 committed Sep 27, 2024
1 parent 564e02c commit b64cabc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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.11.45",
version="0.11.46",
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
6 changes: 3 additions & 3 deletions src/ModelMerge/models/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def ask_stream(
self.function_calls_counter[function_call_name] = 1
else:
self.function_calls_counter[function_call_name] += 1
if self.function_calls_counter[function_call_name] <= self.function_call_max_loop and function_full_response != {}:
if self.function_calls_counter[function_call_name] <= self.function_call_max_loop and function_full_response != "{}":
function_call_max_tokens = self.truncate_limit - message_token["total"] - 1000
if function_call_max_tokens <= 0:
function_call_max_tokens = int(self.truncate_limit / 2)
Expand Down Expand Up @@ -645,7 +645,7 @@ async def ask_stream_async(
# print("response.status_code", response.status_code, response.status_code == 200, response != None and response.status_code == 200, response.text == "", response.text[:400])
if response.status_code == 400 or response.status_code == 422:
print("response.text", response.text)
if _ == 2:
if "Content did not pass the moral check" in response.text:
raise Exception(f"{response.status_code} {response.reason_phrase} {response.text[:400]}")
if "function calling" in response.text:
if "tools" in json_post:
Expand Down Expand Up @@ -775,7 +775,7 @@ async def ask_stream_async(
self.function_calls_counter[function_call_name] = 1
else:
self.function_calls_counter[function_call_name] += 1
if self.function_calls_counter[function_call_name] <= self.function_call_max_loop and function_full_response != {}:
if self.function_calls_counter[function_call_name] <= self.function_call_max_loop and function_full_response != "{}":
function_call_max_tokens = self.truncate_limit - message_token["total"] - 1000
if function_call_max_tokens <= 0:
function_call_max_tokens = int(self.truncate_limit / 2)
Expand Down

0 comments on commit b64cabc

Please sign in to comment.