add
This commit is contained in:
parent
e8a9113ab3
commit
235a881f07
40
data.py
40
data.py
@ -1,28 +1,26 @@
|
||||
from PIL import Image
|
||||
from openai import OpenAI
|
||||
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"
|
||||
|
||||
client = OpenAI(
|
||||
api_key = os.environ.get("OPENAI_API_KEY"),
|
||||
client = AI(api_key = api_key.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():
|
||||
# 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()
|
||||
print(req.choices[0].message.content)
|
||||
|
Loading…
Reference in New Issue
Block a user