MCPcopy Create free account
hub / github.com/Hrishikesh332/dev-ai / insert_embeddings

Function insert_embeddings

utils.py:95–130  ·  view source on GitHub ↗
(embeddings_data, product_info)

Source from the content-addressed store, hash-verified

93
94# Insert text and all video segment embeddings
95def insert_embeddings(embeddings_data, product_info):
96 try:
97 metadata = {
98 "product_id": product_info['product_id'],
99 "title": product_info['title'],
100 "description": product_info['desc'],
101 "video_url": product_info['video_url'],
102 "link": product_info['link']
103 }
104
105 # Insert text embedding
106 text_entry = {
107 "id": int(uuid.uuid4().int & (1<<63)-1),
108 "vector": embeddings_data['text_embedding'],
109 "metadata": metadata,
110 "embedding_type": "text"
111 }
112 collection.insert([text_entry])
113 st.write("Text embedding inserted successfully")
114
115 # Insert each video segment embedding
116 for video_segment in embeddings_data['video_embeddings']:
117 video_entry = {
118 "id": int(uuid.uuid4().int & (1<<63)-1),
119 "vector": video_segment['embedding'],
120 "metadata": {**metadata, **video_segment['metadata']},
121 "embedding_type": "video"
122 }
123 collection.insert([video_entry])
124
125 st.write(f"Inserted {len(embeddings_data['video_embeddings'])} video segment embeddings")
126 return True
127
128 except Exception as e:
129 st.error(f"Error inserting embeddings: {str(e)}")
130 return False
131
132
133# Search for similar video segments using image query

Callers 1

add_product_dataFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected