Skip to content

Commit d302821

Browse files
author
Chojan Shang
committed
fix: make echo work better
Signed-off-by: Chojan Shang <chojan.shang@vesoft.com>
1 parent 61ae1f4 commit d302821

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

examples/echo_agent.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
11
import asyncio
2-
3-
from acp import Agent, AgentSideConnection, PromptRequest, PromptResponse, SessionNotification, stdio_streams
2+
from uuid import uuid4
3+
4+
from acp import (
5+
Agent,
6+
AgentSideConnection,
7+
InitializeRequest,
8+
InitializeResponse,
9+
NewSessionRequest,
10+
NewSessionResponse,
11+
PromptRequest,
12+
PromptResponse,
13+
SessionNotification,
14+
stdio_streams,
15+
)
416
from acp.schema import AgentMessageChunk, TextContentBlock
517

618

719
class EchoAgent(Agent):
820
def __init__(self, conn):
921
self._conn = conn
1022

23+
async def initialize(self, params: InitializeRequest) -> InitializeResponse:
24+
return InitializeResponse(protocolVersion=params.protocolVersion)
25+
26+
async def newSession(self, params: NewSessionRequest) -> NewSessionResponse:
27+
return NewSessionResponse(sessionId=uuid4().hex)
28+
1129
async def prompt(self, params: PromptRequest) -> PromptResponse:
1230
for block in params.prompt:
1331
text = getattr(block, "text", "")

0 commit comments

Comments
 (0)