diff --git a/common/src/storage/types/knowledge_entity.rs b/common/src/storage/types/knowledge_entity.rs index cd7f6fa..00f855d 100644 --- a/common/src/storage/types/knowledge_entity.rs +++ b/common/src/storage/types/knowledge_entity.rs @@ -275,10 +275,9 @@ impl KnowledgeEntity { db_client: &SurrealDbClient, ai_client: &Client, ) -> Result<(), AppError> { - let embedding_input = format!( - "name: {}, description: {}, type: {:?}", - name, description, entity_type - ); + let embedding_input = format!( + "name: {name}, description: {description}, type: {entity_type:?}", + ); let embedding = generate_embedding(ai_client, &embedding_input, db_client).await?; let user_id = Self::get_user_id_by_id(id, db_client).await?; let emb = KnowledgeEntityEmbedding::new(id, embedding, user_id); @@ -398,7 +397,7 @@ impl KnowledgeEntity { // Add all update statements to the embedding table for (id, (embedding, user_id)) in new_embeddings { - let embedding_str = serde_json::to_string(&embedding) + let embedding = serde_json::to_string(&embedding) .map_err(|e| AppError::InternalError(format!("embedding serialization failed: {e}")))?; write!( transaction_query, @@ -408,9 +407,6 @@ impl KnowledgeEntity { user_id = '{user_id}', \ created_at = IF created_at != NONE THEN created_at ELSE time::now() END, \ updated_at = time::now();", - id = id, - embedding = embedding_str, - user_id = user_id, ) .map_err(|e| AppError::InternalError(e.to_string()))?; } @@ -521,7 +517,7 @@ impl KnowledgeEntity { let mut transaction_query = String::from("BEGIN TRANSACTION;"); for (id, (embedding, user_id)) in new_embeddings { - let embedding_str = serde_json::to_string(&embedding) + let embedding = serde_json::to_string(&embedding) .map_err(|e| AppError::InternalError(format!("embedding serialization failed: {e}")))?; write!( transaction_query, @@ -531,9 +527,6 @@ impl KnowledgeEntity { user_id = '{user_id}', \ created_at = time::now(), \ updated_at = time::now();", - id = id, - embedding = embedding_str, - user_id = user_id, ) .map_err(|e| AppError::InternalError(e.to_string()))?; } diff --git a/common/src/storage/types/text_chunk.rs b/common/src/storage/types/text_chunk.rs index 0e60d5d..a35ad09 100644 --- a/common/src/storage/types/text_chunk.rs +++ b/common/src/storage/types/text_chunk.rs @@ -291,7 +291,7 @@ impl TextChunk { let mut transaction_query = String::from("BEGIN TRANSACTION;"); for (id, (embedding, user_id, source_id)) in new_embeddings { - let embedding_str = serde_json::to_string(&embedding) + let embedding = serde_json::to_string(&embedding) .map_err(|e| AppError::InternalError(format!("embedding serialization failed: {e}")))?; write!( &mut transaction_query, @@ -302,10 +302,6 @@ impl TextChunk { user_id = '{user_id}', \ created_at = IF created_at != NONE THEN created_at ELSE time::now() END, \ updated_at = time::now();", - id = id, - embedding = embedding_str, - source_id = source_id, - user_id = user_id, ) .map_err(|e| AppError::InternalError(e.to_string()))?; } @@ -406,7 +402,7 @@ impl TextChunk { let mut transaction_query = String::from("BEGIN TRANSACTION;"); for (id, (embedding, user_id, source_id)) in new_embeddings { - let embedding_str = serde_json::to_string(&embedding) + let embedding = serde_json::to_string(&embedding) .map_err(|e| AppError::InternalError(format!("embedding serialization failed: {e}")))?; write!( &mut transaction_query, @@ -417,10 +413,6 @@ impl TextChunk { user_id = '{user_id}', \ created_at = time::now(), \ updated_at = time::now();", - id = id, - embedding = embedding_str, - source_id = source_id, - user_id = user_id, ) .map_err(|e| AppError::InternalError(e.to_string()))?; }