mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +01:00
deps: remove reqwest, use bare curl
This commit is contained in:
parent
8c6b78f6ca
commit
98a00674f3
3 changed files with 14 additions and 1187 deletions
1173
Cargo.lock
generated
1173
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -24,7 +24,6 @@ regex-lite = "0.1"
|
||||||
toml = { version = "0.8", optional = true }
|
toml = { version = "0.8", optional = true }
|
||||||
serde_json = { version = "1.0", optional = true }
|
serde_json = { version = "1.0", optional = true }
|
||||||
serde = { version = "1.0", features = ["derive"], optional = true }
|
serde = { version = "1.0", features = ["derive"], optional = true }
|
||||||
reqwest = { version = "0.12", features = ["blocking", "json"], optional = true }
|
|
||||||
textwrap = { version = "0.16", features = ["terminal_size"], optional = true}
|
textwrap = { version = "0.16", features = ["terminal_size"], optional = true}
|
||||||
|
|
||||||
pay-respects-parser = "0.2.6"
|
pay-respects-parser = "0.2.6"
|
||||||
|
|
@ -33,7 +32,7 @@ pay-respects-parser = "0.2.6"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
runtime-rules = ["dep:serde", "dep:toml"]
|
runtime-rules = ["dep:serde", "dep:toml"]
|
||||||
request-ai = ["dep:serde", "dep:serde_json", "dep:reqwest", "dep:textwrap"]
|
request-ai = ["dep:serde", "dep:serde_json", "dep:textwrap"]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
strip = true
|
strip = true
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use reqwest::blocking::Client;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
|
|
@ -98,25 +97,27 @@ The command `{last_command}` returns the following error message: `{error_msg}`.
|
||||||
model,
|
model,
|
||||||
};
|
};
|
||||||
|
|
||||||
let client = Client::new();
|
let res = std::process::Command::new("curl")
|
||||||
let res = client
|
.arg("-X")
|
||||||
.post(&request_url)
|
.arg("POST")
|
||||||
.header("Authorization", format!("Bearer {}", api_key))
|
.arg("-H")
|
||||||
.header("Content-Type", "application/json")
|
.arg(format!("Authorization: Bearer {}", api_key))
|
||||||
.json(&messages)
|
.arg("-H")
|
||||||
.timeout(std::time::Duration::from_secs(10))
|
.arg("Content-Type: application/json")
|
||||||
.send();
|
.arg("-d")
|
||||||
|
.arg(serde_json::to_string(&messages).unwrap())
|
||||||
|
.arg(request_url)
|
||||||
|
.output();
|
||||||
|
|
||||||
let res = match res {
|
let res = match res {
|
||||||
Ok(res) => res,
|
Ok(res) => res.stdout,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let res = &res.text().unwrap();
|
|
||||||
let json: Value = {
|
let json: Value = {
|
||||||
let json = serde_json::from_str(res);
|
let json = serde_json::from_str(std::str::from_utf8(&res).unwrap());
|
||||||
if json.is_err() {
|
if json.is_err() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue