Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,25 @@ public static void main(String[] args) {
System.out.println("Status: " + interaction.status());

// Print the text outputs from the interaction.
for (Step step : interaction.steps()) {
if (step.isModelOutput()) {
step.asModelOutput()
.content()
.ifPresent(
contents -> {
for (Content content : contents) {
content
.text()
.ifPresent(text -> System.out.println("Output: " + text.text()));
}
});
}
}
interaction
.steps()
.ifPresent(
steps -> {
for (Step step : steps) {
if (step.isModelOutput()) {
step.asModelOutput()
.content()
.ifPresent(
contents -> {
for (Content content : contents) {
content
.text()
.ifPresent(text -> System.out.println("Output: " + text.text()));
}
});
}
}
});
}

private InteractionBasic() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,25 @@ public static void main(String[] args) {
System.out.println("Status: " + interaction.status());

// Print the text outputs from the interaction.
for (Step step : interaction.steps()) {
if (step.isModelOutput()) {
step.asModelOutput()
.content()
.ifPresent(
contents -> {
for (Content content : contents) {
content
.text()
.ifPresent(text -> System.out.println("Output: " + text.text()));
}
});
}
}
interaction
.steps()
.ifPresent(
steps -> {
for (Step step : steps) {
if (step.isModelOutput()) {
step.asModelOutput()
.content()
.ifPresent(
contents -> {
for (Content content : contents) {
content
.text()
.ifPresent(text -> System.out.println("Output: " + text.text()));
}
});
}
}
});
}

