-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathvision_completions.py
More file actions
29 lines (24 loc) · 885 Bytes
/
vision_completions.py
File metadata and controls
29 lines (24 loc) · 885 Bytes
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
"""Example of using the OpenAI API to generate completions for vision tasks."""
from openai import OpenAI
# The url can be found with vec-inf status $JOB_ID
client = OpenAI(base_url="http://gpuXXX:XXXX/v1", api_key="EMPTY")
# Update the model path accordingly
completion = client.chat.completions.create(
model="llava-1.5-13b-hf",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What's in this image?"},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
},
},
],
}
],
max_tokens=50,
)
print(completion)