ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1
2
Welcome to Claude-in-sheets!
3
This is Anthroic's somewhat janky but still very useful tool for rapidly testing different prompts against an evaluation suite of inputs. This is very pre-release so expect some bumps!

This spreadsheet contains an extension that enables you to make calls to Anthropic's Claude API from within a cell. This enables you to test out a prompt on a range of data, quickly iterate on prompts, automatically score results, and do many other things. Each tab here is an example of different functionality.

There are several examples, starting with a simple one and moving to a complex one. There are also two "Blank" sheets that you can use on your own prompts. You're welcome to duplicate the blank sheets to try lots of prompts, but copying the whole file will not work, as the Claude-in-sheets extension is tied to this spreadsheet.
4
5
Caveat: Right now the API only allows about 10 simulataneous API calls from Claude-in-sheets, and Google Sheets times out all calls after 30 seconds. That means if you have a large number of cells, some of them will return #ERROR (Exceeded maximum execution time) after 30 seconds of inactivity. The best way to handle this is to erase those cells, wait a few seconds, and then copy-paste the formula back in.
6
7
Claude-in-sheets contains two functions:

=CLAUDE(prompt, model, params) which will insert the "\n\nHuman: " and "\n\nAssistant: " formatting around your prompt for you. This is identical to the Slackbot Claude interface and "Chat" mode on the console.

=CLAUDEFREE(prompt, model, params) in which you have to insert "\n\nHuman: " and "\n\nAssistant: " yourself. This is identical to the raw API Claude interface and "Edit Chat" mode on the console.

For more information on the special "Human:"/"Assistant:" formatting in CLAUDEFREE, see this documentation page.

Note that you don't have to provide the model or params; by default it will use the latest model and default parameters.

Advanced use: If you want to specify API parameters, you can do so by listing "parameter name", "parameter value" at the end of the call. For example, if you want to set the max_tokens to 3, you can do it as follows: =CLAUDE("[your prompt]"), "claude-v1", "max_tokens_to_sample", 3)
8
9
Very helpful Google Sheets shortcuts to know:
- You have to type Command-Enter (Mac) or Control-Enter (Windows) to start a new line in a cell!
- If you're pasting many lines of input into a single cell in Google Sheets, select the cell you want to put input into, then hit Function-F2, then paste. If you don't do this, your multiline input gets pasted across several cells.
- Google sheets string-escapes "\n" so you have to type an actual newline for it to work.
10
Getting your prompt to work:
Read the documentation on the Partner Portal first.
If your prompt isn't working as desired, use the prompting checklist to make sure you're doing everything right.
11
12
Here's an example of the CLAUDE function in action:
13
14
Prompt:
15
When was Google founded?
16
CLAUDE response (generated with an API call to Anthropic!)
17
Google was founded in 1998.
18
19
Here's an example of the CLAUDEFREE function in action:
20
21
Note that you have to add "Human:" and then press Command-enter twice at the beginning of the prompt to add the two newlines. The newlines are invisible. Claude expects this input by default, so you need to add it when using CLAUDEFREE. This format is most useful when you want to force Claude to respond in a particular way. By essentially putting words in its mouth, it will continue its response in the desired format.
22
Prompt:
23


Human: You are a customer service agent that is classifying emails by type. I want you to give your answer and then explain it.

How would you categorize this email?
<email>
Hi -- My Mixmaster4000 is producing a strange noise when I operate it. It also smells a bit smoky and plasticky, like burning electronics. I need a replacement.
</email>

Categories are:
(A) Pre-sale question
(B) Broken or defective item
(C) Billing question
(D) Other (please explain)

Assistant: My answer is (
24
CLAUDEFREE response (generated with an API call to Anthropic!)
25
B) Broken or defective item.

Explanation: This email is describing a product that is malfunctioning, producing strange noises and smells, indicating it is broken or defective. The customer states they need a replacement, so it is clearly a case of a broken item, not a general pre-sale question or billing inquiry.
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100