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
2 changes: 1 addition & 1 deletion contrib/langchain4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@
<scope>test</scope>
</dependency>
</dependencies>
</project>
</project>
21 changes: 21 additions & 0 deletions core/src/main/java/com/google/adk/agents/CallbackContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@

package com.google.adk.agents;

import com.google.adk.artifacts.ListArtifactsResponse;
import com.google.adk.events.EventActions;
import com.google.adk.sessions.State;
import com.google.genai.types.Part;
import io.reactivex.rxjava3.core.Maybe;
import io.reactivex.rxjava3.core.Single;
import java.util.List;
import java.util.Optional;

/** The context of various callbacks for an agent invocation. */
Expand Down Expand Up @@ -51,6 +54,24 @@ public EventActions eventActions() {
return eventActions;
}

/**
* Lists the filenames of the artifacts attached to the current session.
*
* @return the list of artifact filenames
*/
public Single<List<String>> listArtifacts() {
if (invocationContext.artifactService() == null) {
throw new IllegalStateException("Artifact service is not initialized.");
}
return invocationContext
.artifactService()
.listArtifactKeys(
invocationContext.session().appName(),
invocationContext.session().userId(),
invocationContext.session().id())
.map(ListArtifactsResponse::filenames);
}

/**
* Loads an artifact from the artifact service associated with the current session.
*
Expand Down
17 changes: 0 additions & 17 deletions core/src/main/java/com/google/adk/tools/ToolContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@

import com.google.adk.agents.CallbackContext;
import com.google.adk.agents.InvocationContext;
import com.google.adk.artifacts.ListArtifactsResponse;
import com.google.adk.events.EventActions;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.reactivex.rxjava3.core.Single;
import java.util.List;
import java.util.Optional;

/** ToolContext object provides a structured context for executing tools or functions. */
Expand Down Expand Up @@ -71,20 +68,6 @@ private void searchMemory() {
throw new UnsupportedOperationException("Search memory not implemented yet.");
}

/** Lists the filenames of the artifacts attached to the current session. */
public Single<List<String>> listArtifacts() {
if (invocationContext.artifactService() == null) {
throw new IllegalStateException("Artifact service is not initialized.");
}
return invocationContext
.artifactService()
.listArtifactKeys(
invocationContext.session().appName(),
invocationContext.session().userId(),
invocationContext.session().id())
.map(ListArtifactsResponse::filenames);
}

public static Builder builder(InvocationContext invocationContext) {
return new Builder(invocationContext);
}
Expand Down