-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e83d93a
commit bc39ffb
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import openai | ||
import os | ||
|
||
def image_analyzer(image_url, prompt): | ||
"""Use this tool when the user provides a URL with an image extension such as JPG or PNG. | ||
Parameters: | ||
'image_url' = URL containing the image or photograph. | ||
'prompt' = description of what the user wants to analyze in the image. If the user does not specify, it should default to "What's in this image?" | ||
""" | ||
client = openai.AzureOpenAI( | ||
azure_endpoint = 'https://openai-hal9.openai.azure.com/', | ||
api_key = os.environ['OPENAI_AZURE'], | ||
api_version = '2024-02-15-preview', | ||
) | ||
|
||
response = client.chat.completions.create( | ||
model="gpt-4o", | ||
messages=[ | ||
{ | ||
"role": "user", | ||
"content": [ | ||
{"type": "text", "text": prompt}, | ||
{ | ||
"type": "image_url", | ||
"image_url" : {"url": image_url,}, | ||
}, | ||
], | ||
} | ||
], | ||
) | ||
|
||
print(response.choices[0].message.content) | ||
return response.choices[0].message.content |