improving non-openai tool_call prompt

This commit is contained in:
TheDiscoMole 2024-01-20 00:16:00 +01:00
parent f5ced089d6
commit 2ebc9e3c92

View file

@ -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: