Skip to content

Commit

Permalink
Add a blank to invalid function call para message (microsoft#129)
Browse files Browse the repository at this point in the history
Fix some typos in error messages, including error words, blanks and
punctuation.

---------

Co-authored-by: cs_lucky <[email protected]>
  • Loading branch information
chenslucky and cs_lucky authored Aug 21, 2023
1 parent 08e1867 commit 3b47e72
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/promptflow-tools/promptflow/tools/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ def process_function_call(function_call):
param = function_call
else:
function_call_example = json.dumps({"name": "function_name"})
common_tsg = f"Here is a valid example: {function_call_example}. See the guide at" \
common_tsg = f"Here is a valid example: {function_call_example}. See the guide at " \
"https://platform.openai.com/docs/api-reference/chat/create#chat/create-function_call " \
"or view sample 'How to call functions with chat models' in our gallery."
try:
param = json.loads(function_call)
except json.JSONDecodeError:
raise ChatAPIInvalidFunctions(
message=f"function_call parameter '{function_call}' is an invaild json. {common_tsg}")
message=f"function_call parameter '{function_call}' is an invalid json. {common_tsg}")
except TypeError:
raise ChatAPIInvalidFunctions(
message=f"function_call parameter '{function_call}' must be str, bytes or bytearray"
Expand Down
2 changes: 1 addition & 1 deletion src/promptflow-tools/promptflow/tools/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ def embedding(connection: Union[AzureOpenAIConnection, OpenAIConnection], input:
)["data"][0]["embedding"]
else:
error_message = f"Not Support connection type '{type(connection).__name__}' for embedding api. " \
f"Connection type should be in [AzureOpenAIConnection, OpenAIConnection]"
f"Connection type should be in [AzureOpenAIConnection, OpenAIConnection]."
raise InvalidConnectionType(message=error_message)
4 changes: 2 additions & 2 deletions src/promptflow-tools/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def test_chat_api_invalid_functions(self, functions, error_message):
"function_call, error_message",
[
({"name": "get_current_weather"}, "must be str, bytes or bytearray"),
("{'name': 'get_current_weather'}", "is an invaild json"),
("get_current_weather", "is an invaild json"),
("{'name': 'get_current_weather'}", "is an invalid json"),
("get_current_weather", "is an invalid json"),
("123", "function_call parameter '123' must be a dict"),
('{"name1": "get_current_weather"}', 'function_call parameter {"name1": "get_current_weather"} must '
'contain "name" field'),
Expand Down

0 comments on commit 3b47e72

Please sign in to comment.