puuuuush
Puuuuush it babyyyyy DEEEEEEPER
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import ollama
|
||||
import pymupdf
|
||||
import os
|
||||
import lib
|
||||
import json
|
||||
import psycopg2
|
||||
|
||||
|
||||
|
||||
def retrieve_file_contents(path):
|
||||
file_extraction_functions = {
|
||||
@@ -30,5 +34,50 @@ def retrieve_file_contents(path):
|
||||
contents = retrieve_file_contents("C:\\Users\\afist\\Downloads\\SoftwareEng")
|
||||
|
||||
|
||||
embedding_list = []
|
||||
|
||||
print(json.dumps(contents, indent="\t"))
|
||||
def create_embeddings(pContent):
|
||||
conn = psycopg2.connect(
|
||||
dbname="embeddings",
|
||||
user="python",
|
||||
password="PasswordPassword123",
|
||||
host="localhost",
|
||||
port="5555"
|
||||
)
|
||||
cur = conn.cursor()
|
||||
|
||||
create_table_query = '''
|
||||
create table if not exists dbtable (
|
||||
id SERIAL PRIMARY KEY,
|
||||
filename TEXT NOT NULL,
|
||||
embedding VECTOR NOT NULL
|
||||
)
|
||||
'''
|
||||
|
||||
|
||||
cur.execute(create_table_query)
|
||||
|
||||
cur.execute('CREATE EXTENSION IF NOT EXISTS vector;')
|
||||
for content in pContent:
|
||||
merged_info = "Dateiname: " + content["filename"] + " Dateiinhalt: " + content[
|
||||
"content"] # Bessere Embeddings mit Dateiname // Information vorne dran?
|
||||
# print(merged_info)
|
||||
response = ollama.embeddings(model="mxbai-embed-large", prompt=merged_info)
|
||||
#embedding_list.append(response["embedding"])
|
||||
insert_data = f'insert into dbtable (filepath, embedding) Values ({content["filepath"]}, {response["embedding"]});'
|
||||
cur.execute(insert_data)
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
create_embeddings(contents)
|
||||
|
||||
|
||||
#print(json.dumps(contents, indent="\t"))
|
||||
Reference in New Issue
Block a user