diff options
| author | sigoden <sigoden@gmail.com> | 2024-06-06 05:27:21 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-06 05:27:21 +0800 |
| commit | c26594c3c85fb99ad5b0db1c535b337585d3c103 (patch) | |
| tree | 1829b2b1eee599fd835f2eb6f4751097c145b802 /src/config/input.rs | |
| parent | 171a46eee2afcb92bcbbd6a11b52ebc82f2476db (diff) | |
| download | aichat-c26594c3c85fb99ad5b0db1c535b337585d3c103.tar.gz | |
refactor: config refinement (#570)
Diffstat (limited to 'src/config/input.rs')
| -rw-r--r-- | src/config/input.rs | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/config/input.rs b/src/config/input.rs index 0406a5e..4d0ed7f 100644 --- a/src/config/input.rs +++ b/src/config/input.rs @@ -1,7 +1,7 @@ use super::{role::Role, session::Session, GlobalConfig}; use crate::client::{ - init_client, list_chat_models, ChatCompletionsData, Client, ImageUrl, Message, MessageContent, + init_client, ChatCompletionsData, Client, ImageUrl, Message, MessageContent, MessageContentPart, MessageRole, Model, }; use crate::function::{ToolCallResult, ToolResults}; @@ -165,18 +165,15 @@ impl Input { } pub fn model(&self) -> Model { - let model = self.config.read().model.clone(); - if let Some(model_id) = self.role().and_then(|v| v.model_id.clone()) { - if model.id() != model_id { - if let Some(model) = list_chat_models(&self.config.read()) - .into_iter() - .find(|v| v.id() == model_id) - { - return model.clone(); - } - } - }; - model + if let Some(session) = self.session(&self.config.read().session) { + return session.model.clone(); + } else if let Some(model) = self + .role() + .and_then(|v| v.retrieve_model(&self.config.read())) + { + return model; + } + self.config.read().model.clone() } pub fn create_client(&self) -> Result<Box<dyn Client>> { |
