mirror of
https://github.com/perstarkse/minne.git
synced 2026-04-23 09:18:36 +02:00
feat: arc client
This commit is contained in:
@@ -27,7 +27,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
let config = get_config()?;
|
let config = get_config()?;
|
||||||
|
|
||||||
let job_queue = JobQueue::new(Arc::new(
|
let surreal_db_client = Arc::new(
|
||||||
SurrealDbClient::new(
|
SurrealDbClient::new(
|
||||||
&config.surrealdb_address,
|
&config.surrealdb_address,
|
||||||
&config.surrealdb_username,
|
&config.surrealdb_username,
|
||||||
@@ -36,9 +36,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
&config.surrealdb_database,
|
&config.surrealdb_database,
|
||||||
)
|
)
|
||||||
.await?,
|
.await?,
|
||||||
));
|
);
|
||||||
|
|
||||||
let content_processor = ContentProcessor::new(&config).await?;
|
let job_queue = JobQueue::new(surreal_db_client.clone());
|
||||||
|
|
||||||
|
let content_processor = ContentProcessor::new(surreal_db_client).await?;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// First, check for any unfinished jobs
|
// First, check for any unfinished jobs
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use std::time::Instant;
|
use std::{sync::Arc, time::Instant};
|
||||||
|
|
||||||
use text_splitter::TextSplitter;
|
use text_splitter::TextSplitter;
|
||||||
use tracing::{debug, info};
|
use tracing::{debug, info};
|
||||||
@@ -12,7 +12,7 @@ use crate::{
|
|||||||
text_chunk::TextChunk, text_content::TextContent,
|
text_chunk::TextChunk, text_content::TextContent,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
utils::{config::AppConfig, embedding::generate_embedding},
|
utils::embedding::generate_embedding,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::analysis::{
|
use super::analysis::{
|
||||||
@@ -20,21 +20,14 @@ use super::analysis::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub struct ContentProcessor {
|
pub struct ContentProcessor {
|
||||||
db_client: SurrealDbClient,
|
db_client: Arc<SurrealDbClient>,
|
||||||
openai_client: async_openai::Client<async_openai::config::OpenAIConfig>,
|
openai_client: async_openai::Client<async_openai::config::OpenAIConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContentProcessor {
|
impl ContentProcessor {
|
||||||
pub async fn new(app_config: &AppConfig) -> Result<Self, AppError> {
|
pub async fn new(surreal_db_client: Arc<SurrealDbClient>) -> Result<Self, AppError> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
db_client: SurrealDbClient::new(
|
db_client: surreal_db_client,
|
||||||
&app_config.surrealdb_address,
|
|
||||||
&app_config.surrealdb_username,
|
|
||||||
&app_config.surrealdb_password,
|
|
||||||
&app_config.surrealdb_namespace,
|
|
||||||
&app_config.surrealdb_database,
|
|
||||||
)
|
|
||||||
.await?,
|
|
||||||
openai_client: async_openai::Client::new(),
|
openai_client: async_openai::Client::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user