-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from dongri/refactor-function-types
refactoring function
- Loading branch information
Showing
6 changed files
with
106 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod common; | ||
pub mod error; | ||
pub mod types; | ||
|
||
pub mod audio; | ||
pub mod batch; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use std::collections::HashMap; | ||
|
||
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)] | ||
pub struct Function { | ||
pub name: String, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub description: Option<String>, | ||
pub parameters: FunctionParameters, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)] | ||
pub struct FunctionParameters { | ||
#[serde(rename = "type")] | ||
pub schema_type: JSONSchemaType, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub properties: Option<HashMap<String, Box<JSONSchemaDefine>>>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub required: Option<Vec<String>>, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)] | ||
#[serde(rename_all = "lowercase")] | ||
pub enum JSONSchemaType { | ||
Object, | ||
Number, | ||
String, | ||
Array, | ||
Null, | ||
Boolean, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize, Clone, Default, PartialEq, Eq)] | ||
pub struct JSONSchemaDefine { | ||
#[serde(rename = "type")] | ||
pub schema_type: Option<JSONSchemaType>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub description: Option<String>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub enum_values: Option<Vec<String>>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub properties: Option<HashMap<String, Box<JSONSchemaDefine>>>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub required: Option<Vec<String>>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub items: Option<Box<JSONSchemaDefine>>, | ||
} |