fix: error
This commit is contained in:
parent
dd73c89397
commit
8dfaf98de8
19
src/lib.rs
19
src/lib.rs
@ -1,6 +1,16 @@
|
|||||||
use ratmom::{prelude::*, Request};
|
use ratmom::{prelude::*, Request};
|
||||||
|
|
||||||
async fn ask(prompt: String) -> Result<String, Box<dyn std::error::Error>> {
|
async fn ask(prompt: String) -> Result<String, Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
|
let mut body = String::new();
|
||||||
|
body.push_str(r#"{
|
||||||
|
"prompt": ""#);
|
||||||
|
body.push_str(&prompt);
|
||||||
|
body.push_str(r#"",
|
||||||
|
"options": {
|
||||||
|
"parentMessageId": "8c00bd29-75b0-42c7-9d4f-05a94ac8b2de"
|
||||||
|
}
|
||||||
|
}"#);
|
||||||
let mut request = Request::builder()
|
let mut request = Request::builder()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
.uri("https://chatbot.theb.ai/api/chat-process")
|
.uri("https://chatbot.theb.ai/api/chat-process")
|
||||||
@ -10,13 +20,8 @@ async fn ask(prompt: String) -> Result<String, Box<dyn std::error::Error>> {
|
|||||||
.header("Host", "chatbot.theb.ai")
|
.header("Host", "chatbot.theb.ai")
|
||||||
.header("Referer", "https://chatbot.theb.ai")
|
.header("Referer", "https://chatbot.theb.ai")
|
||||||
.header("Origin", "https://chatbot.theb.ai")
|
.header("Origin", "https://chatbot.theb.ai")
|
||||||
.body(format!(r#"{
|
.body(body)?
|
||||||
"prompt": "{prompt}",
|
|
||||||
"options": {
|
|
||||||
"parentMessageId": "8c00bd29-75b0-42c7-9d4f-05a94ac8b2de"
|
|
||||||
}
|
|
||||||
}"#, prompt = prompt.as_str()))?
|
|
||||||
.send()?;
|
.send()?;
|
||||||
|
|
||||||
return request.text()?;
|
return Ok(request.text()?);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user