Skip to content

Commit

Permalink
Fixing some dict value checking for function_call (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
nuaimat authored Nov 6, 2023
1 parent 8aa2e53 commit 8ad1209
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions memgpt/local_llm/llm_chat_completion_wrappers/airoboros.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def create_function_call(function_call):
elif message["role"] == "assistant":
prompt += f"\nASSISTANT: {message['content']}"
# need to add the function call if there was one
if message["function_call"]:
if "function_call" in message and message["function_call"]:
prompt += f"\n{create_function_call(message['function_call'])}"
elif message["role"] == "function":
# TODO find a good way to add this
Expand Down Expand Up @@ -339,7 +339,7 @@ def create_function_call(function_call, inner_thoughts=None):
prompt += f"\nASSISTANT:"
# need to add the function call if there was one
inner_thoughts = message["content"]
if message["function_call"]:
if "function_call" in message and message["function_call"]:
prompt += f"\n{create_function_call(message['function_call'], inner_thoughts=inner_thoughts)}"
elif message["role"] == "function":
# TODO find a good way to add this
Expand Down
2 changes: 1 addition & 1 deletion memgpt/local_llm/llm_chat_completion_wrappers/dolphin.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def create_function_call(function_call):
prompt += f"\n{message['content']}"
# prompt += f"\nASSISTANT: {message['content']}"
# need to add the function call if there was one
if message["function_call"]:
if "function_call" in message and message["function_call"]:
prompt += f"\n{create_function_call(message['function_call'])}"
prompt += f"{IM_END_TOKEN}"
elif message["role"] == "function":
Expand Down
4 changes: 2 additions & 2 deletions memgpt/local_llm/llm_chat_completion_wrappers/zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def create_function_call(function_call):
prompt += f"\n{message['content']}"
# prompt += f"\nASSISTANT: {message['content']}"
# need to add the function call if there was one
if message["function_call"]:
if "function_call" in message and message["function_call"]:
prompt += f"\n{create_function_call(message['function_call'])}"
prompt += f"{IM_END_TOKEN}"
elif message["role"] == "function":
Expand Down Expand Up @@ -259,7 +259,7 @@ def create_function_call(function_call, inner_thoughts=None):
prompt += f"\n<|assistant|>"
# need to add the function call if there was one
inner_thoughts = message["content"]
if message["function_call"]:
if "function_call" in message and message["function_call"]:
prompt += f"\n{create_function_call(message['function_call'], inner_thoughts=inner_thoughts)}"
elif message["role"] == "function":
# TODO find a good way to add this
Expand Down

0 comments on commit 8ad1209

Please sign in to comment.