private InteractionCreate() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,27 @@ public static void main(String[] args) {
System.out.println("Status: " + interaction.status());

// Print the text outputs from the interaction.
for (Step step : interaction.steps()) {
if (step.isModelOutput()) {
step.asModelOutput()
.content()
.ifPresent(
contents -> {
for (Content content : contents) {
content
.text()
.ifPresent(
text -> System.out.println("Output: " + text.text()));
}
});
}
}
interaction
.steps()
.ifPresent(
steps -> {
for (Step step : steps) {
if (step.isModelOutput()) {
step.asModelOutput()
.content()
.ifPresent(
contents -> {
for (Content content : contents) {
content
.text()
.ifPresent(
text ->
System.out.println("Output: " + text.text()));
}
});
}
}
});
})
.join();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static void main(String[] args) {
String functionCallId = null;
String functionName = null;

List<Step> steps = response.steps();
List<Step> steps = response.steps().orElse(null);
if (steps != null) {
for (Step step : steps) {
if (step.isFunctionCall()) {
Expand Down Expand Up @@ -191,21 +191,26 @@ public static void main(String[] args) {
Interaction followUpResponse = client.interactions.create(followUpParams);

System.out.println("Final response status: " + followUpResponse.status());
for (Step step : followUpResponse.steps()) {
if (step.isModelOutput()) {
step.asModelOutput()
.content()
.ifPresent(
contents -> {
for (Content output : contents) {
output
.text()
.ifPresent(
text -> System.out.println("Final Output: " + text.text()));
}
});
}
}
followUpResponse
.steps()
.ifPresent(
finalSteps -> {
for (Step step : finalSteps) {
if (step.isModelOutput()) {
step.asModelOutput()
.content()
.ifPresent(
contents -> {
for (Content output : contents) {
output
.text()
.ifPresent(
text -> System.out.println("Final Output: " + text.text()));
}
});
}
}
});
} else {
System.out.println("No function call requested by the model.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static void main(String[] args) {
String functionCallId = null;
String functionName = null;

List<Step> steps = response.steps();
List<Step> steps = response.steps().orElse(null);
if (steps != null) {
for (Step step : steps) {
if (step.isFunctionCall()) {
Expand Down Expand Up @@ -170,21 +170,26 @@ public static void main(String[] args) {
Interaction followUpResponse = client.interactions.create(followUpParams);

System.out.println("Final response status: " + followUpResponse.status());
for (Step step : followUpResponse.steps()) {
if (step.isModelOutput()) {
step.asModelOutput()
.content()
.ifPresent(
contents -> {
for (Content output : contents) {
output
.text()
.ifPresent(
text -> System.out.println("Final Output: " + text.text()));
}
});
}
}
followUpResponse
.steps()
.ifPresent(
finalSteps -> {
for (Step step : finalSteps) {
if (step.isModelOutput()) {
step.asModelOutput()
.content()
.ifPresent(
contents -> {
for (Content output : contents) {
output
.text()
.ifPresent(
text -> System.out.println("Final Output: " + text.text()));
}
});
}
}
});
} else {
System.out.println("No function call requested by the model.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,25 @@ public static void main(String[] args) {
System.out.println("Status: " + retrievedInteraction.status());

// Print the text outputs from the retrieved interaction.
for (Step step : retrievedInteraction.steps()) {
if (step.isModelOutput()) {
step.asModelOutput()
.content()
.ifPresent(
contents -> {
for (Content content : contents) {
content
.text()
.ifPresent(text -> System.out.println("Output: " + text.text()));
}
});
}
}
retrievedInteraction
.steps()
.ifPresent(
steps -> {
for (Step step : steps) {
if (step.isModelOutput()) {
step.asModelOutput()
.content()
.ifPresent(
contents -> {
for (Content content : contents) {
content
.text()
.ifPresent(text -> System.out.println("Output: " + text.text()));
}
});
}
}
});
}

private InteractionGet() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ private static void createInteractions(Client client) {

Interaction interaction = client.interactions.create(params);

List<Step> steps = interaction.steps();
for (int i = 0; i < steps.size(); i++) {
System.out.println("Step " + (i + 1) + ": " + steps.get(i));
}
interaction
.steps()
.ifPresent(
steps -> {
for (int i = 0; i < steps.size(); i++) {
System.out.println("Step " + (i + 1) + ": " + steps.get(i));
}
});
}

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ private static void createInteractions(Client client) {

Interaction interaction = client.interactions.create(params);

List<Step> steps = interaction.steps();
for (int i = 0; i < steps.size(); i++) {
System.out.println("Step " + (i + 1) + ": " + steps.get(i));
}
interaction
.steps()
.ifPresent(
steps -> {
for (int i = 0; i < steps.size(); i++) {
System.out.println("Step " + (i + 1) + ": " + steps.get(i));
}
});
}

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import com.google.genai.interactions.models.interactions.GenerationConfig;
import com.google.genai.interactions.models.interactions.Interaction;
import com.google.genai.interactions.models.interactions.SpeechConfig;
import com.google.genai.interactions.models.interactions.Step;
import java.util.Arrays;

/** Example of generating audio using the Interactions API. */
Expand All @@ -69,11 +68,14 @@ private static void createInteractions(Client client) {

Interaction interaction = client.interactions.create(params);

int i = 1;
for (Step step : interaction.steps()) {
System.out.println("Output " + i + ": " + step);
i++;
}
interaction
.steps()
.ifPresent(
outputs -> {
for (int i = 0; i < outputs.size(); i++) {
System.out.println("Output " + (i + 1) + ": " + outputs.get(i));
}
});
}

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,15 @@ public static void main(String[] args) {
System.out.println("Interaction ID: " + interaction.id());
System.out.println("Status: " + interaction.status());

int i = 1;
for (Step step : interaction.steps()) {
System.out.println("Step " + i + ": " + step);
i++;
}
interaction
.steps()
.ifPresent(
steps -> {
for (int i = 0; i < steps.size(); i++) {
Step step = steps.get(i);
System.out.println("Step " + (i + 1) + ": " + step);
}
});

System.out.println("[Generate Content] Start generate content");
GenerateContentConfig config =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.google.genai.interactions.models.interactions.CreateModelInteractionParams;
import com.google.genai.interactions.models.interactions.CreateModelInteractionParams.ResponseModality;
import com.google.genai.interactions.models.interactions.Interaction;
import com.google.genai.interactions.models.interactions.Step;
import java.util.Arrays;

/** Example of generating an image using the Interactions API. */
Expand All @@ -61,11 +60,14 @@ private static void createInteractions(Client client) {

Interaction interaction = client.interactions.create(params);

int i = 1;
for (Step step : interaction.steps()) {
System.out.println("Output " + i + ": " + step);
i++;
}
interaction
.steps()
.ifPresent(
outputs -> {
for (int i = 0; i < outputs.size(); i++) {
System.out.println("Output " + (i + 1) + ": " + outputs.get(i));
}
});
}

public static void main(String[] args) {
Expand Down
Loading
Loading