-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
28 lines (21 loc) · 668 Bytes
/
Copy pathtest.py
File metadata and controls
28 lines (21 loc) · 668 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
import easyocr
import os
import openai
from dotenv import load_dotenv
load_dotenv()
openai.api_key = os.getenv('key')
name = 'multican.jpg'
reader = easyocr.Reader(['en'])
result = reader.readtext(name)
food = " "
for x in result:
food = food + x[1] + " "
list_foods = []
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "In this sentence pick out the name of the every main food item: " + food + ". Only return the name of the food items and nothing else. for example 'beef stew', 'carrots', 'spinach'"}
]
)
list_foods = completion.choices[0].message.content.split(",")
print(list_foods)