AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
InvokeModelWithResponseStreamHandler.h
1
6#pragma once
7#include <aws/core/utils/HashingUtils.h>
8#include <aws/core/utils/event/EventStreamHandler.h>
9#include <aws/core/client/AWSError.h>
10#include <aws/bedrock-runtime/BedrockRuntime_EXPORTS.h>
11#include <aws/bedrock-runtime/BedrockRuntimeErrors.h>
12
13#include <aws/bedrock-runtime/model/InvokeModelWithResponseStreamInitialResponse.h>
14#include <aws/bedrock-runtime/model/PayloadPart.h>
15
16namespace Aws
17{
18namespace BedrockRuntime
19{
20namespace Model
21{
23 {
25 CHUNK,
27 };
28
30 {
31 typedef std::function<void(const InvokeModelWithResponseStreamInitialResponse&)> InvokeModelWithResponseStreamInitialResponseCallback;
32 typedef std::function<void(const InvokeModelWithResponseStreamInitialResponse&, const Utils::Event::InitialResponseType)> InvokeModelWithResponseStreamInitialResponseCallbackEx;
33 typedef std::function<void(const PayloadPart&)> PayloadPartCallback;
34 typedef std::function<void(const Aws::Client::AWSError<BedrockRuntimeErrors>& error)> ErrorCallback;
35
36 public:
37 AWS_BEDROCKRUNTIME_API InvokeModelWithResponseStreamHandler();
39
40 AWS_BEDROCKRUNTIME_API virtual void OnEvent() override;
41
43
49 inline void SetInitialResponseCallbackEx(const InvokeModelWithResponseStreamInitialResponseCallbackEx& callback) { m_onInitialResponse = callback; }
53 inline void SetInitialResponseCallback(const InvokeModelWithResponseStreamInitialResponseCallback& noArgCallback)
54 {
55 m_onInitialResponse = [noArgCallback](const InvokeModelWithResponseStreamInitialResponse& rs, const Utils::Event::InitialResponseType) { return noArgCallback(rs); };
56 }
58 inline void SetPayloadPartCallback(const PayloadPartCallback& callback) { m_onPayloadPart = callback; }
59 inline void SetOnErrorCallback(const ErrorCallback& callback) { m_onError = callback; }
60
61 inline InvokeModelWithResponseStreamInitialResponseCallbackEx& GetInitialResponseCallbackEx() { return m_onInitialResponse; }
62
63 private:
64 AWS_BEDROCKRUNTIME_API void HandleEventInMessage();
65 AWS_BEDROCKRUNTIME_API void HandleErrorInMessage();
66 AWS_BEDROCKRUNTIME_API void MarshallError(const Aws::String& errorCode, const Aws::String& errorMessage);
67
68 InvokeModelWithResponseStreamInitialResponseCallbackEx m_onInitialResponse;
69 PayloadPartCallback m_onPayloadPart;
70 ErrorCallback m_onError;
71 };
72
73namespace InvokeModelWithResponseStreamEventMapper
74{
76
78} // namespace InvokeModelWithResponseStreamEventMapper
79} // namespace Model
80} // namespace BedrockRuntime
81} // namespace Aws
void SetInitialResponseCallback(const InvokeModelWithResponseStreamInitialResponseCallback &noArgCallback)
void SetInitialResponseCallbackEx(const InvokeModelWithResponseStreamInitialResponseCallbackEx &callback)
virtual AWS_BEDROCKRUNTIME_API void OnEvent() override
InvokeModelWithResponseStreamInitialResponseCallbackEx & GetInitialResponseCallbackEx()
AWS_BEDROCKRUNTIME_API InvokeModelWithResponseStreamHandler & operator=(const InvokeModelWithResponseStreamHandler &)=default
AWS_BEDROCKRUNTIME_API InvokeModelWithResponseStreamEventType GetInvokeModelWithResponseStreamEventTypeForName(const Aws::String &name)
AWS_BEDROCKRUNTIME_API Aws::String GetNameForInvokeModelWithResponseStreamEventType(InvokeModelWithResponseStreamEventType value)
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String