Spaces:
Running
on
Zero
Running
on
Zero
diamond
Browse files
babyagi/classesa/diamond.py
CHANGED
@@ -38,9 +38,10 @@ class ProductDatabase:
|
|
38 |
query_vector = self.get_embedding(query_text).tolist() # ndarray をリストに変換
|
39 |
with self.conn.cursor() as cursor:
|
40 |
cursor.execute("""
|
41 |
-
SELECT id, vector_col <=> %s::vector AS distance
|
42 |
FROM diamondprice
|
43 |
-
|
|
|
44 |
LIMIT %s;
|
45 |
""", (query_vector, top_k))
|
46 |
results = cursor.fetchall()
|
@@ -77,8 +78,8 @@ def main():
|
|
77 |
for result in results:
|
78 |
print(result)
|
79 |
id = result[0]
|
80 |
-
sample_text = str(result[1])+str(result[2])+str(result[3])+str(result[4])+str(result[5])+str(result[6])
|
81 |
-
db.insert_vector(
|
82 |
#return
|
83 |
# サンプルデータの挿入
|
84 |
#sample_text = """"""
|
@@ -90,7 +91,8 @@ def main():
|
|
90 |
|
91 |
|
92 |
# ベクトル検索
|
93 |
-
query_text = "12.
|
|
|
94 |
results = db.search_similar_vectors(query_text)
|
95 |
print("Search results:")
|
96 |
for result in results:
|
|
|
38 |
query_vector = self.get_embedding(query_text).tolist() # ndarray をリストに変換
|
39 |
with self.conn.cursor() as cursor:
|
40 |
cursor.execute("""
|
41 |
+
SELECT id,carat, cut, color, clarity, depth, diamondprice.table, x, y, z, vector_col <=> %s::vector AS distance
|
42 |
FROM diamondprice
|
43 |
+
WHERE vector_col IS NOT NULL
|
44 |
+
ORDER BY distance desc
|
45 |
LIMIT %s;
|
46 |
""", (query_vector, top_k))
|
47 |
results = cursor.fetchall()
|
|
|
78 |
for result in results:
|
79 |
print(result)
|
80 |
id = result[0]
|
81 |
+
sample_text = str(result[0])+str(result[1])+str(result[2])+str(result[3])+str(result[4])+str(result[5])+str(result[6])+str(result[7])+str(result[8])
|
82 |
+
db.insert_vector(id, sample_text)
|
83 |
#return
|
84 |
# サンプルデータの挿入
|
85 |
#sample_text = """"""
|
|
|
91 |
|
92 |
|
93 |
# ベクトル検索
|
94 |
+
query_text = "12.03Very GoodJSI262.0587.27"
|
95 |
+
query_text = "12.03Very GoodJSI2"
|
96 |
results = db.search_similar_vectors(query_text)
|
97 |
print("Search results:")
|
98 |
for result in results:
|