Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,13 @@ InvokeModelOutcome BedrockRuntimeClient::InvokeModel(const InvokeModelRequest& r
smithy::components::tracing::SpanKind::CLIENT);
return TracingUtils::MakeCallWithTiming<InvokeModelOutcome>(
[&]() -> InvokeModelOutcome {
return InvokeModelOutcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_POST,
[&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void {
resolvedEndpoint.AddPathSegments("/model/");
resolvedEndpoint.AddPathSegment(request.GetModelId());
resolvedEndpoint.AddPathSegments("/invoke");
}));
return InvokeModelOutcome(MakeRequestWithUnparsedResponse(&request, request.GetServiceRequestName(),
Aws::Http::HttpMethod::HTTP_POST,
[&](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void {
resolvedEndpoint.AddPathSegments("/model/");
resolvedEndpoint.AddPathSegment(request.GetModelId());
resolvedEndpoint.AddPathSegments("/invoke");
}));
},
TracingUtils::SMITHY_CLIENT_DURATION_METRIC, *meter,
{{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <aws/bedrock-runtime/model/ConverseStreamRequest.h>
#include <aws/bedrock-runtime/model/ConverseStreamHandler.h>
#include <aws/core/client/CoreErrors.h>
#include <aws/bedrock-runtime/model/InvokeModelRequest.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/utils/Outcome.h>
#include <aws/testing/TestingEnvironment.h>
Expand Down Expand Up @@ -74,4 +75,21 @@ TEST_F(BedrockRuntimeTests, TestStreaming)
return responseReceived; });
ASSERT_TRUE(responseReceived);
}

TEST_F(BedrockRuntimeTests, TestInvokeModel)
{
auto bedrockRequest = Aws::BedrockRuntime::Model::InvokeModelRequest{}.WithModelId("us.anthropic.claude-3-5-sonnet-20241022-v2:0").WithAccept("application/json") ;

bedrockRequest.SetBody(Aws::MakeShared<Aws::StringStream>(
"BedrockRuntimeTests::TestInvokeModel",
R"({"anthropic_version":"bedrock-2023-05-31","max_tokens":1024,"messages":[{"role":"user","content":"Why is the Mets baseball team so bad?"}]})"));
bedrockRequest.SetContentType("application/json");

Aws::BedrockRuntime::Model::InvokeModelOutcome outcome = m_client->InvokeModel(bedrockRequest);
ASSERT_TRUE(outcome.IsSuccess());
Aws::StringStream ss;
ss << outcome.GetResult().GetBody().rdbuf();
ASSERT_FALSE(ss.str().empty());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ ${operation.name}Outcome ${className}::${operation.name}(${constText}${operation
});
}
#end
return ${operation.name}Outcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_${operation.http.method}, [&#if($hasEndPointOverrides) , endpointOverrides #end](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void {
#if($operation.result && $operation.result.shape.hasStreamMembers())
return ${operation.name}Outcome(MakeRequestWithUnparsedResponse(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_${operation.http.method}, [&#if($hasEndPointOverrides) , endpointOverrides #end](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void {
#else
return ${operation.name}Outcome(MakeRequestDeserialize(&request, request.GetServiceRequestName(), Aws::Http::HttpMethod::HTTP_${operation.http.method}, [&#if($hasEndPointOverrides) , endpointOverrides #end](Aws::Endpoint::AWSEndpoint& resolvedEndpoint) -> void {
#end
#parse("/com/amazonaws/util/awsclientgenerator/velocity/cpp/smithy/SmithyEndpointClosure.vm")
}));
},
Expand Down
Loading