File: batch_results.py

package info (click to toggle)
anthropic-sdk-python 0.75.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,252 kB
  • sloc: python: 29,737; sh: 177; makefile: 5
file content (19 lines) | stat: -rw-r--r-- 399 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import sys
import time

import rich

from anthropic import Anthropic

client = Anthropic()

try:
    batch_id = sys.argv[1]
except IndexError as exc:
    raise RuntimeError("must specify a message batch ID, `python examples/batch_results.py msgbatch_123`") from exc

s = time.monotonic()

result_stream = client.messages.batches.results(batch_id)
for result in result_stream:
    rich.print(result)