-
Notifications
You must be signed in to change notification settings - Fork 29
/
apilist.txt
74 lines (47 loc) · 2.3 KB
/
apilist.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# claudette Module Documentation
## claudette.asink
- `class AsyncClient`
- `def __init__(self, model, cli, log)`
Async Anthropic messages client.
- `@patch @delegates(Client) def __call__(self, msgs, sp, temp, maxtok, prefill, stream, stop, **kwargs)`
Make an async call to Claude.
- `@delegates() class AsyncChat`
- `def __init__(self, model, cli, **kwargs)`
Anthropic async chat client.
## claudette.core
- `def find_block(r, blk_type)`
Find the first block of type `blk_type` in `r.content`.
- `def contents(r)`
Helper to get the contents from Claude response `r`.
- `def usage(inp, out, cache_create, cache_read)`
Slightly more concise version of `Usage`.
- `@patch def __add__(self, b)`
Add together each of `input_tokens` and `output_tokens`
- `def mk_msgs(msgs, **kw)`
Helper to set 'assistant' role on alternate messages.
- `class Client`
- `def __init__(self, model, cli, log)`
Basic Anthropic messages client.
- `def mk_tool_choice(choose)`
Create a `tool_choice` dict that's 'auto' if `choose` is `None`, 'any' if it is True, or 'tool' otherwise
- `def mk_funcres(tuid, res)`
Given tool use id and the tool result, create a tool_result response.
- `def mk_toolres(r, ns, obj)`
Create a `tool_result` message from response `r`.
- `@patch @delegates(messages.Messages.create) def __call__(self, msgs, sp, temp, maxtok, prefill, stream, stop, tools, tool_choice, **kwargs)`
Make a call to Claude.
- `@patch @delegates(Client.__call__) def structured(self, msgs, tools, obj, ns, **kwargs)`
Return the value of all tool calls (generally used for structured outputs)
- `class Chat`
- `def __init__(self, model, cli, sp, tools, temp, cont_pr)`
Anthropic chat client.
- `@property def use(self)`
- `def img_msg(data, cache)`
Convert image `data` into an encoded `dict`
- `def text_msg(s, cache)`
Convert `s` to a text message
- `def mk_msg(content, role, cache, **kw)`
Helper to create a `dict` appropriate for a Claude message. `kw` are added as key/value pairs to the message
## claudette.toolloop
- `@patch @delegates(Chat.__call__) def toolloop(self, pr, max_steps, trace_func, cont_func, **kwargs)`
Add prompt `pr` to dialog and get a response from Claude, automatically following up with `tool_use` messages