-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
49 lines (43 loc) · 1.33 KB
/
app.py
File metadata and controls
49 lines (43 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from groq import Groq
import os
from dotenv import load_dotenv
# Load environment variables from the .env file
load_dotenv()
# Retrieve the Groq API key from the environment variable
api_key = os.getenv("GROQ_API_KEY")
if not api_key:
raise ValueError("GROQ_API_KEY is not set in the .env file.")
# Initialize the Groq client with the API key
client = Groq(api_key=api_key)
# Create the chat completion request
completion = client.chat.completions.create(
model="llama-3.2-11b-vision-preview",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://static01.nyt.com/images/2016/06/28/nyregion/00SIDEWALKS1sub/00SIDEWALKS1sub-videoSixteenByNineJumbo1600.jpg" # Path to your image file
}
}
]
},
{
"role": "user",
"content": "describe this vision in detail. Tell me about everything present here"
}
],
temperature=1,
max_tokens=1024,
top_p=1,
stream=False,
stop=None,
)
# Print the response from the API
print(completion.choices[0].message())