waseoke commited on
Commit
de8ce12
·
verified ·
1 Parent(s): 19a8d8c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -46,11 +46,12 @@ if product_data:
46
  product_embedding = embed_product_data(product_data)
47
  print("Product Embedding:", product_embedding)
48
 
49
- # product_id 기준으로 임베딩을 MongoDB에 저장
50
- product_collection.update_one(
51
- {"product_id": "1"},
52
- {"$set": {"embedding": product_embedding.tolist()}}
 
53
  )
54
- print("Embedding saved to MongoDB based on product_id.")
55
  else:
56
  print("Product not found.")
 
46
  product_embedding = embed_product_data(product_data)
47
  print("Product Embedding:", product_embedding)
48
 
49
+ # MongoDB Atlas의 product_embeddings 컬렉션에 임베딩 저장
50
+ embedding_collection.update_one(
51
+ {"product_id": product_data["product_id"]}, # product_id 기준으로 찾기
52
+ {"$set": {"embedding": product_embedding.tolist()}}, # 벡터를 리스트 형태로 저장
53
+ upsert=True # 기존 항목이 없으면 새로 삽입
54
  )
55
+ print("Embedding saved to MongoDB Atlas based on product_id.")
56
  else:
57
  print("Product not found.")