From 8dfaf98de84abf0260fd6ad1a132b024371915b9 Mon Sep 17 00:00:00 2001 From: 0xMRTT <0xMRTT@proton.me> Date: Sat, 17 Jun 2023 15:24:07 +0200 Subject: [PATCH] fix: error --- src/lib.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f4abdbd..23394a4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,16 @@ use ratmom::{prelude::*, Request}; async fn ask(prompt: String) -> Result> { + + 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> { .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()?); } \ No newline at end of file