После нескольких часов поиска я не смог найти код основного примера .NET. Единственным примером, который я нашел, был этот пример Python: https://docs.aws.amazon.com/bedrock/lat ... tmlобразно до .NET Core, это выглядело многообещающе.
Код: Выделить всё
var messages = new List
{
new Message
{
Role = ConversationRole.User,
Content = new List { new ContentBlock { Text = "Get the most popular song played on a radio station." } }
}
};
var response = await bedrock.ConverseAsync(new ConverseRequest
{
ModelId = "anthropic.claude-3-sonnet-20240229-v1:0",
Messages = messages,
ToolConfig = new ToolConfiguration
{
//taken from https://docs.aws.amazon.com/bedrock/latest/userguide/tool-use-inference-call.html
Tools = new List
{
new Tool
{
ToolSpec = new ToolSpecification
{
Name = "GetSong",
Description = "Gets the current song on the radio",
InputSchema = new ToolInputSchema
{
Json = Amazon.Runtime.Documents.Document.FromObject(new
{
Type = "object",
Properties = new Dictionary
{
{ "sign", new {
Type = "string",
Description = "The call sign for the radio station for which you want the most popular song. Example calls signs are WZPZ and WKRP."
} }
},
Required = new string[]
{
"sign"
},
}),
},
}
}
}
}
});
< /code>
К сожалению, он бросает это исключение во время выполнения: < /p>
Amazon.BedrockRuntime.Model.ValidationException
HResult=0x80131500
Message=The value at toolConfig.tools.0.toolSpec.inputSchema.json.type must be one of the following: object.
Source=AWSSDK.Core
StackTrace:
at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleExceptionStream(IRequestContext requestContext, IWebResponseData httpErrorResponse, HttpErrorResponseException exception, Stream responseStream)
at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.d__2.MoveNext()
at Amazon.Runtime.Internal.ExceptionHandler`1.d__6.MoveNext()
at Amazon.Runtime.Internal.ErrorHandler.
d__8.MoveNext()
at Amazon.Runtime.Internal.ErrorHandler.d__5`1.MoveNext()
at Amazon.Runtime.Internal.CallbackHandler.d__9`1.MoveNext()
at Amazon.Runtime.Internal.Signer.d__1`1.MoveNext()
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.d__2`1.MoveNext()
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.d__2`1.MoveNext()
at Amazon.Runtime.Internal.CredentialsRetriever.d__7`1.MoveNext()
at Amazon.Runtime.Internal.RetryHandler.d__10`1.MoveNext()
at Amazon.Runtime.Internal.RetryHandler.d__10`1.MoveNext()
at Amazon.Runtime.Internal.CallbackHandler.d__9`1.MoveNext()
at Amazon.Runtime.Internal.CallbackHandler.d__9`1.MoveNext()
at Amazon.Runtime.Internal.ErrorCallbackHandler.d__5`1.MoveNext()
at Amazon.Runtime.Internal.MetricsHandler.d__1`1.MoveNext()
at Program.d__0.MoveNext() in D:\DotnetAgentExperiments\aws.bed\Program.cs:line 22
Подробнее здесь: https://stackoverflow.com/questions/793 ... n-net-core