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
3 changes: 3 additions & 0 deletions packages/gcp_vertexai/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# newer versions go on top
- version: "1.4.0-next"
changes:
- description: Update the mapping to snake case in pipeline.
type: enhancement
link: https://github.com/elastic/integrations/pull/15604
- description: Add support for Vertex AI Prompt Response Logs datastream.
type: enhancement
link: https://github.com/elastic/integrations/pull/15435
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,41 @@ processors:
field: event.action
copy_from: gcp.vertexai.prompt_response_logs.api_method
if: ctx.gcp?.vertexai?.prompt_response_logs?.api_method != null


# Rename camelCase fields to snake_case

- script:
lang: painless
source: |
Map keysToSnakeCase(Map m) {
def regex = /_?([a-z])([A-Z]+)/;
def snakeCaseMap = [:];
for (entry in m.entrySet()) {
def k = entry.getKey();
def v = entry.getValue();
if (v instanceof Map) {
v = keysToSnakeCase(v);
} else if (v instanceof List) {
for (int i = 0; i < v.size(); i++) {
def item = v.get(i);
if (item instanceof Map) {
v.set(i, keysToSnakeCase(item));
}
}
}
k = regex.matcher(k).replaceAll('$1_$2').toLowerCase();
snakeCaseMap.put(k, v);
}
return snakeCaseMap;
}

if (ctx.gcp?.vertexai?.prompt_response_logs?.full_request != null) {
ctx.gcp.vertexai.prompt_response_logs.full_request = keysToSnakeCase(ctx.gcp.vertexai.prompt_response_logs.full_request);
}
if (ctx.gcp?.vertexai?.prompt_response_logs?.full_response != null) {
ctx.gcp.vertexai.prompt_response_logs.full_response = keysToSnakeCase(ctx.gcp.vertexai.prompt_response_logs.full_response);
}


# Remove null and empty values recursively
- script:
Expand Down