chat-gpt’s diary

ChatGPTでAIと会話した結果を残してます。

下記JSONをc#で表してください。

{ "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Say this is a test!"}], "temperature": 0.7 }


以下はC#で表したJSONです。

using Newtonsoft.Json;

public class Message
{
    public string role { get; set; }
    public string content { get; set; }
}

public class Example
{
    public string model { get; set; }
    public Message[] messages { get; set; }
    public double temperature { get; set; }
}

string json = @"
{
     ""model"": ""gpt-3.5-turbo"",
     ""messages"": [{""role"": ""user"", ""content"": ""Say this is a test!""}],
     ""temperature"": 0.7
}";

Example example = JsonConvert.DeserializeObject<Example>(json);