-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
379 additions
and
2,671 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.