openai_struct/models/
chat_completion_request_developer_message.rs

1/*
2 * OpenAI API
3 *
4 * The OpenAI REST API. Please see pub https://platform.openai.com/docs/api-reference for more details.
5 *
6 * OpenAPI spec pub version: 2.3.0
7 *
8 * Generated pub by: https://github.com/swagger-api/swagger-codegen.git
9 */
10
11/// pub ChatCompletionRequestDeveloperMessage : Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, `developer` messages replace the previous `system` messages.
12
13#[allow(unused_imports)]
14use serde_json::Value;
15
16use crate::ChatCompletionRequestMessageContentPartText;
17
18#[derive(Debug, Serialize, Deserialize, PartialEq)]
19pub struct ChatCompletionRequestDeveloperMessage {
20    /// The contents of the developer message.
21    #[serde(rename = "content")]
22    pub content: ChatCompletionRequestDeveloperMessageContent,
23    /// An optional name for the participant. Provides the model information to differentiate between participants of the same role.
24    #[serde(rename = "name")]
25    pub name: Option<String>,
26}
27
28#[derive(Debug, Serialize, Deserialize, PartialEq)]
29#[serde(untagged)]
30pub enum ChatCompletionRequestDeveloperMessageContent {
31    Text(String),
32    Array(Vec<ChatCompletionRequestMessageContentPartText>),
33}
34
35#[test]
36fn test_message_developer_message_content() {
37    assert_eq!(
38        serde_json::to_string(&ChatCompletionRequestDeveloperMessageContent::Text(
39            "qwe".into()
40        ))
41        .unwrap(),
42        "\"qwe\"".to_string()
43    );
44}