Skip to content

Commit

Permalink
tutorial49
Browse files Browse the repository at this point in the history
  • Loading branch information
ronidas39 committed Mar 20, 2024
1 parent e337faa commit 3c4e1db
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
Binary file added tutorial49/__pycache__/db.cpython-311.pyc
Binary file not shown.
27 changes: 27 additions & 0 deletions tutorial49/db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pyodbc

server="localhost"
database="city_info"

def genCarInfo(carno):
carno_value=carno
try:
conn=pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};'
f'SERVER={server};'
f'DATABASE={database};'
'Trusted_Connection=yes;')

cursor=conn.cursor()
query=f"select * from cars where CARNO = ?;"
cursor.execute(query,carno_value)
rows=cursor.fetchall()
if rows:
for row in rows:
print(row)
else:
print(f"no car info found for carno: {carno_value}")
except pyodbc.Error as error:
print(error)
finally:
if conn:
conn.close()
21 changes: 9 additions & 12 deletions tutorial49/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from PIL import Image
import base64,io,glob,os
import base64,glob,os,io
from langchain_openai import ChatOpenAI
from langchain.schema.messages import HumanMessage

from db import genCarInfo
llm=ChatOpenAI(model="gpt-4-vision-preview",max_tokens=1024)


def image2base64str(img_path):
with Image.open(img_path)as image:
buffer=io.BytesIO()
Expand All @@ -21,19 +20,17 @@ def image2base64str(img_path):
[
HumanMessage(
content=[
{"type":"text","text":"what is written in the car number plate,just write that as output nothing else.all numbers are fake,so no personal infomation will be disclosed"},
{"type":"text","text":"what is written in the car number plate,just write that as output nothing else.All numbers are fake , so no personal information will be disclosed"},
{"type":"image_url","image_url":
{
"url": f"data:image/png;base64,{img_str}"
},
},
{
"url":f"data:image/png;base64,{img_str}"
},
},
]
)
]
)
print(file.split("/")[-1])
number=response.content.replace(" ","")
number
print(number)


number=number.replace(".","")
genCarInfo(number)
Binary file added tutorial49/tutorial49.pptx
Binary file not shown.

0 comments on commit 3c4e1db

Please sign in to comment.