Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
50 |
-
|
51 |
-
{"product_id": "
|
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.")
|