1mod traits;
2mod types;
3
4pub use traits::*;
5pub use types::*;
6
7#[doc(hidden)]
9pub use async_trait;
10#[doc(hidden)]
11pub use schemars;
12#[doc(hidden)]
13pub use serde;
14#[doc(hidden)]
15pub use serde_json;
16
17pub use gpt_fn_macros::*;
18
19#[cfg(test)]
20mod tests {
21 use crate::functions::FunctionDescriptor;
22 use schemars::JsonSchema;
23 use serde::Deserialize;
24 use serde_json::json;
25 use std::marker::PhantomData;
26
27 #[test]
28 pub fn test_descriptor_serialization() {
29 #[derive(Deserialize, JsonSchema)]
30 #[allow(dead_code)]
31 struct TestArguments {
32 name: String,
34 age: u16,
36 }
37
38 let test_descriptor = FunctionDescriptor {
39 name: "test_descriptor",
40 description: "Used for testing descriptor serialization",
41 parameters: PhantomData::<TestArguments>,
42 };
43
44 let value = serde_json::to_value(test_descriptor).unwrap();
45 assert_eq!(
46 json!({
47 "description": "Used for testing descriptor serialization",
48 "name": "test_descriptor",
49 "parameters": {
50 "properties": {
51 "age": {
52 "description": "Some example age",
53 "format": "uint16",
54 "minimum": 0.0,
55 "type": "integer"
56 },
57 "name": {
58 "description": "Some example name",
59 "type": "string"
60 }
61 },
62 "required": ["age", "name"],
63 "title": "TestArguments",
64 "type": "object"
65 }
66 }),
67 value
68 );
69 }
70}