use async_openai::types::{ ChatCompletionRequestSystemMessageArgs, ChatCompletionRequestUserMessageArgs, CreateChatCompletionRequest, CreateChatCompletionRequestArgs, }; #[tokio::test] async fn chat_types_serde() { let request: CreateChatCompletionRequest = CreateChatCompletionRequestArgs::default() .messages([ ChatCompletionRequestSystemMessageArgs::default() .content("your are a calculator") .build() .unwrap() .into(), ChatCompletionRequestUserMessageArgs::default() .content("what is the result of 1+1") .build() .unwrap() .into(), ]) .build() .unwrap(); // serialize the request let serialized = serde_json::to_string(&request).unwrap(); // deserialize the request let deserialized: CreateChatCompletionRequest = serde_json::from_str(&serialized).unwrap(); assert_eq!(request, deserialized); }