feat(examples): Add func call support (#168)
Some works about simple-chat. 1. fix some bugs. 2. add func call optional. Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
This commit is contained in:
parent
787cc015b7
commit
6de444c62f
1 changed files with 160 additions and 108 deletions
|
|
@ -58,8 +58,11 @@ impl ChatClient for OpenAIClient {
|
|||
println!("API error: {}", error_text);
|
||||
return Err(anyhow::anyhow!("API Error: {}", error_text));
|
||||
}
|
||||
|
||||
let completion: CompletionResponse = response.json().await?;
|
||||
let text_data = response.text().await?;
|
||||
println!("Received response: {}", text_data);
|
||||
let completion: CompletionResponse = serde_json::from_str(&text_data)
|
||||
.map_err(anyhow::Error::from)
|
||||
.unwrap();
|
||||
Ok(completion)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue