File tree Expand file tree Collapse file tree 3 files changed +22
-18
lines changed
core/src/main/java/com/google/adk Expand file tree Collapse file tree 3 files changed +22
-18
lines changed Original file line number Diff line number Diff line change 136136 <scope >test</scope >
137137 </dependency >
138138 </dependencies >
139- </project >
139+ </project >
Original file line number Diff line number Diff line change 1616
1717package com .google .adk .agents ;
1818
19+ import com .google .adk .artifacts .ListArtifactsResponse ;
1920import com .google .adk .events .EventActions ;
2021import com .google .adk .sessions .State ;
2122import com .google .genai .types .Part ;
2223import io .reactivex .rxjava3 .core .Maybe ;
24+ import io .reactivex .rxjava3 .core .Single ;
25+ import java .util .List ;
2326import 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 *
Original file line number Diff line number Diff line change 1818
1919import com .google .adk .agents .CallbackContext ;
2020import com .google .adk .agents .InvocationContext ;
21- import com .google .adk .artifacts .ListArtifactsResponse ;
2221import com .google .adk .events .EventActions ;
2322import com .google .errorprone .annotations .CanIgnoreReturnValue ;
24- import io .reactivex .rxjava3 .core .Single ;
25- import java .util .List ;
2623import 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 }
You can’t perform that action at this time.
0 commit comments