mirror of
https://github.com/perstarkse/minne.git
synced 2026-04-27 11:17:03 +02:00
refactoring: continuing to break stuff out
This commit is contained in:
@@ -17,6 +17,8 @@ use surrealdb::Surreal;
|
||||
use tracing::{debug, info};
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::embedding::generate_embedding;
|
||||
|
||||
/// Represents a single knowledge entity from the LLM.
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct LLMKnowledgeEntity {
|
||||
@@ -42,29 +44,6 @@ pub struct LLMGraphAnalysisResult {
|
||||
pub relationships: Vec<LLMRelationship>,
|
||||
}
|
||||
|
||||
pub async fn generate_embedding(
|
||||
client: &async_openai::Client<async_openai::config::OpenAIConfig>,
|
||||
input: String,
|
||||
) -> Result<Vec<f32>, ProcessingError> {
|
||||
let request = CreateEmbeddingRequestArgs::default()
|
||||
.model("text-embedding-3-small")
|
||||
.input(&[input])
|
||||
.build()?;
|
||||
|
||||
// Send the request to OpenAI
|
||||
let response = client.embeddings().create(request).await?;
|
||||
|
||||
// Extract the embedding vector
|
||||
let embedding: Vec<f32> = response
|
||||
.data
|
||||
.first()
|
||||
.ok_or_else(|| ProcessingError::EmbeddingError("No embedding data received".into()))?
|
||||
.embedding
|
||||
.clone();
|
||||
|
||||
Ok(embedding)
|
||||
}
|
||||
|
||||
impl LLMGraphAnalysisResult {
|
||||
/// Converts the LLM graph analysis result into database entities and relationships.
|
||||
/// Processes embeddings sequentially for simplicity.
|
||||
|
||||
Reference in New Issue
Block a user