Skip to content

Commit 26a9d5e

Browse files
committed
Merge S2: region markers include imports
2 parents 79883ee + 34b6418 commit 26a9d5e

420 files changed

Lines changed: 568 additions & 567 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

showcase/integrations/ag2/src/agents/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
the agent via the AG-UI protocol.
66
"""
77

8+
# @region[weather-tool-backend]
89
from __future__ import annotations
910

1011
import json
@@ -34,7 +35,6 @@
3435
# =====
3536
# Tools
3637
# =====
37-
# @region[weather-tool-backend]
3838
async def get_weather(
3939
location: Annotated[str, "City name to get weather for"],
4040
) -> dict[str, str | float]:

showcase/integrations/ag2/src/agents/subagents.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
shared-state channel.
1818
"""
1919

20+
# @region[supervisor-delegation-tools]
21+
# @region[subagent-setup]
2022
import asyncio
2123
import logging
2224
import uuid
@@ -61,7 +63,6 @@ class SubagentsSnapshot(BaseModel):
6163
# prompt. They don't share memory or tools with the supervisor — the
6264
# supervisor only sees what each sub-agent's final reply produces.
6365

64-
# @region[subagent-setup]
6566
_SUB_LLM_CONFIG = LLMConfig({"model": "gpt-4o-mini", "stream": False})
6667

