This commit is contained in:
Jonas Braus
2024-12-12 01:21:44 +01:00
parent 30856efe6e
commit 1845cb7ac8
2 changed files with 12 additions and 3 deletions
+11 -2
View File
@@ -59,11 +59,20 @@ def prompt_embedding(prompt):
)
cur = conn.cursor()
cur.execute(f"select 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 20;", (embedding["embedding"],))
result = cur.fetchall()
res = get_data_from_mongo(result)
initial_distance = result[0][2]
new_result = []
for res in result:
current_distance = res[2]
if abs(current_distance - initial_distance) < 1:
new_result.append(res)
res = get_data_from_mongo(new_result)
print(ollama_conn.ask_ollama(prompt, res))