summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-06-25 07:50:19 +0800
committerGitHub <noreply@github.com>2024-06-25 07:50:19 +0800
commit2bc9607b00fa5f31ced08f78fe08fe71b923b152 (patch)
treea641079ed22de950e4c8f6e49ee6fcb713d5421e /src
parent2fbb5271af27eee7ba3ae6d2b3c1aa0818648c8f (diff)
downloadaichat-2bc9607b00fa5f31ced08f78fe08fe71b923b152.tar.gz
refactor: rename model type `rerank` to `reranker` (#646)
Diffstat (limited to 'src')
-rw-r--r--src/client/common.rs4
-rw-r--r--src/client/model.rs8
-rw-r--r--src/config/input.rs6
-rw-r--r--src/config/mod.rs18
4 files changed, 18 insertions, 18 deletions
diff --git a/src/client/common.rs b/src/client/common.rs
index bf2f336..265ab0a 100644
--- a/src/client/common.rs
+++ b/src/client/common.rs
@@ -154,8 +154,8 @@ macro_rules! register_client {
list_models(config).into_iter().filter(|v| v.model_type() == "embedding").collect()
}
- pub fn list_rerank_models(config: &$crate::config::Config) -> Vec<&'static $crate::client::Model> {
- list_models(config).into_iter().filter(|v| v.model_type() == "rerank").collect()
+ pub fn list_reranker_models(config: &$crate::config::Config) -> Vec<&'static $crate::client::Model> {
+ list_models(config).into_iter().filter(|v| v.model_type() == "reranker").collect()
}
};
}
diff --git a/src/client/model.rs b/src/client/model.rs
index d661d85..e6142d4 100644
--- a/src/client/model.rs
+++ b/src/client/model.rs
@@ -1,5 +1,5 @@
use super::{
- list_chat_models, list_embedding_models, list_rerank_models,
+ list_chat_models, list_embedding_models, list_reranker_models,
message::{Message, MessageContent},
EmbeddingsData,
};
@@ -57,10 +57,10 @@ impl Model {
}
}
- pub fn retrieve_rerank(config: &Config, model_id: &str) -> Result<Self> {
- match Self::find(&list_rerank_models(config), model_id) {
+ pub fn retrieve_reranker(config: &Config, model_id: &str) -> Result<Self> {
+ match Self::find(&list_reranker_models(config), model_id) {
Some(v) => Ok(v),
- None => bail!("Invalid rerank model '{model_id}'"),
+ None => bail!("Invalid reranker model '{model_id}'"),
}
}
diff --git a/src/config/input.rs b/src/config/input.rs
index 3a258b9..09dfa8f 100644
--- a/src/config/input.rs
+++ b/src/config/input.rs
@@ -177,11 +177,11 @@ impl Input {
config.rag_min_score_keyword_search,
)
};
- let rerank = match self.config.read().rag_rerank_model.clone() {
- Some(rerank_model_id) => {
+ let rerank = match self.config.read().rag_reranker_model.clone() {
+ Some(reranker_model_id) => {
let min_score = self.config.read().rag_min_score_rerank;
let rerank_model =
- Model::retrieve_rerank(&self.config.read(), &rerank_model_id)?;
+ Model::retrieve_reranker(&self.config.read(), &reranker_model_id)?;
let rerank_client = init_client(&self.config, Some(rerank_model))?;
Some((rerank_client, min_score))
}
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 8b0f995..62ed28e 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -9,7 +9,7 @@ pub use self::role::{Role, RoleLike, CODE_ROLE, EXPLAIN_SHELL_ROLE, SHELL_ROLE};
use self::session::Session;
use crate::client::{
- create_client_config, list_chat_models, list_client_types, list_rerank_models, ClientConfig,
+ create_client_config, list_chat_models, list_client_types, list_reranker_models, ClientConfig,
Model, OPENAI_COMPATIBLE_PLATFORMS,
};
use crate::function::{FunctionDeclaration, Functions, FunctionsFilter, ToolResult};
@@ -108,7 +108,7 @@ pub struct Config {
pub agents: Vec<AgentConfig>,
pub rag_embedding_model: Option<String>,
- pub rag_rerank_model: Option<String>,
+ pub rag_reranker_model: Option<String>,
pub rag_top_k: usize,
pub rag_chunk_size: Option<usize>,
pub rag_chunk_overlap: Option<usize>,
@@ -167,7 +167,7 @@ impl Default for Config {
agents: vec![],
rag_embedding_model: None,
- rag_rerank_model: None,
+ rag_reranker_model: None,
rag_top_k: 4,
rag_chunk_size: None,
rag_chunk_overlap: None,
@@ -478,8 +478,8 @@ impl Config {
("compress_threshold", self.compress_threshold.to_string()),
("function_calling", self.function_calling.to_string()),
(
- "rag_rerank_model",
- format_option_value(&self.rag_rerank_model),
+ "rag_reranker_model",
+ format_option_value(&self.rag_reranker_model),
),
("rag_top_k", self.rag_top_k.to_string()),
("highlight", self.highlight.to_string()),
@@ -527,8 +527,8 @@ impl Config {
let value = parse_value(value)?;
self.set_top_p(value);
}
- "rag_rerank_model" => {
- self.rag_rerank_model = if value == "null" {
+ "rag_reranker_model" => {
+ self.rag_reranker_model = if value == "null" {
None
} else {
Some(value.to_string())
@@ -1096,7 +1096,7 @@ impl Config {
"max_output_tokens",
"temperature",
"top_p",
- "rag_rerank_model",
+ "rag_reranker_model",
"rag_top_k",
"function_calling",
"compress_threshold",
@@ -1117,7 +1117,7 @@ impl Config {
Some(v) => vec![v.to_string()],
None => vec![],
},
- "rag_rerank_model" => list_rerank_models(self).iter().map(|v| v.id()).collect(),
+ "rag_reranker_model" => list_reranker_models(self).iter().map(|v| v.id()).collect(),
"function_calling" => complete_bool(self.function_calling),
"save" => complete_bool(self.save),
"save_session" => {