Importing Function Definitions from the OpenAI json schema #8835
-
Hello, While I could create a C# code generator, I really hope there is a faster solution for this. Can someone point me to the API, if exists? |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 5 replies
-
@raffaeler - you can take a look at how to do this with Open API (https://github.com/microsoft/semantic-kernel/tree/main/dotnet/samples/Concepts/Plugins). Open AI updated this blog post (https://openai.com/index/chatgpt-plugins/) noting "Note: OpenAI plugins have been deprecated. For more information about our products, check out ChatGPT for everyone, for Teams, and for Enterprises, plus our APIs for developers." |
Beta Was this translation helpful? Give feedback.
-
Hi @evchaki I am not sure we are talking about the same thing. Thanks |
Beta Was this translation helpful? Give feedback.
-
@raffaeler |
Beta Was this translation helpful? Give feedback.
-
The strategy used in the OpenAI function definitions looks like rudimental but it solves the problem of dependent libraries. To solve this, the cleanest and easiest solution is to:
If there is a way to do that, I can parse the OpenAI json format by myself and register the function definitions. @markwallace-microsoft could you please tell me if there is a way to imperatively build a plugin without using attributes or SK interfaces? |
Beta Was this translation helpful? Give feedback.
-
@markwallace-microsoft sorry for insisting, but you mentioned OpenAPI and I am instead talking about OpenAI. Thanks |
Beta Was this translation helpful? Give feedback.
-
Thank you @markwallace-microsoft |
Beta Was this translation helpful? Give feedback.
-
@raffaeler I tried this prompt
And got this code (which should illustrate what you need to do) Here's the C# code to create a model class and deserialize the JSON string into the class object using Newtonsoft.Json library: First, you need to install the Newtonsoft.Json library, if not already installed. You can install it using NuGet package manager with the following command: Install-Package Newtonsoft.Json
using Newtonsoft.Json; public class GetCurrentWeather
} public class Parameters
} public class Property
}
using Newtonsoft.Json; string json = @"{ GetCurrentWeather currentWeather = JsonConvert.DeserializeObject(json); Now you have deserialized the JSON into the GetCurrentWeather class, and you can use the currentWeather object to access the properties. |
Beta Was this translation helpful? Give feedback.
-
@markwallace-microsoft I see, thank you. Thanks |
Beta Was this translation helpful? Give feedback.
@raffaeler
You can deserialize the JSON into a model object that you provide and then convert that into the arguments required by
KernelPluginFactory.CreateFromFunctions
.I tried this prompt