Skip to content

Commit

Permalink
working ish
Browse files Browse the repository at this point in the history
  • Loading branch information
nicarq committed Dec 23, 2024
1 parent 3e61a6f commit aa7f38f
Show file tree
Hide file tree
Showing 31 changed files with 379 additions and 2,671 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions shinkai-libs/shinkai-embedding/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod embedding_generator;
pub mod model_type;
pub mod shinkai_embedding_errors;
pub mod mock_generator;
50 changes: 50 additions & 0 deletions shinkai-libs/shinkai-embedding/src/mock_generator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use crate::model_type::EmbeddingModelType;
use crate::shinkai_embedding_errors::ShinkaiEmbeddingError;
use async_trait::async_trait;
use crate::embedding_generator::EmbeddingGenerator;

#[derive(Clone)]
pub struct MockGenerator {
model_type: EmbeddingModelType,
num_embeddings: usize,
}

impl MockGenerator {
pub fn new(model_type: EmbeddingModelType, num_embeddings: usize) -> Self {
MockGenerator {
model_type,
num_embeddings,
}
}
}

#[async_trait]
impl EmbeddingGenerator for MockGenerator {
fn model_type(&self) -> EmbeddingModelType {
self.model_type.clone()
}

fn set_model_type(&mut self, model_type: EmbeddingModelType) {
self.model_type = model_type;
}

fn box_clone(&self) -> Box<dyn EmbeddingGenerator> {
Box::new((*self).clone())
}

fn generate_embedding_blocking(&self, _input_string: &str) -> Result<Vec<f32>, ShinkaiEmbeddingError> {
Ok(vec![0.0; self.num_embeddings])
}

fn generate_embeddings_blocking(&self, input_strings: &Vec<String>) -> Result<Vec<Vec<f32>>, ShinkaiEmbeddingError> {
Ok(input_strings.iter().map(|_| vec![0.0; self.num_embeddings]).collect())
}

async fn generate_embedding(&self, _input_string: &str) -> Result<Vec<f32>, ShinkaiEmbeddingError> {
Ok(vec![0.0; self.num_embeddings])
}

async fn generate_embeddings(&self, input_strings: &Vec<String>) -> Result<Vec<Vec<f32>>, ShinkaiEmbeddingError> {
Ok(input_strings.iter().map(|_| vec![0.0; self.num_embeddings]).collect())
}
}
2 changes: 1 addition & 1 deletion shinkai-libs/shinkai-fs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bincode = { workspace = true }
serde_json = { workspace = true }
rand = { workspace = true }
blake3 = { workspace = true }
# tokio = { workspace = true, features = ["full"] }
tokio = { workspace = true, features = ["full"] }
chrono = { workspace = true }
comrak = { version = "0.22.0", default-features = true }
thiserror = "2.0.3"
Expand Down
280 changes: 0 additions & 280 deletions shinkai-libs/shinkai-fs/src/file_parser/file_parser.rs

This file was deleted.

Loading

0 comments on commit aa7f38f

Please sign in to comment.