Closed
Description
Hi @64bit , your lib is awesome. I'm using it in my side project and it works perfectly.
I found that the structure output can be improved by use serde
and schemars
to make code easy to maintain like my PR #301 . I hope the PR works for you and community.
Btw, I think we can write the utility function like client.complete_structure_output<T>(...)
and then user can just insert their rust struct and no need to worry about manual writing schema.
Assumtption code:
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct Step {
pub output: String,
pub explanation: String,
}
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct MathReasoningResponse {
pub final_answer: String,
pub steps: Vec<Step>,
}
let request = CreateChatCompletionRequestArgs::default()
.max_tokens(512u32)
.model("gpt-4o-mini")
.messages(messages)
.complete_structure_output<MathReasoningResponse>()
.build()?;
let client = Client::new();
let response = client.chat().create(request).await?;
Thanks