This commit is contained in:
Agnosto Dvonik 2024-02-24 17:59:15 -05:00
parent e8a9113ab3
commit 235a881f07

40
data.py
View File

@ -1,28 +1,26 @@
from PIL import Image from PIL import Image
from openai import OpenAI
import pytesseract as OCR import pytesseract as OCR
import os import api_key
from openai import OpenAI as AI
receipts = ['image.jpg']
amounts = []
merchants = []
OCR.pytesseract.tesseract_cmd = r"/usr/local/bin/tesseract" OCR.pytesseract.tesseract_cmd = r"/usr/local/bin/tesseract"
client = OpenAI( client = AI(api_key = api_key.key)
api_key = os.environ.get("OPENAI_API_KEY"),
for receipt in receipts:
text = OCR.image_to_string(receipt)
print(text)
req = client.chat.completions.create(
model="gpt-3.5.turbo",
messages = [{
"role": "user",
"content": f"parse the following receipt as JSON data: {text}",
}]
) )
def app(): print(req.choices[0].message.content)
# data shit --> where does it come from???
data = OCR.image_to_string("input.png")
print(data)
complete = client.chat.completions.create(
model="gpt-3.5-turbo",
messages = [
{
"role": "user",
"content": "parse the following data in JSON format: ${data}",
}
])
print(complete.choices[0].message.content)
app()