Skip to content

fix: Added Java Example in configuration.md #442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
43 changes: 43 additions & 0 deletions docs/streaming/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ It's set by [RunConfig](https://github.com/google/adk-python/blob/main/src/googl

For example, if you want to set voice config, you can leverage speech_config.

==="Python"
```python
voice_config = genai_types.VoiceConfig(
prebuilt_voice_config=genai_types.PrebuiltVoiceConfigDict(
Expand All @@ -20,5 +21,47 @@ runner.run_live(
run_config=run_config,
)
```
==="Java"
```
package agents;

import com.google.adk.agents.BaseAgent;
import com.google.adk.agents.LlmAgent;
import com.google.adk.events.Event;
import com.google.adk.runner.Runner;
import com.google.adk.sessions.InMemorySessionService;
import io.reactivex.rxjava3.core.Flowable;

public class GeminiStreamingAgent {
public static BaseAgent ROOT_AGENT = initAgent();

private static BaseAgent initAgent() {
return LlmAgent.builder()
.name("gemini-streaming-agent")
.description("Agent demonstrating Gemini Live streaming")
.model("gemini-2.0-flash-live-001")
.instruction("Respond in streaming mode. Use concise messages.")
.build();
}

public static void main(String[] args) {
InMemorySessionService sessionService = new InMemorySessionService();
Runner runner = new Runner(ROOT_AGENT, "GeminiLiveApp", null, sessionService);

var session = sessionService.createSession("GeminiLiveApp", "user1").blockingGet();

// Demonstrate streaming via console
Flowable<Event> stream = runner.runLive(session.userId(), session.id(), "What's trending in AI today?");

stream.subscribe(event -> {
System.out.print(event.stringifyContent());
}, err -> {
err.printStackTrace();
}, () -> {
System.out.println("\n[Stream Complete]");
});
}
}
```