Skip to content

Commit 2cdb435

Browse files
jaycee-licopybara-github
authored andcommitted
feat: add types for Live API
PiperOrigin-RevId: 734211894
1 parent aa0262d commit 2cdb435

11 files changed

+898
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Auto-generated code. Do not edit.
18+
19+
package com.google.genai.types;
20+
21+
import com.fasterxml.jackson.annotation.JsonCreator;
22+
import com.fasterxml.jackson.annotation.JsonProperty;
23+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
24+
import com.google.auto.value.AutoValue;
25+
import com.google.genai.JsonSerializable;
26+
import java.util.List;
27+
import java.util.Optional;
28+
29+
/**
30+
* Incremental update of the current conversation delivered from the client.
31+
*
32+
* <p>All the content here will unconditionally be appended to the conversation history and used as
33+
* part of the prompt to the model to generate content.
34+
*
35+
* <p>A message here will interrupt any current model generation.
36+
*/
37+
@AutoValue
38+
@JsonDeserialize(builder = LiveClientContent.Builder.class)
39+
public abstract class LiveClientContent extends JsonSerializable {
40+
/**
41+
* The content appended to the current conversation with the model.
42+
*
43+
* <p>For single-turn queries, this is a single instance. For multi-turn queries, this is a
44+
* repeated field that contains conversation history and latest request.
45+
*/
46+
@JsonProperty("turns")
47+
public abstract Optional<List<Content>> turns();
48+
49+
/**
50+
* If true, indicates that the server content generation should start with the currently
51+
* accumulated prompt. Otherwise, the server will await additional messages before starting
52+
* generation.
53+
*/
54+
@JsonProperty("turnComplete")
55+
public abstract Optional<Boolean> turnComplete();
56+
57+
/** Instantiates a builder for LiveClientContent. */
58+
public static Builder builder() {
59+
return new AutoValue_LiveClientContent.Builder();
60+
}
61+
62+
/** Creates a builder with the same values as this instance. */
63+
public abstract Builder toBuilder();
64+
65+
/** Builder for LiveClientContent. */
66+
@AutoValue.Builder
67+
public abstract static class Builder {
68+
/** For internal usage. Please use `LiveClientContent.builder()` for instantiation. */
69+
@JsonCreator
70+
private static Builder create() {
71+
return new AutoValue_LiveClientContent.Builder();
72+
}
73+
74+
@JsonProperty("turns")
75+
public abstract Builder turns(List<Content> turns);
76+
77+
@JsonProperty("turnComplete")
78+
public abstract Builder turnComplete(boolean turnComplete);
79+
80+
public abstract LiveClientContent build();
81+
}
82+
83+
/** Deserializes a JSON string to a LiveClientContent object. */
84+
public static LiveClientContent fromJson(String jsonString) {
85+
return JsonSerializable.fromJsonString(jsonString, LiveClientContent.class);
86+
}
87+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Auto-generated code. Do not edit.
18+
19+
package com.google.genai.types;
20+
21+
import com.fasterxml.jackson.annotation.JsonCreator;
22+
import com.fasterxml.jackson.annotation.JsonProperty;
23+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
24+
import com.google.auto.value.AutoValue;
25+
import com.google.genai.JsonSerializable;
26+
import java.util.Optional;
27+
28+
/** Messages sent by the client in the API call. */
29+
@AutoValue
30+
@JsonDeserialize(builder = LiveClientMessage.Builder.class)
31+
public abstract class LiveClientMessage extends JsonSerializable {
32+
/**
33+
* Message to be sent by the system when connecting to the API. SDK users should not send this
34+
* message.
35+
*/
36+
@JsonProperty("setup")
37+
public abstract Optional<LiveClientSetup> setup();
38+
39+
/** Incremental update of the current conversation delivered from the client. */
40+
@JsonProperty("clientContent")
41+
public abstract Optional<LiveClientContent> clientContent();
42+
43+
/** User input that is sent in real time. */
44+
@JsonProperty("realtimeInput")
45+
public abstract Optional<LiveClientRealtimeInput> realtimeInput();
46+
47+
/** Response to a `ToolCallMessage` received from the server. */
48+
@JsonProperty("toolResponse")
49+
public abstract Optional<LiveClientToolResponse> toolResponse();
50+
51+
/** Instantiates a builder for LiveClientMessage. */
52+
public static Builder builder() {
53+
return new AutoValue_LiveClientMessage.Builder();
54+
}
55+
56+
/** Creates a builder with the same values as this instance. */
57+
public abstract Builder toBuilder();
58+
59+
/** Builder for LiveClientMessage. */
60+
@AutoValue.Builder
61+
public abstract static class Builder {
62+
/** For internal usage. Please use `LiveClientMessage.builder()` for instantiation. */
63+
@JsonCreator
64+
private static Builder create() {
65+
return new AutoValue_LiveClientMessage.Builder();
66+
}
67+
68+
@JsonProperty("setup")
69+
public abstract Builder setup(LiveClientSetup setup);
70+
71+
@JsonProperty("clientContent")
72+
public abstract Builder clientContent(LiveClientContent clientContent);
73+
74+
@JsonProperty("realtimeInput")
75+
public abstract Builder realtimeInput(LiveClientRealtimeInput realtimeInput);
76+
77+
@JsonProperty("toolResponse")
78+
public abstract Builder toolResponse(LiveClientToolResponse toolResponse);
79+
80+
public abstract LiveClientMessage build();
81+
}
82+
83+
/** Deserializes a JSON string to a LiveClientMessage object. */
84+
public static LiveClientMessage fromJson(String jsonString) {
85+
return JsonSerializable.fromJsonString(jsonString, LiveClientMessage.class);
86+
}
87+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Auto-generated code. Do not edit.
18+
19+
package com.google.genai.types;
20+
21+
import com.fasterxml.jackson.annotation.JsonCreator;
22+
import com.fasterxml.jackson.annotation.JsonProperty;
23+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
24+
import com.google.auto.value.AutoValue;
25+
import com.google.genai.JsonSerializable;
26+
import java.util.List;
27+
import java.util.Optional;
28+
29+
/**
30+
* User input that is sent in real time.
31+
*
32+
* <p>This is different from `ClientContentUpdate` in a few ways:
33+
*
34+
* <p>- Can be sent continuously without interruption to model generation. - If there is a need to
35+
* mix data interleaved across the `ClientContentUpdate` and the `RealtimeUpdate`, server attempts
36+
* to optimize for best response, but there are no guarantees. - End of turn is not explicitly
37+
* specified, but is rather derived from user activity (for example, end of speech). - Even before
38+
* the end of turn, the data is processed incrementally to optimize for a fast start of the response
39+
* from the model. - Is always assumed to be the user's input (cannot be used to populate
40+
* conversation history).
41+
*/
42+
@AutoValue
43+
@JsonDeserialize(builder = LiveClientRealtimeInput.Builder.class)
44+
public abstract class LiveClientRealtimeInput extends JsonSerializable {
45+
/** Inlined bytes data for media input. */
46+
@JsonProperty("mediaChunks")
47+
public abstract Optional<List<Blob>> mediaChunks();
48+
49+
/** Instantiates a builder for LiveClientRealtimeInput. */
50+
public static Builder builder() {
51+
return new AutoValue_LiveClientRealtimeInput.Builder();
52+
}
53+
54+
/** Creates a builder with the same values as this instance. */
55+
public abstract Builder toBuilder();
56+
57+
/** Builder for LiveClientRealtimeInput. */
58+
@AutoValue.Builder
59+
public abstract static class Builder {
60+
/** For internal usage. Please use `LiveClientRealtimeInput.builder()` for instantiation. */
61+
@JsonCreator
62+
private static Builder create() {
63+
return new AutoValue_LiveClientRealtimeInput.Builder();
64+
}
65+
66+
@JsonProperty("mediaChunks")
67+
public abstract Builder mediaChunks(List<Blob> mediaChunks);
68+
69+
public abstract LiveClientRealtimeInput build();
70+
}
71+
72+
/** Deserializes a JSON string to a LiveClientRealtimeInput object. */
73+
public static LiveClientRealtimeInput fromJson(String jsonString) {
74+
return JsonSerializable.fromJsonString(jsonString, LiveClientRealtimeInput.class);
75+
}
76+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Auto-generated code. Do not edit.
18+
19+
package com.google.genai.types;
20+
21+
import com.fasterxml.jackson.annotation.JsonCreator;
22+
import com.fasterxml.jackson.annotation.JsonProperty;
23+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
24+
import com.google.auto.value.AutoValue;
25+
import com.google.genai.JsonSerializable;
26+
import java.util.List;
27+
import java.util.Optional;
28+
29+
/** Message contains configuration that will apply for the duration of the streaming session. */
30+
@AutoValue
31+
@JsonDeserialize(builder = LiveClientSetup.Builder.class)
32+
public abstract class LiveClientSetup extends JsonSerializable {
33+
/** The fully qualified name of the publisher model or tuned model endpoint to use. */
34+
@JsonProperty("model")
35+
public abstract Optional<String> model();
36+
37+
/**
38+
* The generation configuration for the session.
39+
*
40+
* <p>The following fields are supported: - `response_logprobs` - `response_mime_type` -
41+
* `logprobs` - `response_schema` - `stop_sequence` - `routing_config` - `audio_timestamp`
42+
*/
43+
@JsonProperty("generationConfig")
44+
public abstract Optional<GenerationConfig> generationConfig();
45+
46+
/**
47+
* The user provided system instructions for the model. Note: only text should be used in parts
48+
* and content in each part will be in a separate paragraph.
49+
*/
50+
@JsonProperty("systemInstruction")
51+
public abstract Optional<Content> systemInstruction();
52+
53+
/**
54+
* A list of `Tools` the model may use to generate the next response.
55+
*
56+
* <p>A `Tool` is a piece of code that enables the system to interact with external systems to
57+
* perform an action, or set of actions, outside of knowledge and scope of the model.
58+
*/
59+
@JsonProperty("tools")
60+
public abstract Optional<List<Tool>> tools();
61+
62+
/** Instantiates a builder for LiveClientSetup. */
63+
public static Builder builder() {
64+
return new AutoValue_LiveClientSetup.Builder();
65+
}
66+
67+
/** Creates a builder with the same values as this instance. */
68+
public abstract Builder toBuilder();
69+
70+
/** Builder for LiveClientSetup. */
71+
@AutoValue.Builder
72+
public abstract static class Builder {
73+
/** For internal usage. Please use `LiveClientSetup.builder()` for instantiation. */
74+
@JsonCreator
75+
private static Builder create() {
76+
return new AutoValue_LiveClientSetup.Builder();
77+
}
78+
79+
@JsonProperty("model")
80+
public abstract Builder model(String model);
81+
82+
@JsonProperty("generationConfig")
83+
public abstract Builder generationConfig(GenerationConfig generationConfig);
84+
85+
@JsonProperty("systemInstruction")
86+
public abstract Builder systemInstruction(Content systemInstruction);
87+
88+
@JsonProperty("tools")
89+
public abstract Builder tools(List<Tool> tools);
90+
91+
public abstract LiveClientSetup build();
92+
}
93+
94+
/** Deserializes a JSON string to a LiveClientSetup object. */
95+
public static LiveClientSetup fromJson(String jsonString) {
96+
return JsonSerializable.fromJsonString(jsonString, LiveClientSetup.class);
97+
}
98+
}

0 commit comments

Comments
 (0)