Compare commits
No commits in common. "3626d07d833a4ee78a7246aff916dff827de3de5" and "2e8781f9416f4f33b59be3bca8c304ac162e0dc3" have entirely different histories.
3626d07d83
...
2e8781f941
|
@ -5,20 +5,17 @@ use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub enum Model {
|
pub enum Model {
|
||||||
|
#[serde(rename = "claude-instant-1.2")]
|
||||||
Claude12,
|
Claude12,
|
||||||
|
#[serde(rename = "gpt-3.5-turbo-0125")]
|
||||||
GPT35,
|
GPT35,
|
||||||
Claude,
|
|
||||||
GPT3,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for Model {
|
impl ToString for Model {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
Self::Claude12 => panic!("Your config is outdated! Please delete your ~/.config/hey directory"),
|
Self::Claude12 => String::from("claude-instant-1.2"),
|
||||||
Self::GPT35 => panic!("Your config is outdated! Please delete your ~/.config/hey directory"),
|
Self::GPT35 => String::from("gpt-3.5-turbo-0125"),
|
||||||
|
|
||||||
Self::Claude => String::from("claude-3-haiku-20240307"),
|
|
||||||
Self::GPT3 => String::from("gpt-3.5-turbo-0125"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +29,7 @@ pub struct Config {
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
model: Model::Claude,
|
model: Model::Claude12,
|
||||||
tos: false
|
tos: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,10 +76,7 @@ impl Config {
|
||||||
if ! file_path.is_file() {
|
if ! file_path.is_file() {
|
||||||
Ok(Self::default())
|
Ok(Self::default())
|
||||||
} else {
|
} else {
|
||||||
let conf: Config = toml::from_str(&fs::read_to_string(file_path)?)?;
|
Ok(toml::from_str(&fs::read_to_string(file_path)?)?)
|
||||||
conf.model.to_string(); // so that it would panic if the config is outdated
|
|
||||||
|
|
||||||
Ok(conf)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,7 +34,9 @@ struct ChatChunk {
|
||||||
pub role: String,
|
pub role: String,
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub created: u64,
|
pub created: u64,
|
||||||
|
pub id: String,
|
||||||
pub action: String,
|
pub action: String,
|
||||||
|
pub model: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
@ -48,7 +50,7 @@ struct ErrChatChunk {
|
||||||
fn get_headers() -> HeaderMap {
|
fn get_headers() -> HeaderMap {
|
||||||
let mut map = HeaderMap::new();
|
let mut map = HeaderMap::new();
|
||||||
map.insert("Host", HeaderValue::from_static("duckduckgo.com"));
|
map.insert("Host", HeaderValue::from_static("duckduckgo.com"));
|
||||||
map.insert("Accept", HeaderValue::from_static("text/event-stream"));
|
map.insert("Accept", HeaderValue::from_static("*/*"));
|
||||||
map.insert("Accept-Language", HeaderValue::from_static("en-US,en;q=0.5"));
|
map.insert("Accept-Language", HeaderValue::from_static("en-US,en;q=0.5"));
|
||||||
map.insert("Accept-Encoding", HeaderValue::from_static("gzip, deflate, br"));
|
map.insert("Accept-Encoding", HeaderValue::from_static("gzip, deflate, br"));
|
||||||
map.insert("Referer", HeaderValue::from_static("https://duckduckgo.com/"));
|
map.insert("Referer", HeaderValue::from_static("https://duckduckgo.com/"));
|
||||||
|
@ -56,7 +58,7 @@ fn get_headers() -> HeaderMap {
|
||||||
map.insert("DNT", HeaderValue::from_static("1"));
|
map.insert("DNT", HeaderValue::from_static("1"));
|
||||||
map.insert("Sec-GPC", HeaderValue::from_static("1"));
|
map.insert("Sec-GPC", HeaderValue::from_static("1"));
|
||||||
map.insert("Connection", HeaderValue::from_static("keep-alive"));
|
map.insert("Connection", HeaderValue::from_static("keep-alive"));
|
||||||
map.insert("Cookie", HeaderValue::from_static("dcm=3; ay=b"));
|
map.insert("Cookie", HeaderValue::from_static("dcm=3"));
|
||||||
map.insert("Sec-Fetch-Dest", HeaderValue::from_static("empty"));
|
map.insert("Sec-Fetch-Dest", HeaderValue::from_static("empty"));
|
||||||
map.insert("Sec-Fetch-Mode", HeaderValue::from_static("cors"));
|
map.insert("Sec-Fetch-Mode", HeaderValue::from_static("cors"));
|
||||||
map.insert("Sec-Fetch-Site", HeaderValue::from_static("same-origin"));
|
map.insert("Sec-Fetch-Site", HeaderValue::from_static("same-origin"));
|
||||||
|
@ -102,6 +104,7 @@ async fn get_res<'a>(cli: &Client, query: String, vqd: String, cache: &'a mut Ca
|
||||||
let payload = serde_json::to_string(&payload).unwrap();
|
let payload = serde_json::to_string(&payload).unwrap();
|
||||||
|
|
||||||
let req = cli.post("https://duckduckgo.com/duckchat/v1/chat")
|
let req = cli.post("https://duckduckgo.com/duckchat/v1/chat")
|
||||||
|
// .headers(get_headers())
|
||||||
.header("Content-Type", "application/json")
|
.header("Content-Type", "application/json")
|
||||||
.header("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0")
|
.header("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0")
|
||||||
.header("x-vqd-4", vqd.clone())
|
.header("x-vqd-4", vqd.clone())
|
||||||
|
|
Loading…
Reference in New Issue