respect model specified in config

This commit is contained in:
b1ek 2024-04-14 15:46:56 +10:00
parent 69e19c3b87
commit 741a71fb3b
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 12 additions and 5 deletions

View File

@ -11,6 +11,15 @@ pub enum Model {
GPT35,
}
impl ToString for Model {
fn to_string(&self) -> String {
match self {
Self::Claude12 => String::from("claude-instant-1.2"),
Self::GPT35 => String::from("gpt-3.5-turbo-0125"),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Config {
pub model: Model,

View File

@ -96,15 +96,13 @@ async fn get_vqd(cli: &Client) -> Result<String, Box<dyn Error>> {
}
}
async fn get_res<'a>(cli: &Client, query: String, vqd: String, cache: &'a mut Cache) {
async fn get_res<'a>(cli: &Client, query: String, vqd: String, cache: &'a mut Cache, config: &Config) {
let payload = ChatPayload {
model: "claude-instant-1.2".into(),
model: config.model.to_string(),
messages: vec![ ChatMessagePayload { role: "user".into(), content: query } ]
};
let payload = serde_json::to_string(&payload).unwrap();
// println!("{payload}\n\n{:#?}", headers);return;
let req = cli.post("https://duckduckgo.com/duckchat/v1/chat")
// .headers(get_headers())
.header("Content-Type", "application/json")
@ -197,6 +195,6 @@ async fn main() {
None => get_vqd(&cli).await.unwrap()
};
get_res(&cli, query, vqd, &mut cache).await;
get_res(&cli, query, vqd, &mut cache, &config).await;
}