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:
jokemanfire 2025-05-12 13:52:57 +08:00 • committed by GitHub
commit 6de444c62f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)
}
}