6768
_research_agent = ConversableAgent(
@@ -217,7 +218,6 @@ async def _run_delegation(
217218
# ---------------------------------------------------------------------------
218219

219220

220-
# @region[supervisor-delegation-tools]
221221
# Each @tool wraps a sub-agent invocation. The supervisor LLM "calls"
222222
# these tools to delegate work; each call asynchronously runs the
223223
# matching sub-agent, records the delegation into shared state via

showcase/integrations/ag2/src/app/api/copilotkit-voice/[[...slug]]/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// `transcriptionService` option. V2 URL-routes on `/info`, `/agent/:id/run`,
1313
// `/transcribe`, etc., so the route lives at `[[...slug]]/route.ts`.
1414

15+
// @region[voice-runtime]
16+
// @region[transcription-service-guard]
1517
import type { NextRequest } from "next/server";
1618
import {
1719
CopilotRuntime,
@@ -27,7 +29,6 @@ const AGENT_URL = process.env.AGENT_URL || "http://localhost:8000";
2729

2830
const voiceDemoAgent = new HttpAgent({ url: `${AGENT_URL}/` });
2931

30-
// @region[transcription-service-guard]
3132
class GuardedOpenAITranscriptionService extends TranscriptionService {
3233
private delegate: TranscriptionServiceOpenAI | null;
3334

@@ -55,7 +56,6 @@ let cachedHandler: ((req: Request) => Promise<Response>) | null = null;
5556
function getHandler(): (req: Request) => Promise<Response> {
5657
if (cachedHandler) return cachedHandler;
5758

58-
// @region[voice-runtime]
5959
const runtime = new CopilotRuntime({
6060
// @ts-ignore -- see main route.ts; published agents type generic mismatch
6161
agents: {

showcase/integrations/ag2/src/app/demos/a2ui-fixed-schema/a2ui-backend.snippet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#
1010
# Mirrors the convention from `tool-rendering/render-flight-tool.snippet.tsx`.
1111

12+
# @region[backend-render-operations]
13+
# @region[backend-schema-json-load]
1214
from pathlib import Path
1315
import json
1416

@@ -38,7 +40,6 @@ def render(*args, **kwargs): ...
3840
CATALOG_ID = "flight-catalog"
3941

4042

41-
# @region[backend-schema-json-load]
4243
# Schemas are JSON so they can be authored and reviewed independently of
4344
# the backend code. `a2ui.load_schema` is just a thin `json.load` wrapper
4445
# that resolves the path against the schemas directory.
@@ -47,7 +48,6 @@ def render(*args, **kwargs): ...
4748

4849

4950
def emit_render_operations(origin: str, destination: str, airline: str, price: float):
50-
# @region[backend-render-operations]
5151
# The a2ui middleware detects the `a2ui_operations` container in this
5252
# tool result and forwards the ops to the frontend renderer. The
5353
# frontend catalog resolves component names to local React components.

showcase/integrations/ag2/src/app/demos/a2ui-fixed-schema/a2ui/catalog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
* the agent's fixed schema (src/agents/a2ui_schemas/flight_schema.json) can
99
* compose custom and basic components interchangeably.
1010
*/
11+
// @region[catalog-creation]
1112
import { createCatalog } from "@copilotkit/a2ui-renderer";
1213

1314
import { flightDefinitions } from "./definitions";
1415
import { flightRenderers } from "./renderers";
1516

1617
export const CATALOG_ID = "copilotkit://flight-fixed-catalog";
1718

18-
// @region[catalog-creation]
1919
export const fixedCatalog = createCatalog(flightDefinitions, flightRenderers, {
2020
catalogId: CATALOG_ID,
2121
includeBasicCatalog: true,

showcase/integrations/ag2/src/app/demos/a2ui-fixed-schema/a2ui/definitions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* This matches the canonical catalog's `DynString` helper:
1717
* examples/integrations/langgraph-python/src/app/declarative-generative-ui/definitions.ts
1818
*/
19+
// @region[definitions-types]
1920
import { z } from "zod";
2021
import type { CatalogDefinitions } from "@copilotkit/a2ui-renderer";
2122

@@ -25,7 +26,6 @@ import type { CatalogDefinitions } from "@copilotkit/a2ui-renderer";
2526
*/
2627
const DynString = z.union([z.string(), z.object({ path: z.string() })]);
2728

28-
// @region[definitions-types]
2929
export const flightDefinitions = {
3030
Title: {
3131
description: "A prominent heading for the flight card.",

showcase/integrations/ag2/src/app/demos/agentic-chat-reasoning/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// labeled "Agent reasoning"). That is the "per-message conditional rendering
1818
// via slots" path — the public, stable way to customize reasoning output.
1919

20+
// @region[reasoning-block-render]
2021
import React from "react";
2122
import {
2223
CopilotKit,
@@ -44,7 +45,6 @@ export default function AgenticChatReasoningDemo() {
4445
// Inner — wires a custom `reasoningMessage` slot that makes the thinking
4546
// chain visually prominent, then renders the chat.
4647
function Chat() {
47-
// @region[reasoning-block-render]
4848
return (
4949
<CopilotChat
5050
agentId="agentic-chat-reasoning"

showcase/integrations/ag2/src/app/demos/chat-slots/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
"use client";
22

3+
// @region[register-assistant-message-slot]
4+
// @region[register-disclaimer-slot]
5+
// @region[register-welcome-slot]
36
import React from "react";
47
import {
58
CopilotKit,
@@ -32,13 +35,10 @@ function Chat() {
3235
available: "always",
3336
});
3437

35-
// @region[register-welcome-slot]
3638
const welcomeScreen = CustomWelcomeScreen;
3739
// @endregion[register-welcome-slot]
38-
// @region[register-disclaimer-slot]
3940
const input = { disclaimer: CustomDisclaimer };
4041
// @endregion[register-disclaimer-slot]
41-
// @region[register-assistant-message-slot]
4242
const messageView = {
4343
assistantMessage:
4444
CustomAssistantMessage as unknown as typeof CopilotChatAssistantMessage,

showcase/integrations/ag2/src/app/demos/declarative-gen-ui/a2ui/catalog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
* Reference:
1212
* https://docs.copilotkit.ai/integrations/langgraph/generative-ui/a2ui
1313
*/
14+
// @region[create-catalog]
1415
import { createCatalog } from "@copilotkit/a2ui-renderer";
1516

1617
import { myDefinitions } from "./definitions";
1718
import { myRenderers } from "./renderers";
1819

19-
// @region[create-catalog]
2020
export const myCatalog = createCatalog(myDefinitions, myRenderers, {
2121
catalogId: "declarative-gen-ui-catalog",
2222
includeBasicCatalog: true,

showcase/integrations/ag2/src/app/demos/declarative-gen-ui/a2ui/definitions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
* `includeBasicCatalog: true` so the built-in A2UI primitives (Text, Row,
1212
* Column, Image, Card, Button, …) come along for free.
1313
*/
14+
// @region[definitions-zod]
1415
import { z } from "zod";
1516
import type { CatalogDefinitions } from "@copilotkit/a2ui-renderer";
1617

17-
// @region[definitions-zod]
1818
export const myDefinitions = {
1919
Card: {
2020
description:

0 commit comments

Comments
 (0)