mirror of
https://github.com/perstarkse/minne.git
synced 2026-06-21 14:09:33 +02:00
chore: harden system settings and unify prompt usage
Validate settings updates, use typed embedding backends, and route ingestion through DB-stored prompts so admin edits take effect.
This commit is contained in:
@@ -8,6 +8,7 @@ use std::{
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use async_openai::{types::CreateEmbeddingRequestArgs, Client};
|
||||
use fastembed::{EmbeddingModel, ModelTrait, TextEmbedding, TextInitOptions};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
use tracing::debug;
|
||||
|
||||
@@ -26,7 +27,8 @@ pub struct ParseEmbeddingBackendError {
|
||||
|
||||
/// Supported embedding backends.
|
||||
#[allow(clippy::module_name_repetitions)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum EmbeddingBackend {
|
||||
#[default]
|
||||
OpenAI,
|
||||
@@ -34,6 +36,17 @@ pub enum EmbeddingBackend {
|
||||
Hashed,
|
||||
}
|
||||
|
||||
impl EmbeddingBackend {
|
||||
#[must_use]
|
||||
pub fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
Self::OpenAI => "openai",
|
||||
Self::FastEmbed => "fastembed",
|
||||
Self::Hashed => "hashed",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for EmbeddingBackend {
|
||||
type Err = ParseEmbeddingBackendError;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user