kenken999 commited on
Commit
93f3952
1 Parent(s): a1e6264

insert vector

Browse files
Files changed (1) hide show
  1. babyagi/classesa/diamond.py +12 -8
babyagi/classesa/diamond.py CHANGED
@@ -52,6 +52,7 @@ class ProductDatabase:
52
  cursor.execute("""
53
  SELECT id,'carat', 'cut', 'color', 'clarity', 'depth', 'diamondprice.table', 'x', 'y', 'z'
54
  FROM diamondprice
 
55
  """, (query_vector, top_k))
56
  results = cursor.fetchall()
57
  return results
@@ -74,19 +75,22 @@ def main():
74
  results = db.search_similar_all(query_text)
75
  print("Search results:")
76
  for result in results:
77
- print(result)
78
- return
 
 
 
79
  # サンプルデータの挿入
80
- sample_text = """"""
81
- sample_product_id = 1 # 実際の製品IDを使用
82
- db.insert_vector(sample_product_id, sample_text)
83
- db.insert_vector(2, sample_text)
84
 
85
- print(f"Vector inserted for product ID {sample_product_id}.")
86
 
87
 
88
  # ベクトル検索
89
- query_text = "今お話した内容と同様で"
90
  results = db.search_similar_vectors(query_text)
91
  print("Search results:")
92
  for result in results:
 
52
  cursor.execute("""
53
  SELECT id,'carat', 'cut', 'color', 'clarity', 'depth', 'diamondprice.table', 'x', 'y', 'z'
54
  FROM diamondprice
55
+ where id = 1
56
  """, (query_vector, top_k))
57
  results = cursor.fetchall()
58
  return results
 
75
  results = db.search_similar_all(query_text)
76
  print("Search results:")
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(sample_product_id, sample_text)
82
+ #return
83
  # サンプルデータの挿入
84
+ #sample_text = """"""
85
+ #sample_product_id = 1 # 実際の製品IDを使用
86
+ #db.insert_vector(sample_product_id, sample_text)
87
+ #db.insert_vector(2, sample_text)
88
 
89
+ #print(f"Vector inserted for product ID {sample_product_id}.")
90
 
91
 
92
  # ベクトル検索
93
+ query_text = "12.03"
94
  results = db.search_similar_vectors(query_text)
95
  print("Search results:")
96
  for result in results: