Skip to content

Commit a82e888

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: Add custom session id functionality to vertex ai session service
PiperOrigin-RevId: 891919371
1 parent 15988b8 commit a82e888

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/genai/converters/_sessions_converters.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export function createAgentEngineSessionConfigToVertex(
4141
common.setValueByPath(parentObject, ['labels'], fromLabels);
4242
}
4343

44+
const fromSessionId = common.getValueByPath(fromObject, ['sessionId']);
45+
if (parentObject !== undefined && fromSessionId != null) {
46+
common.setValueByPath(parentObject, ['_query', 'sessionId'], fromSessionId);
47+
}
48+
4449
return toObject;
4550
}
4651

@@ -185,6 +190,11 @@ export function updateAgentEngineSessionConfigToVertex(
185190
common.setValueByPath(parentObject, ['labels'], fromLabels);
186191
}
187192

193+
const fromSessionId = common.getValueByPath(fromObject, ['sessionId']);
194+
if (parentObject !== undefined && fromSessionId != null) {
195+
common.setValueByPath(parentObject, ['_query', 'sessionId'], fromSessionId);
196+
}
197+
188198
const fromUpdateMask = common.getValueByPath(fromObject, ['updateMask']);
189199
if (parentObject !== undefined && fromUpdateMask != null) {
190200
common.setValueByPath(

src/genai/types/common.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,6 +1865,8 @@ export declare interface CreateAgentEngineSessionConfig {
18651865
expireTime?: string;
18661866
/** Optional. The labels with user-defined metadata to organize your Sessions. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels. */
18671867
labels?: Record<string, string>;
1868+
/** Optional. The user defined ID to use for session, which will become the final component of the session resource name. If not provided, Vertex AI will generate a value for this ID. This value may be up to 63 characters, and valid characters are `[a-z0-9-]`. The first character must be a letter, and the last character must be a letter or number. */
1869+
sessionId?: string;
18681870
}
18691871

18701872
/** Parameters for creating Agent Engine Sessions. */
@@ -2031,6 +2033,8 @@ export declare interface UpdateAgentEngineSessionConfig {
20312033
expireTime?: string;
20322034
/** Optional. The labels with user-defined metadata to organize your Sessions. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels. */
20332035
labels?: Record<string, string>;
2036+
/** Optional. The user defined ID to use for session, which will become the final component of the session resource name. If not provided, Vertex AI will generate a value for this ID. This value may be up to 63 characters, and valid characters are `[a-z0-9-]`. The first character must be a letter, and the last character must be a letter or number. */
2037+
sessionId?: string;
20342038
/** The update mask to apply. For the `FieldMask` definition, see
20352039
https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask. */
20362040
updateMask?: string;

0 commit comments

Comments
 (0)