Skip to content

Commit 5839f6c

Browse files
Merge pull request #326 from glaforge:main
PiperOrigin-RevId: 792814097
2 parents 4fc83f0 + ed23e88 commit 5839f6c

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

contrib/langchain4j/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,4 @@
136136
<scope>test</scope>
137137
</dependency>
138138
</dependencies>
139-
</project>
139+
</project>

core/src/main/java/com/google/adk/agents/CallbackContext.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616

1717
package com.google.adk.agents;
1818

19+
import com.google.adk.artifacts.ListArtifactsResponse;
1920
import com.google.adk.events.EventActions;
2021
import com.google.adk.sessions.State;
2122
import com.google.genai.types.Part;
2223
import io.reactivex.rxjava3.core.Maybe;
24+
import io.reactivex.rxjava3.core.Single;
25+
import java.util.List;
2326
import java.util.Optional;
2427

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

57+
/**
58+
* Lists the filenames of the artifacts attached to the current session.
59+
*
60+
* @return the list of artifact filenames
61+
*/
62+
public Single<List<String>> listArtifacts() {
63+
if (invocationContext.artifactService() == null) {
64+
throw new IllegalStateException("Artifact service is not initialized.");
65+
}
66+
return invocationContext
67+
.artifactService()
68+
.listArtifactKeys(
69+
invocationContext.session().appName(),
70+
invocationContext.session().userId(),
71+
invocationContext.session().id())
72+
.map(ListArtifactsResponse::filenames);
73+
}
74+
5475
/**
5576
* Loads an artifact from the artifact service associated with the current session.
5677
*

core/src/main/java/com/google/adk/tools/ToolContext.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818

1919
import com.google.adk.agents.CallbackContext;
2020
import com.google.adk.agents.InvocationContext;
21-
import com.google.adk.artifacts.ListArtifactsResponse;
2221
import com.google.adk.events.EventActions;
2322
import com.google.errorprone.annotations.CanIgnoreReturnValue;
24-
import io.reactivex.rxjava3.core.Single;
25-
import java.util.List;
2623
import java.util.Optional;
2724

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

74-
/** Lists the filenames of the artifacts attached to the current session. */
75-
public Single<List<String>> listArtifacts() {
76-
if (invocationContext.artifactService() == null) {
77-
throw new IllegalStateException("Artifact service is not initialized.");
78-
}
79-
return invocationContext
80-
.artifactService()
81-
.listArtifactKeys(
82-
invocationContext.session().appName(),
83-
invocationContext.session().userId(),
84-
invocationContext.session().id())
85-
.map(ListArtifactsResponse::filenames);
86-
}
87-
8871
public static Builder builder(InvocationContext invocationContext) {
8972
return new Builder(invocationContext);
9073
}

0 commit comments

Comments
 (0)