fix: error

This commit is contained in:
0xMRTT 2023-06-17 15:24:07 +02:00
parent dd73c89397
commit 8dfaf98de8
Signed by: 0xMRTT
GPG Key ID: 910B287304120902
1 changed files with 12 additions and 7 deletions

View File

@ -1,6 +1,16 @@
use ratmom::{prelude::*, Request};
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()
.method("POST")
.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("Referer", "https://chatbot.theb.ai")
.header("Origin", "https://chatbot.theb.ai")
.body(format!(r#"{
"prompt": "{prompt}",
"options": {
"parentMessageId": "8c00bd29-75b0-42c7-9d4f-05a94ac8b2de"
}
}"#, prompt = prompt.as_str()))?
.body(body)?
.send()?;
return request.text()?;
return Ok(request.text()?);
}