Skip to content

Commit 00bfd4f

Browse files
committed
Remove comments
1 parent 061585f commit 00bfd4f

File tree

2 files changed

+26
-40
lines changed

2 files changed

+26
-40
lines changed

vector-db-proxy/src/data/processing_incoming_messages.rs

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ pub async fn embed_text_construct_point(
3333
// Convert embedding_field_name to lowercase
3434
let mut payload: HashMap<String, Value> = data.clone();
3535
if let Some(value) = payload.remove(embedding_field_name) {
36-
// Always store the text content in page_content
3736
payload.insert(
3837
"page_content".to_string(),
3938
Value::String(clean_text(value.to_string())),

vector-db-proxy/src/embeddings/utils.rs

+26-39
Original file line numberDiff line numberDiff line change
@@ -220,23 +220,25 @@ pub async fn embed_bulk_insert_unstructured_response(
220220
let datasource_id = datasource.id.to_string();
221221
match embed_text_chunks_async(list_of_text.clone(), &embedding_model).await {
222222
Ok(embeddings) => {
223-
let mut search_request =
224-
SearchRequest::new(search_type.clone(), datasource.collection_name.clone().unwrap_or(datasource_id.clone()));
223+
let mut search_request = SearchRequest::new(
224+
search_type.clone(),
225+
datasource
226+
.collection_name
227+
.clone()
228+
.unwrap_or(datasource_id.clone()),
229+
);
225230
search_request.byo_vector_db = Some(true);
226231
search_request.namespace = datasource.namespace.clone();
227232
let mut points_to_upload: Vec<Point> = vec![];
228233

229-
// Construct points to upload
230234
for (i, document) in documents.iter().enumerate() {
231235
let mut point_metadata: HashMap<String, Value> = HashMap::new();
232236

233-
// Always store the text content in page_content
234237
point_metadata.insert(
235238
"page_content".to_string(),
236239
Value::String(clean_text(document.text.clone())),
237240
);
238241

239-
// Add metadata from the original document
240242
if let Ok(Value::Object(map)) = serde_json::to_value(document.metadata.clone()) {
241243
for (key, value) in map {
242244
point_metadata.insert(key, value);
@@ -251,67 +253,52 @@ pub async fn embed_bulk_insert_unstructured_response(
251253
let embedding_vector = embeddings.get(i);
252254
if let Some(vector) = embedding_vector {
253255
let point = Point::new(
254-
point_metadata
255-
.get("index")
256-
.map_or_else(
257-
|| Some(Value::String(Uuid::new_v4().to_string())),
258-
|id| match id {
259-
Value::String(s) => Some(Value::String(s.clone())),
260-
_ => Some(Value::String(id.to_string().trim_matches('"').to_string()))
261-
}
262-
),
256+
point_metadata.get("index").map_or_else(
257+
|| Some(Value::String(Uuid::new_v4().to_string())),
258+
|id| match id {
259+
Value::String(s) => Some(Value::String(s.clone())),
260+
_ => Some(Value::String(
261+
id.to_string().trim_matches('"').to_string(),
262+
)),
263+
},
264+
),
263265
vector.to_vec(),
264266
Some(point_metadata),
265267
);
266268
points_to_upload.push(point)
267269
}
268270
}
269271

270-
// Only create one vector database client for all points
271272
let vector_database_client =
272273
check_byo_vector_database(datasource.clone(), &mongo_connection)
273274
.await
274275
.unwrap_or(default_vector_db_client().await);
275276

276-
// Initialize vector database client
277277
let vector_database = Arc::clone(&vector_database_client);
278278
let vector_database_client = vector_database.read().await;
279279

280-
// Bulk insert all points at once
281280
if let Ok(bulk_insert_status) = vector_database_client
282281
.bulk_insert_points(search_request.clone(), points_to_upload)
283282
.await
284283
{
285284
match bulk_insert_status {
286285
VectorDatabaseStatus::Ok => {
287286
log::debug!("points uploaded successfully!");
288-
// Increment success count
289-
increment_by_one(
290-
&mongo_connection,
291-
&datasource_id,
292-
"recordCount.success",
293-
)
294-
.await
295-
.unwrap();
287+
288+
increment_by_one(&mongo_connection, &datasource_id, "recordCount.success")
289+
.await
290+
.unwrap();
296291
}
297292
VectorDatabaseStatus::Failure | VectorDatabaseStatus::NotFound => {
298-
increment_by_one(
299-
&mongo_connection,
300-
&datasource_id,
301-
"recordCount.failure",
302-
)
303-
.await
304-
.unwrap();
293+
increment_by_one(&mongo_connection, &datasource_id, "recordCount.failure")
294+
.await
295+
.unwrap();
305296
log::warn!("Could not find collection :{}", datasource_id);
306297
}
307298
VectorDatabaseStatus::Error(e) => {
308-
increment_by_one(
309-
&mongo_connection,
310-
&datasource_id,
311-
"recordCount.failure",
312-
)
313-
.await
314-
.unwrap();
299+
increment_by_one(&mongo_connection, &datasource_id, "recordCount.failure")
300+
.await
301+
.unwrap();
315302
log::error!(
316303
"An error occurred while attempting point insert operation. Error: {:?}",
317304
e

0 commit comments

Comments
 (0)