Skip to content

Commit

Permalink
Update to use localhost and fix openai changes
Browse files Browse the repository at this point in the history
  • Loading branch information
conrad-mo committed May 21, 2024
1 parent 1fbd37d commit 13912bd
Show file tree
Hide file tree
Showing 5 changed files with 1,391 additions and 262 deletions.
5 changes: 3 additions & 2 deletions backend/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ pub async fn gptcall(prompt: String) -> Result<String, Error>{
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
let response = client.post("https://api.openai.com/v1/chat/completions").headers(headers).json(&body).send().await?;
let response_body = response.text().await?;
//println!("{:?}", response_body);
println!("{:?}", response_body);
if !(response_body.is_empty()){
let index1 = response_body.find("\"content\": \"");
let indexone = index1.unwrap() + 12;
let index2 = response_body.find("\"\n },\n \"finish_reason\":");
let index2 = response_body.find("\"\n },\n \"logprobs\":");
println!("{:?}", index2);
let indextwo = index2.unwrap();
Ok(String::from(&response_body[indexone..indextwo]))
}
Expand Down
Loading

0 comments on commit 13912bd

Please sign in to comment.