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
11 changes: 11 additions & 0 deletions docs/callbacks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
30 changes: 30 additions & 0 deletions docs/callbacks/types-of-callbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions examples/typescript/snippets/callbacks/callback_basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -53,6 +55,7 @@ const myAgent = new LlmAgent({
instruction: "Be helpful.",
beforeModelCallback: myBeforeModelLogic,
});
// --8<-- [end:callback_basic]

// Agent Interaction
async function callAgentAsync(query: string) {
Expand Down
Loading