Skip to content

Commit

Permalink
run code gen
Browse files Browse the repository at this point in the history
  • Loading branch information
sbiscigl committed Dec 21, 2023
1 parent fb30374 commit d9ff2b6
Show file tree
Hide file tree
Showing 41 changed files with 3,675 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <aws/bedrock-agent-runtime/BedrockAgentRuntime_EXPORTS.h>
#include <aws/bedrock-agent-runtime/BedrockAgentRuntimeErrors.h>

#include <aws/bedrock-agent-runtime/model/InvokeAgentInitialResponse.h>
#include <aws/bedrock-agent-runtime/model/PayloadPart.h>
#include <aws/bedrock-agent-runtime/model/TracePart.h>

Expand All @@ -21,13 +22,15 @@ namespace Model
{
enum class InvokeAgentEventType
{
INITIAL_RESPONSE,
CHUNK,
TRACE,
UNKNOWN
};

class InvokeAgentHandler : public Aws::Utils::Event::EventStreamHandler
{
typedef std::function<void(const InvokeAgentInitialResponse&)> InvokeAgentInitialResponseCallback;
typedef std::function<void(const PayloadPart&)> PayloadPartCallback;
typedef std::function<void(const TracePart&)> TracePartCallback;
typedef std::function<void(const Aws::Client::AWSError<BedrockAgentRuntimeErrors>& error)> ErrorCallback;
Expand All @@ -38,6 +41,7 @@ namespace Model

AWS_BEDROCKAGENTRUNTIME_API virtual void OnEvent() override;

inline void SetInitialResponseCallback(const InvokeAgentInitialResponseCallback& callback) { m_onInitialResponse = callback; }
inline void SetPayloadPartCallback(const PayloadPartCallback& callback) { m_onPayloadPart = callback; }
inline void SetTracePartCallback(const TracePartCallback& callback) { m_onTracePart = callback; }
inline void SetOnErrorCallback(const ErrorCallback& callback) { m_onError = callback; }
Expand All @@ -47,6 +51,7 @@ namespace Model
AWS_BEDROCKAGENTRUNTIME_API void HandleErrorInMessage();
AWS_BEDROCKAGENTRUNTIME_API void MarshallError(const Aws::String& errorCode, const Aws::String& errorMessage);

InvokeAgentInitialResponseCallback m_onInitialResponse;
PayloadPartCallback m_onPayloadPart;
TracePartCallback m_onTracePart;
ErrorCallback m_onError;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/

#pragma once
#include <aws/bedrock-agent-runtime/BedrockAgentRuntime_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <utility>

namespace Aws
{
namespace Utils
{
namespace Json
{
class JsonValue;
class JsonView;
} // namespace Json
} // namespace Utils
namespace BedrockAgentRuntime
{
namespace Model
{

class InvokeAgentInitialResponse
{
public:
AWS_BEDROCKAGENTRUNTIME_API InvokeAgentInitialResponse();
AWS_BEDROCKAGENTRUNTIME_API InvokeAgentInitialResponse(Aws::Utils::Json::JsonView jsonValue);
AWS_BEDROCKAGENTRUNTIME_API InvokeAgentInitialResponse& operator=(Aws::Utils::Json::JsonView jsonValue);
AWS_BEDROCKAGENTRUNTIME_API Aws::Utils::Json::JsonValue Jsonize() const;


/**
* <p>streaming response mimetype of the model</p>
*/
inline const Aws::String& GetSessionId() const{ return m_sessionId; }

/**
* <p>streaming response mimetype of the model</p>
*/
inline bool SessionIdHasBeenSet() const { return m_sessionIdHasBeenSet; }

/**
* <p>streaming response mimetype of the model</p>
*/
inline void SetSessionId(const Aws::String& value) { m_sessionIdHasBeenSet = true; m_sessionId = value; }

/**
* <p>streaming response mimetype of the model</p>
*/
inline void SetSessionId(Aws::String&& value) { m_sessionIdHasBeenSet = true; m_sessionId = std::move(value); }

/**
* <p>streaming response mimetype of the model</p>
*/
inline void SetSessionId(const char* value) { m_sessionIdHasBeenSet = true; m_sessionId.assign(value); }

/**
* <p>streaming response mimetype of the model</p>
*/
inline InvokeAgentInitialResponse& WithSessionId(const Aws::String& value) { SetSessionId(value); return *this;}

/**
* <p>streaming response mimetype of the model</p>
*/
inline InvokeAgentInitialResponse& WithSessionId(Aws::String&& value) { SetSessionId(std::move(value)); return *this;}

/**
* <p>streaming response mimetype of the model</p>
*/
inline InvokeAgentInitialResponse& WithSessionId(const char* value) { SetSessionId(value); return *this;}


/**
* <p>streaming response mimetype of the model</p>
*/
inline const Aws::String& GetContentType() const{ return m_contentType; }

/**
* <p>streaming response mimetype of the model</p>
*/
inline bool ContentTypeHasBeenSet() const { return m_contentTypeHasBeenSet; }

/**
* <p>streaming response mimetype of the model</p>
*/
inline void SetContentType(const Aws::String& value) { m_contentTypeHasBeenSet = true; m_contentType = value; }

/**
* <p>streaming response mimetype of the model</p>
*/
inline void SetContentType(Aws::String&& value) { m_contentTypeHasBeenSet = true; m_contentType = std::move(value); }

/**
* <p>streaming response mimetype of the model</p>
*/
inline void SetContentType(const char* value) { m_contentTypeHasBeenSet = true; m_contentType.assign(value); }

/**
* <p>streaming response mimetype of the model</p>
*/
inline InvokeAgentInitialResponse& WithContentType(const Aws::String& value) { SetContentType(value); return *this;}

/**
* <p>streaming response mimetype of the model</p>
*/
inline InvokeAgentInitialResponse& WithContentType(Aws::String&& value) { SetContentType(std::move(value)); return *this;}

/**
* <p>streaming response mimetype of the model</p>
*/
inline InvokeAgentInitialResponse& WithContentType(const char* value) { SetContentType(value); return *this;}

private:

Aws::String m_sessionId;
bool m_sessionIdHasBeenSet = false;

Aws::String m_contentType;
bool m_contentTypeHasBeenSet = false;
};

} // namespace Model
} // namespace BedrockAgentRuntime
} // namespace Aws
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ namespace Model

InvokeAgentHandler::InvokeAgentHandler() : EventStreamHandler()
{
m_onInitialResponse = [&](const InvokeAgentInitialResponse&)
{
AWS_LOGSTREAM_TRACE(INVOKEAGENT_HANDLER_CLASS_TAG,
"InvokeAgent initial response received.");
};

m_onPayloadPart = [&](const PayloadPart&)
{
AWS_LOGSTREAM_TRACE(INVOKEAGENT_HANDLER_CLASS_TAG, "PayloadPart received.");
Expand Down Expand Up @@ -93,6 +99,21 @@ namespace Model
}
switch (InvokeAgentEventMapper::GetInvokeAgentEventTypeForName(eventTypeHeaderIter->second.GetEventHeaderValueAsString()))
{

case InvokeAgentEventType::INITIAL_RESPONSE:
{
JsonValue json(GetEventPayloadAsString());
if (!json.WasParseSuccessful())
{
AWS_LOGSTREAM_WARN(INVOKEAGENT_HANDLER_CLASS_TAG, "Unable to generate a proper InvokeAgentInitialResponse object from the response in JSON format.");
break;
}

InvokeAgentInitialResponse event(json.View());
m_onInitialResponse(event);
break;
}

case InvokeAgentEventType::CHUNK:
{
JsonValue json(GetEventPayloadAsString());
Expand Down Expand Up @@ -209,13 +230,19 @@ namespace Model

namespace InvokeAgentEventMapper
{
static const int INITIAL_RESPONSE_HASH = Aws::Utils::HashingUtils::HashString("initial-response");
static const int CHUNK_HASH = Aws::Utils::HashingUtils::HashString("chunk");
static const int TRACE_HASH = Aws::Utils::HashingUtils::HashString("trace");

InvokeAgentEventType GetInvokeAgentEventTypeForName(const Aws::String& name)
{
int hashCode = Aws::Utils::HashingUtils::HashString(name.c_str());
if (hashCode == CHUNK_HASH)

if (hashCode == INITIAL_RESPONSE_HASH)
{
return InvokeAgentEventType::INITIAL_RESPONSE;
}
else if (hashCode == CHUNK_HASH)
{
return InvokeAgentEventType::CHUNK;
}
Expand All @@ -230,6 +257,8 @@ namespace InvokeAgentEventMapper
{
switch (value)
{
case InvokeAgentEventType::INITIAL_RESPONSE:
return "initial-response";
case InvokeAgentEventType::CHUNK:
return "chunk";
case InvokeAgentEventType::TRACE:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/

#include <aws/bedrock-agent-runtime/model/InvokeAgentInitialResponse.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>

#include <utility>

using namespace Aws::Utils::Json;
using namespace Aws::Utils;

namespace Aws
{
namespace BedrockAgentRuntime
{
namespace Model
{

InvokeAgentInitialResponse::InvokeAgentInitialResponse() :
m_sessionIdHasBeenSet(false),
m_contentTypeHasBeenSet(false)
{
}

InvokeAgentInitialResponse::InvokeAgentInitialResponse(JsonView jsonValue) :
m_sessionIdHasBeenSet(false),
m_contentTypeHasBeenSet(false)
{
*this = jsonValue;
}

InvokeAgentInitialResponse& InvokeAgentInitialResponse::operator =(JsonView jsonValue)
{
AWS_UNREFERENCED_PARAM(jsonValue);
return *this;
}

JsonValue InvokeAgentInitialResponse::Jsonize() const
{
JsonValue payload;

return payload;
}

} // namespace Model
} // namespace BedrockAgentRuntime
} // namespace Aws
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <aws/bedrock-runtime/BedrockRuntime_EXPORTS.h>
#include <aws/bedrock-runtime/BedrockRuntimeErrors.h>

#include <aws/bedrock-runtime/model/InvokeModelWithResponseStreamInitialResponse.h>
#include <aws/bedrock-runtime/model/PayloadPart.h>

namespace Aws
Expand All @@ -20,12 +21,14 @@ namespace Model
{
enum class InvokeModelWithResponseStreamEventType
{
INITIAL_RESPONSE,
CHUNK,
UNKNOWN
};

class InvokeModelWithResponseStreamHandler : public Aws::Utils::Event::EventStreamHandler
{
typedef std::function<void(const InvokeModelWithResponseStreamInitialResponse&)> InvokeModelWithResponseStreamInitialResponseCallback;
typedef std::function<void(const PayloadPart&)> PayloadPartCallback;
typedef std::function<void(const Aws::Client::AWSError<BedrockRuntimeErrors>& error)> ErrorCallback;

Expand All @@ -35,6 +38,7 @@ namespace Model

AWS_BEDROCKRUNTIME_API virtual void OnEvent() override;

inline void SetInitialResponseCallback(const InvokeModelWithResponseStreamInitialResponseCallback& callback) { m_onInitialResponse = callback; }
inline void SetPayloadPartCallback(const PayloadPartCallback& callback) { m_onPayloadPart = callback; }
inline void SetOnErrorCallback(const ErrorCallback& callback) { m_onError = callback; }

Expand All @@ -43,6 +47,7 @@ namespace Model
AWS_BEDROCKRUNTIME_API void HandleErrorInMessage();
AWS_BEDROCKRUNTIME_API void MarshallError(const Aws::String& errorCode, const Aws::String& errorMessage);

InvokeModelWithResponseStreamInitialResponseCallback m_onInitialResponse;
PayloadPartCallback m_onPayloadPart;
ErrorCallback m_onError;
};
Expand Down
Loading

0 comments on commit d9ff2b6

Please sign in to comment.