You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
884 B
32 lines
884 B
5 months ago
|
from dotenv import load_dotenv
|
||
|
from openai import OpenAI
|
||
|
import os
|
||
|
|
||
|
load_dotenv()
|
||
|
|
||
|
openai_api_key = os.getenv("SWARMS_API_KEY")
|
||
|
openai_api_base = "https://api.swarms.world"
|
||
|
model = "gpt-4o"
|
||
|
|
||
|
client = OpenAI(api_key=openai_api_key, base_url=openai_api_base)
|
||
|
# Note that this model expects the image to come before the main text
|
||
|
chat_response = client.chat.completions.create(
|
||
|
model=model,
|
||
|
messages=[
|
||
|
{
|
||
|
"role": "user",
|
||
|
"content": [
|
||
|
{
|
||
|
"type": "image_url",
|
||
|
"image_url": {
|
||
|
"url": "https://home-cdn.reolink.us/wp-content/uploads/2022/04/010345091648784709.4253.jpg",
|
||
|
},
|
||
|
},
|
||
|
{"type": "text", "text": "What's in this image?"},
|
||
|
],
|
||
|
}
|
||
|
],
|
||
|
temperature=0.1,
|
||
|
)
|
||
|
print("Chat response:", chat_response)
|