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

36
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"),
)
def app(): for receipt in receipts:
# data shit --> where does it come from??? text = OCR.image_to_string(receipt)
data = OCR.image_to_string("input.png") print(text)
print(data)
complete = client.chat.completions.create( req = client.chat.completions.create(
model="gpt-3.5-turbo", model="gpt-3.5.turbo",
messages = [ messages = [{
{
"role": "user", "role": "user",
"content": "parse the following data in JSON format: ${data}", "content": f"parse the following receipt as JSON data: {text}",
} }]
]) )
print(complete.choices[0].message.content) print(req.choices[0].message.content)
app()