From 3b47e7278595a94fcb7787b863a51a8cdb9bd6b3 Mon Sep 17 00:00:00 2001 From: chenslucky <75061414+chenslucky@users.noreply.github.com> Date: Mon, 21 Aug 2023 16:28:22 +0800 Subject: [PATCH] Add a blank to invalid function call para message (#129) Fix some typos in error messages, including error words, blanks and punctuation. --------- Co-authored-by: cs_lucky --- src/promptflow-tools/promptflow/tools/common.py | 4 ++-- src/promptflow-tools/promptflow/tools/embedding.py | 2 +- src/promptflow-tools/tests/test_common.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/promptflow-tools/promptflow/tools/common.py b/src/promptflow-tools/promptflow/tools/common.py index a6226122d87..acc6f395f3d 100644 --- a/src/promptflow-tools/promptflow/tools/common.py +++ b/src/promptflow-tools/promptflow/tools/common.py @@ -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" diff --git a/src/promptflow-tools/promptflow/tools/embedding.py b/src/promptflow-tools/promptflow/tools/embedding.py index d4e97e01ce9..193c81d3e5a 100644 --- a/src/promptflow-tools/promptflow/tools/embedding.py +++ b/src/promptflow-tools/promptflow/tools/embedding.py @@ -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) diff --git a/src/promptflow-tools/tests/test_common.py b/src/promptflow-tools/tests/test_common.py index a00341a58d0..1bc2a5a7e88 100644 --- a/src/promptflow-tools/tests/test_common.py +++ b/src/promptflow-tools/tests/test_common.py @@ -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'),