openai / openai-dotnet

The official .NET library for the OpenAI API
https://www.nuget.org/packages/OpenAI/AbsoluteLatest
MIT License
734 stars 64 forks source link

Parsing the OpenAI messages json #99

Open slreznit opened 5 days ago

slreznit commented 5 days ago

Hi,

I would like to use this SDK to Parse the messages Json and then iterate it and access the different fields

For example, can I do this?

 var messages = """
     [
         {
               "role": "system",
               "content": "You are an AI assistant..."
         },
         {
               "role": "user",
               "content": "some user question",
         }
     ]
     """;
List<ChatMessage> p = ParseChatRequest(messages);
foreach (var message in p)
{
    Print($"{p.role}, {p.content}").
}