From 2ebc9e3c923fd1c92fe778c6b66fccf909d9834b Mon Sep 17 00:00:00 2001 From: TheDiscoMole Date: Sat, 20 Jan 2024 00:16:00 +0100 Subject: [PATCH] improving non-openai tool_call prompt --- litellm/llms/prompt_templates/factory.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/litellm/llms/prompt_templates/factory.py b/litellm/llms/prompt_templates/factory.py index 43fbe872409..b4bbb044782 100644 --- a/litellm/llms/prompt_templates/factory.py +++ b/litellm/llms/prompt_templates/factory.py @@ -394,7 +394,7 @@ def anthropic_pt( prompt += f"{AnthropicConstants.AI_PROMPT.value}" return prompt - + def _load_image_from_url(image_url): try: from PIL import Image @@ -413,7 +413,7 @@ def _load_image_from_url(image_url): # Load the image from the response content return Image.open(BytesIO(response.content)) - + except requests.RequestException as e: print(f"Request failed: {e}") except UnidentifiedImageError: @@ -521,7 +521,7 @@ def gemini_text_image_pt(messages: list): # Function call template def function_call_prompt(messages: list, functions: list): function_prompt = ( - "Produce JSON OUTPUT ONLY! The following functions are available to you:" + """Produce JSON OUTPUT ONLY! Adhere to this format {"name": "function_name", "arguments":{"argument_name": "argument_value"}} The following functions are available to you:""" ) for function in functions: function_prompt += f"""\n{function}\n""" @@ -529,7 +529,7 @@ def function_call_prompt(messages: list, functions: list): function_added_to_prompt = False for message in messages: if "system" in message["role"]: - message["content"] += f"""{function_prompt}""" + message["content"] += f""" {function_prompt}""" function_added_to_prompt = True if function_added_to_prompt == False: