diff --git a/docs/callbacks/index.md b/docs/callbacks/index.md index e550eff95..a9f7bde16 100644 --- a/docs/callbacks/index.md +++ b/docs/callbacks/index.md @@ -40,6 +40,12 @@ Callbacks are a cornerstone feature of ADK, providing a powerful mechanism to ho --8<-- "examples/python/snippets/callbacks/callback_basic.py:callback_basic" ``` + === "Typescript" + + ```typescript + --8<-- "examples/typescript/snippets/callbacks/callback_basic.ts:callback_basic" + ``` + === "Go" ```go @@ -91,6 +97,11 @@ This example demonstrates the common pattern for a guardrail using `before_model --8<-- "examples/python/snippets/callbacks/before_model_callback.py" ``` + === "Typescript" + ```typescript + --8<-- "examples/typescript/snippets/callbacks/before_model_callback.ts" + ``` + === "Go" ```go --8<-- "examples/go/snippets/callbacks/main.go:imports" diff --git a/docs/callbacks/types-of-callbacks.md b/docs/callbacks/types-of-callbacks.md index a261e9eef..2eef7d2ea 100644 --- a/docs/callbacks/types-of-callbacks.md +++ b/docs/callbacks/types-of-callbacks.md @@ -27,6 +27,11 @@ These callbacks are available on *any* agent that inherits from `BaseAgent` (inc --8<-- "examples/python/snippets/callbacks/before_agent_callback.py" ``` + === "Typescript" + ```typescript + --8<-- "examples/typescript/snippets/callbacks/before_agent_callback.ts" + ``` + === "Go" ```go @@ -68,6 +73,11 @@ These callbacks are available on *any* agent that inherits from `BaseAgent` (inc --8<-- "examples/python/snippets/callbacks/after_agent_callback.py" ``` + === "Typescript" + ```typescript + --8<-- "examples/typescript/snippets/callbacks/after_agent_callback.ts" + ``` + === "Go" ```go @@ -114,6 +124,11 @@ If the callback returns `None` (or a `Maybe.empty()` object in Java), the LLM co ```python --8<-- "examples/python/snippets/callbacks/before_model_callback.py" ``` + + === "Typescript" + ```typescript + --8<-- "examples/typescript/snippets/callbacks/before_model_callback.ts" + ``` === "Go" @@ -149,6 +164,11 @@ If the callback returns `None` (or a `Maybe.empty()` object in Java), the LLM co --8<-- "examples/python/snippets/callbacks/after_model_callback.py" ``` + === "Typescript" + ```typescript + --8<-- "examples/typescript/snippets/callbacks/after_model_callback.ts" + ``` + === "Go" ```go @@ -187,6 +207,11 @@ These callbacks are also specific to `LlmAgent` and trigger around the execution --8<-- "examples/python/snippets/callbacks/before_tool_callback.py" ``` + === "Typescript" + ```typescript + --8<-- "examples/typescript/snippets/callbacks/before_tool_callback.ts" + ``` + === "Go" ```go @@ -220,6 +245,11 @@ These callbacks are also specific to `LlmAgent` and trigger around the execution --8<-- "examples/python/snippets/callbacks/after_tool_callback.py" ``` + === "Typescript" + ```typescript + --8<-- "examples/typescript/snippets/callbacks/after_tool_callback.ts" + ``` + === "Go" ```go diff --git a/examples/typescript/snippets/callbacks/callback_basic.ts b/examples/typescript/snippets/callbacks/callback_basic.ts index 288c94962..cd5307c28 100644 --- a/examples/typescript/snippets/callbacks/callback_basic.ts +++ b/examples/typescript/snippets/callbacks/callback_basic.ts @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +// --8<-- [start:callback_basic] import { LlmAgent, InMemoryRunner, @@ -53,6 +55,7 @@ const myAgent = new LlmAgent({ instruction: "Be helpful.", beforeModelCallback: myBeforeModelLogic, }); +// --8<-- [end:callback_basic] // Agent Interaction async function callAgentAsync(query: string) {