Make Tool and Function classes easier to deserialize #238
Replies: 3 comments 21 replies
-
You're going to have to give a better explanation of your desired use case.
The goal here is to let you unpack the objects as you need them. You should be able to deserialize any data you need already, since it is json, which means it is inherently serializable. |
Beta Was this translation helpful? Give feedback.
-
Here is a non working example on net core 8.0. var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = false };
using var stream = File.OpenRead("functions.json");
var tools = JsonSerializer.DeserializeAsync<List<Tool>>(stream, options); [
{
"Function": {
"Name": "FindSomething",
"Description": "Find something",
"Parameters": {
"Type": "object",
"Properties": {
"Query": {
"Type": "string",
"Description": "The query"
}
},
"Required": [ "query" ]
}
}
}
] |
Beta Was this translation helpful? Give feedback.
-
Ok I see your point. So is the request now this?:
|
Beta Was this translation helpful? Give feedback.
-
Currently it is not possible to deserialize the Tool and Function classes by using System.Text.json.
My goal here is to load the tools / functions at runtime to enable / disable them on my need without creating a new release i.e.
I also have some other related points here:
With that option it would be possible to dynamically deserialize the callback without any switches and pass it to some other processing handlers:
Beta Was this translation helpful? Give feedback.
All reactions