Update Microsoft.Extensions.AI version & expose JSON configuration on McpServerResourceCreateOptions (#511)
* Update Microsoft.Extensions.AI version * Update Microsoft.Extensions.AI.OpenAI * Fix failing tests; add JSON configuration options to McpServerResourceCreateOptions. * Replace temporary code with `AIFunction.ReturnJsonSchema` --------- Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
This commit is contained in:
parent
1e8fb04037
commit
28d65470f4
1 changed files with 45 additions and 35 deletions
|
|
@ -85,30 +85,6 @@ public static partial class McpJsonUtilities
|
|||
return false; // No type keyword found.
|
||||
}
|
||||
|
||||
internal static JsonElement? GetReturnSchema(this AIFunction function, AIJsonSchemaCreateOptions? schemaCreateOptions)
|
||||
{
|
||||
// TODO replace with https://github.com/dotnet/extensions/pull/6447 once merged.
|
||||
if (function.UnderlyingMethod?.ReturnType is not Type returnType)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (returnType == typeof(void) || returnType == typeof(Task) || returnType == typeof(ValueTask))
|
||||
{
|
||||
// Do not report an output schema for void or Task methods.
|
||||
return null;
|
||||
}
|
||||
|
||||
if (returnType.IsGenericType && returnType.GetGenericTypeDefinition() is Type genericTypeDef &&
|
||||
(genericTypeDef == typeof(Task<>) || genericTypeDef == typeof(ValueTask<>)))
|
||||
{
|
||||
// Extract the real type from Task<T> or ValueTask<T> if applicable.
|
||||
returnType = returnType.GetGenericArguments()[0];
|
||||
}
|
||||
|
||||
return AIJsonUtilities.CreateJsonSchema(returnType, serializerOptions: function.JsonSerializerOptions, inferenceOptions: schemaCreateOptions);
|
||||
}
|
||||
|
||||
// Keep in sync with CreateDefaultOptions above.
|
||||
[JsonSourceGenerationOptions(JsonSerializerDefaults.Web,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||
|
|
@ -157,6 +133,7 @@ public static partial class McpJsonUtilities
|
|||
[JsonSerializable(typeof(SubscribeRequestParams))]
|
||||
[JsonSerializable(typeof(UnsubscribeRequestParams))]
|
||||
[JsonSerializable(typeof(IReadOnlyDictionary<string, object>))]
|
||||
[JsonSerializable(typeof(PromptMessage[]))]
|
||||
|
||||
// Primitive types for use in consuming AIFunctions
|
||||
[JsonSerializable(typeof(string))]
|
||||
|
|
|
|||
Loading…
Reference in a new issue