From 030326319770b47809a76731d4476bd73c685950 Mon Sep 17 00:00:00 2001 From: kmishmael Date: Sun, 1 Sep 2024 18:52:09 +0300 Subject: [PATCH] fix: initialize request object, correct typo, and rename parameter - Initialize `r` to `None` to prevent potential `NameError`. - Correct typo: change "funcions" to "functions" in allowed parameters. - Rename "dataSources" to "data_sources" to align with API specs. --- examples/pipelines/providers/azure_openai_pipeline.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/pipelines/providers/azure_openai_pipeline.py b/examples/pipelines/providers/azure_openai_pipeline.py index 39146e00..bb4e6e74 100644 --- a/examples/pipelines/providers/azure_openai_pipeline.py +++ b/examples/pipelines/providers/azure_openai_pipeline.py @@ -56,8 +56,8 @@ def pipe( url = f"{self.valves.AZURE_OPENAI_ENDPOINT}/openai/deployments/{self.valves.AZURE_OPENAI_DEPLOYMENT_NAME}/chat/completions?api-version={self.valves.AZURE_OPENAI_API_VERSION}" allowed_params = {'messages', 'temperature', 'role', 'content', 'contentPart', 'contentPartImage', - 'enhancements', 'dataSources', 'n', 'stream', 'stop', 'max_tokens', 'presence_penalty', - 'frequency_penalty', 'logit_bias', 'user', 'function_call', 'funcions', 'tools', + 'enhancements', 'data_sources', 'n', 'stream', 'stop', 'max_tokens', 'presence_penalty', + 'frequency_penalty', 'logit_bias', 'user', 'function_call', 'functions', 'tools', 'tool_choice', 'top_p', 'log_probs', 'top_logprobs', 'response_format', 'seed'} # remap user field if "user" in body and not isinstance(body["user"], str): @@ -67,6 +67,8 @@ def pipe( if len(body) != len(filtered_body): print(f"Dropped params: {', '.join(set(body.keys()) - set(filtered_body.keys()))}") + # Initialize the response variable to None. + r = None try: r = requests.post( url=url,