AWS SDK for C++

AWS SDK for C++ Version 1.11.609

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();
40
41 AWS_BEDROCKRUNTIME_API virtual void OnEvent() override;
42
44
50 inline void SetInitialResponseCallbackEx(const InvokeModelWithResponseStreamInitialResponseCallbackEx& callback) { m_onInitialResponse = callback; }
54 inline void SetInitialResponseCallback(const InvokeModelWithResponseStreamInitialResponseCallback& noArgCallback)
55 {
56 m_onInitialResponse = [noArgCallback](const InvokeModelWithResponseStreamInitialResponse& rs, const Utils::Event::InitialResponseType) { return noArgCallback(rs); };
57 }
59 inline void SetPayloadPartCallback(const PayloadPartCallback& callback) { m_onPayloadPart = callback; }
60 inline void SetOnErrorCallback(const ErrorCallback& callback) { m_onError = callback; }
61
62 inline InvokeModelWithResponseStreamInitialResponseCallbackEx& GetInitialResponseCallbackEx() { return m_onInitialResponse; }
63
64 private:
65 AWS_BEDROCKRUNTIME_API void HandleEventInMessage();
66 AWS_BEDROCKRUNTIME_API void HandleErrorInMessage();
67 AWS_BEDROCKRUNTIME_API void MarshallError(const Aws::String& errorCode, const Aws::String& errorMessage);
68
69 InvokeModelWithResponseStreamInitialResponseCallbackEx m_onInitialResponse;
70 PayloadPartCallback m_onPayloadPart;
71 ErrorCallback m_onError;
72 };
73
74namespace InvokeModelWithResponseStreamEventMapper
75{
77
79} // namespace InvokeModelWithResponseStreamEventMapper
80} // namespace Model
81} // namespace BedrockRuntime
82} // namespace Aws
void SetInitialResponseCallback(const InvokeModelWithResponseStreamInitialResponseCallback &noArgCallback)
void SetInitialResponseCallbackEx(const InvokeModelWithResponseStreamInitialResponseCallbackEx &callback)
virtual AWS_BEDROCKRUNTIME_API void OnEvent() override
AWS_BEDROCKRUNTIME_API InvokeModelWithResponseStreamHandler(const InvokeModelWithResponseStreamHandler &)=default
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