Skip to content

Commit 9e68fa8

Browse files
add docs to readme
1 parent f9de5f0 commit 9e68fa8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,21 @@ server_params = StdioServerParameters(
417417
env=None # Optional environment variables
418418
)
419419

420+
# Optional: create a sampling callback
421+
async def handle_sampling_message(message: types.CreateMessageRequestParams) -> types.CreateMessageResult:
422+
return types.CreateMessageResult(
423+
role="assistant",
424+
content=types.TextContent(
425+
type="text",
426+
text="Hello, world! from model",
427+
),
428+
model="gpt-3.5-turbo",
429+
stopReason="endTurn",
430+
)
431+
420432
async def run():
421433
async with stdio_client(server_params) as (read, write):
422-
async with ClientSession(read, write) as session:
434+
async with ClientSession(read, write, sampling_callback=handle_sampling_message) as session:
423435
# Initialize the connection
424436
await session.initialize()
425437

0 commit comments

Comments
 (0)