summarize

View as MarkdownOpen in Claude

Generate a summary of the conversation. The service rate limits this to one call per minute per conversation.

Parameters

conversation_id
strRequired

The conversation to summarize.

summary_prompt
str | None

How to summarize. Overrides the post_prompt text in your SWML for this call only.

**sampling
Any

Sampling controls passed through to the service: temperature (0.3), top_p (0.3), frequency_penalty (1.0), presence_penalty (1.0), and max_tokens (512). The list is closed, so any other key is rejected.

Returns

str — the generated summary.

Raises

SummaryError when the service reports that generation failed. The service returns exactly one of summary or error, both on the success envelope, so a failed summary surfaces as an exception rather than reaching you as an empty string. RateLimitError when you exceed one call per minute.

Example

1import asyncio
2
3from signalwire.ai_chat import AIChatClient, SummaryError
4
5
6async def main():
7 async with AIChatClient(space="your-space") as client:
8 try:
9 summary = await client.summarize(
10 "chat-8f21",
11 summary_prompt="List the pickup address, the destination, and the quoted fare.",
12 )
13 except SummaryError as err:
14 print("no summary:", err.message)
15 return
16
17 print(summary)
18
19
20asyncio.run(main())