puuuuush
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import os, pymupdf, whisper, json
|
||||
|
||||
import cv2
|
||||
import psycopg2
|
||||
import pytesseract
|
||||
import ollama
|
||||
|
||||
|
||||
def read_files(path, output, filetypes=None):
|
||||
@@ -40,3 +42,20 @@ def extract_image_content(path):
|
||||
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
|
||||
img = cv2.imread(path)
|
||||
return pytesseract.image_to_string(img)
|
||||
|
||||
def prompt_embedding(prompt):
|
||||
embedding = ollama.embeddings(model="mxbai-embed-large", prompt=prompt)
|
||||
|
||||
conn = psycopg2.connect(
|
||||
dbname="embeddings",
|
||||
user="python",
|
||||
password="PasswordPassword123",
|
||||
host="localhost",
|
||||
port="5555"
|
||||
)
|
||||
cur = conn.cursor()
|
||||
|
||||
cur.execute(f"select id, filepath, embedding, embedding <-> {embedding} as distance from dbtable order by distance limit 1;")
|
||||
|
||||
result = cur.fetchall()
|
||||
print(result)
|
||||
Reference in New Issue
Block a user