lülülülü

This commit is contained in:
Jonas Braus
2024-12-11 23:01:11 +01:00
parent fde7e7570a
commit 13a87a812b
2 changed files with 2 additions and 3 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ def prompt_embedding(prompt):
)
cur = conn.cursor()
cur.execute(f"select id, doc_id, filepath, embedding <-> %s::vector as distance from dbtable order by distance limit 3;", (embedding["embedding"],))
cur.execute(f"select id, filepath, embedding <-> %s::vector as distance from dbtable order by distance limit 3;", (embedding["embedding"],))
result = cur.fetchall()
+1 -2
View File
@@ -49,7 +49,6 @@ def create_embeddings(pContent):
create_table_query = '''
create table if not exists dbtable (
id SERIAL PRIMARY KEY,
doc_id Serial NOT NULL,
filepath TEXT NOT NULL,
embedding VECTOR NOT NULL
);
@@ -67,7 +66,7 @@ def create_embeddings(pContent):
# 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['path']}', %s) Returning doc_id;"
insert_data = f"insert into dbtable (filepath, embedding) Values ('{content['path']}', %s) Returning id;"
cur.execute(insert_data, (response["embedding"],))
doc_id = cur.fetchone()[0]
insert_data_mongo(doc_id, chunk)