Skip to content
Draft
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
14 changes: 13 additions & 1 deletion source/extensions/filters/http/transformation/ai_transformer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,19 @@ std::tuple<bool, bool> AiTransformer::transformHeaders(
} else {
absl::StrAppend(&path,
AiTransformerConstants::get().GEMINI_GENERATE_CONTENT);
}
}
} else if (provider == AiTransformerConstants::get().PROVIDER_BEDROCK) {
ASSERT(!model.empty(), "Bedrock: required model setting is missing!");
path = replaceModelInPath(
lookupEndpointMetadata(endpoint_metadata, "base_path"), model);
if (enable_chat_streaming_) {
absl::StrAppend(
&path, AiTransformerConstants::get().BEDROCK_CONVERSE_STREAM
} else {
absl::StrAppend(&path,
AiTransformerConstants::get().BEDROCK_CONVERSE);
}
}

// Gemini doc is still using the `key` qs param but the Google GenAI sdk has
// switched to use the `x-goog-api-key` header. Here is the reason we also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,20 @@ struct AiTransformerValues {
const std::string PROVIDER_GEMINI{"gemini"};
const std::string PROVIDER_OPENAI{"openai"};
const std::string PROVIDER_VERTEXAI{"vertexai"};
const std::string PROVIDER_BEDROCK{"bedrock"};

const std::string SCHEMA_ANTHROPIC{"anthropic"};
const std::string SCHEMA_GEMINI{"gemini"};
const std::string SCHEMA_OPENAI{"openai"};
const std::string SCHEMA_BEDROCK{"bedrock"};

const std::string GEMINI_GENERATE_CONTENT{"generateContent"};
const std::string GEMINI_STREAM_GENERATE_CONTENT{"streamGenerateContent"};
const std::string GEMINI_STREAM_QS_PARAM{"alt=sse"};

const std::string BEDROCK_CONVERSE{"converse"};
const std::string BEDROCK_CONVERSE_STREAM{"converse-stream"};

const Http::LowerCaseString AnthropicApiKeyHeader{"x-api-key"};
const Http::LowerCaseString AnthropicVersionHeader{"anthropic-version"};
const Http::LowerCaseString AzureApiKeyHeader{"api-key"};
Expand Down
Loading