mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Remove prompt strategy and fallback
This commit is contained in:
parent
806e5b6899
commit
b8e4709dfa
3 changed files with 21 additions and 86 deletions
|
@ -1,7 +1,7 @@
|
|||
use deserr::Deserr;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::prompt::{PromptData, PromptFallbackStrategy};
|
||||
use crate::prompt::PromptData;
|
||||
use crate::update::Setting;
|
||||
use crate::vector::hf::WeightSource;
|
||||
use crate::vector::EmbeddingConfig;
|
||||
|
@ -56,46 +56,28 @@ pub struct PromptSettings {
|
|||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||
#[deserr(default)]
|
||||
pub template: Setting<String>,
|
||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||
#[deserr(default)]
|
||||
pub strategy: Setting<PromptFallbackStrategy>,
|
||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||
#[deserr(default)]
|
||||
pub fallback: Setting<String>,
|
||||
}
|
||||
|
||||
impl PromptSettings {
|
||||
pub fn apply(&mut self, new: Self) {
|
||||
let PromptSettings { template, strategy, fallback } = new;
|
||||
let PromptSettings { template } = new;
|
||||
self.template.apply(template);
|
||||
self.strategy.apply(strategy);
|
||||
self.fallback.apply(fallback);
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PromptData> for PromptSettings {
|
||||
fn from(value: PromptData) -> Self {
|
||||
Self {
|
||||
template: Setting::Set(value.template),
|
||||
strategy: Setting::Set(value.strategy),
|
||||
fallback: Setting::Set(value.fallback),
|
||||
}
|
||||
Self { template: Setting::Set(value.template) }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PromptSettings> for PromptData {
|
||||
fn from(value: PromptSettings) -> Self {
|
||||
let mut this = PromptData::default();
|
||||
let PromptSettings { template, strategy, fallback } = value;
|
||||
let PromptSettings { template } = value;
|
||||
if let Some(template) = template.set() {
|
||||
this.template = template;
|
||||
}
|
||||
if let Some(strategy) = strategy.set() {
|
||||
this.strategy = strategy;
|
||||
}
|
||||
if let Some(fallback) = fallback.set() {
|
||||
this.fallback = fallback;
|
||||
}
|
||||
this
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue