pub struct EmbeddingsFactory { /* private fields */ }Expand description
嵌入模型工厂
Implementations§
Source§impl EmbeddingsFactory
impl EmbeddingsFactory
pub fn new() -> Self
pub fn with_cache(cache: Arc<EmbeddingCache>) -> Self
Sourcepub fn create(
&self,
config: EmbeddingsConfig,
) -> Result<Box<dyn EmbeddingModel>>
pub fn create( &self, config: EmbeddingsConfig, ) -> Result<Box<dyn EmbeddingModel>>
创建嵌入模型实例
Sourcepub fn create_safe(&self, config: EmbeddingsConfig) -> Box<dyn EmbeddingModel>
pub fn create_safe(&self, config: EmbeddingsConfig) -> Box<dyn EmbeddingModel>
创建安全的嵌入模型实例
如果指定的配置无效,自动回退到 Mock 模型。 这确保了即使在未配置环境下也能安全返回一个可用实例。
Sourcepub fn openai(&self) -> Result<Box<dyn EmbeddingModel>>
pub fn openai(&self) -> Result<Box<dyn EmbeddingModel>>
创建 OpenAI 嵌入模型
Sourcepub fn huggingface(&self) -> Result<Box<dyn EmbeddingModel>>
pub fn huggingface(&self) -> Result<Box<dyn EmbeddingModel>>
创建 HuggingFace 嵌入模型
Sourcepub fn cohere(&self) -> Result<Box<dyn EmbeddingModel>>
pub fn cohere(&self) -> Result<Box<dyn EmbeddingModel>>
创建 Cohere 嵌入模型
Sourcepub fn local(
&self,
model: &str,
dimension: Option<usize>,
) -> Result<Box<dyn EmbeddingModel>>
pub fn local( &self, model: &str, dimension: Option<usize>, ) -> Result<Box<dyn EmbeddingModel>>
创建本地嵌入模型
Sourcepub fn cache(&self) -> Arc<EmbeddingCache>
pub fn cache(&self) -> Arc<EmbeddingCache>
获取缓存实例
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for EmbeddingsFactory
impl !UnwindSafe for EmbeddingsFactory
impl Freeze for EmbeddingsFactory
impl Send for EmbeddingsFactory
impl Sync for EmbeddingsFactory
impl Unpin for EmbeddingsFactory
impl UnsafeUnpin for EmbeddingsFactory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more