Skip to content

Commit cf443aa

Browse files
authored
Merge pull request #31 from ertugrul59/main
update depricated model from gpt-4-vision-preview to gpt-4o
2 parents d9900e6 + 1e9a72e commit cf443aa

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

vision.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def encode_and_resize(image):
2525
def get_actions(screenshot, objective):
2626
encoded_screenshot = encode_and_resize(screenshot)
2727
response = openai.chat.completions.create(
28-
model="gpt-4-vision-preview",
28+
model="gpt-4o",
2929
messages=[
3030
{
3131
"role": "user",
@@ -48,20 +48,26 @@ def get_actions(screenshot, objective):
4848

4949
try:
5050
json_response = json.loads(response.choices[0].message.content)
51+
5152
except json.JSONDecodeError:
5253
print("Error: Invalid JSON response")
5354
cleaned_response = openai.chat.completions.create(
54-
model="gpt-3.5-turbo",
55+
model="gpt-4o",
5556
messages=[
5657
{
5758
"role": "system",
5859
"content": "You are a helpful assistant to fix an invalid JSON response. You need to fix the invalid JSON response to be valid JSON. You must respond in JSON only with no other fluff or bad things will happen. Do not return the JSON inside a code block.",
5960
},
60-
{"role": "user", "content": f"The invalid JSON response is: {response.choices[0].message.content}"},
61+
{
62+
"role": "user",
63+
"content": f"The invalid JSON response is: {response.choices[0].message.content}",
64+
},
6165
],
6266
)
6367
try:
64-
cleaned_json_response = json.loads(cleaned_response.choices[0].message.content)
68+
cleaned_json_response = json.loads(
69+
cleaned_response.choices[0].message.content
70+
)
6571
except json.JSONDecodeError:
6672
print("Error: Invalid JSON response")
6773
return {}

0 commit comments

Comments
 (0)