Skip to content

Commit

Permalink
Merge pull request #56 from hytracen/main
Browse files Browse the repository at this point in the history
Impl Default trait for JSONSchemaDefine
  • Loading branch information
Dongri Jin authored Dec 30, 2023
2 parents f88cc6b + bfedc7f commit d192774
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 1 addition & 4 deletions examples/function_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Box::new(chat_completion::JSONSchemaDefine {
schema_type: Some(chat_completion::JSONSchemaType::String),
description: Some("The cryptocurrency to get the price of".to_string()),
enum_values: None,
properties: None,
required: None,
items: None,
..Default::default()
}),
);

Expand Down
5 changes: 1 addition & 4 deletions examples/function_call_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Box::new(chat_completion::JSONSchemaDefine {
schema_type: Some(chat_completion::JSONSchemaType::String),
description: Some("The cryptocurrency to get the price of".to_string()),
enum_values: None,
properties: None,
required: None,
items: None,
..Default::default()
}),
);

Expand Down
13 changes: 13 additions & 0 deletions src/v1/chat_completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,19 @@ pub struct JSONSchemaDefine {
pub items: Option<Box<JSONSchemaDefine>>,
}

impl Default for JSONSchemaDefine {
fn default() -> Self {
Self {
schema_type: None,
description: None,
enum_values: None,
properties: None,
required: None,
items: None,
}
}
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct FunctionParameters {
#[serde(rename = "type")]
Expand Down

0 comments on commit d192774

Please sign in to comment.