@anthropic-ai/sdk 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +42 -77
- package/_shims/index.d.ts +1 -1
- package/_shims/registry.d.ts +1 -1
- package/_shims/registry.d.ts.map +1 -1
- package/core.d.ts +12 -12
- package/core.d.ts.map +1 -1
- package/core.js +39 -13
- package/core.js.map +1 -1
- package/core.mjs +39 -13
- package/core.mjs.map +1 -1
- package/index.js +4 -4
- package/index.mjs +4 -4
- package/lib/MessageStream.js +2 -2
- package/lib/MessageStream.js.map +1 -1
- package/lib/MessageStream.mjs +2 -2
- package/lib/MessageStream.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/beta/messages.d.ts +15 -31
- package/resources/beta/messages.d.ts.map +1 -1
- package/resources/beta/messages.js +3 -9
- package/resources/beta/messages.js.map +1 -1
- package/resources/beta/messages.mjs +3 -9
- package/resources/beta/messages.mjs.map +1 -1
- package/resources/completions.d.ts +14 -21
- package/resources/completions.d.ts.map +1 -1
- package/resources/completions.js +2 -4
- package/resources/completions.js.map +1 -1
- package/resources/completions.mjs +2 -4
- package/resources/completions.mjs.map +1 -1
- package/src/_shims/index.d.ts +1 -1
- package/src/_shims/node-runtime.ts +1 -1
- package/src/_shims/registry.ts +1 -1
- package/src/_shims/web-runtime.ts +1 -1
- package/src/core.ts +65 -30
- package/src/index.ts +4 -4
- package/src/lib/.keep +4 -0
- package/src/lib/MessageStream.ts +2 -2
- package/src/resources/beta/messages.ts +18 -42
- package/src/resources/completions.ts +16 -26
- package/src/uploads.ts +2 -2
- package/src/version.ts +1 -1
- package/uploads.d.ts +2 -2
- package/uploads.d.ts.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -10,26 +10,24 @@ export class Completions extends APIResource {
|
|
|
10
10
|
/**
|
|
11
11
|
* Create a Completion
|
|
12
12
|
*/
|
|
13
|
-
create(
|
|
13
|
+
create(body: CompletionCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<Completion>;
|
|
14
14
|
create(
|
|
15
|
-
|
|
15
|
+
body: CompletionCreateParamsStreaming,
|
|
16
16
|
options?: Core.RequestOptions,
|
|
17
17
|
): APIPromise<Stream<Completion>>;
|
|
18
18
|
create(
|
|
19
|
-
|
|
19
|
+
body: CompletionCreateParamsBase,
|
|
20
20
|
options?: Core.RequestOptions,
|
|
21
21
|
): APIPromise<Stream<Completion> | Completion>;
|
|
22
22
|
create(
|
|
23
|
-
|
|
23
|
+
body: CompletionCreateParams,
|
|
24
24
|
options?: Core.RequestOptions,
|
|
25
25
|
): APIPromise<Completion> | APIPromise<Stream<Completion>> {
|
|
26
|
-
const { 'x-api-key': xAPIKey, ...body } = params;
|
|
27
26
|
return this._client.post('/v1/complete', {
|
|
28
27
|
body,
|
|
29
28
|
timeout: 600000,
|
|
30
29
|
...options,
|
|
31
|
-
|
|
32
|
-
stream: params.stream ?? false,
|
|
30
|
+
stream: body.stream ?? false,
|
|
33
31
|
}) as APIPromise<Completion> | APIPromise<Stream<Completion>>;
|
|
34
32
|
}
|
|
35
33
|
}
|
|
@@ -70,7 +68,7 @@ export type CompletionCreateParams = CompletionCreateParamsNonStreaming | Comple
|
|
|
70
68
|
|
|
71
69
|
export interface CompletionCreateParamsBase {
|
|
72
70
|
/**
|
|
73
|
-
*
|
|
71
|
+
* The maximum number of tokens to generate before stopping.
|
|
74
72
|
*
|
|
75
73
|
* Note that our models may stop _before_ reaching this maximum. This parameter
|
|
76
74
|
* only specifies the absolute maximum number of tokens to generate.
|
|
@@ -78,7 +76,7 @@ export interface CompletionCreateParamsBase {
|
|
|
78
76
|
max_tokens_to_sample: number;
|
|
79
77
|
|
|
80
78
|
/**
|
|
81
|
-
*
|
|
79
|
+
* The model that will complete your prompt.
|
|
82
80
|
*
|
|
83
81
|
* As we improve Claude, we develop new versions of it that you can query. The
|
|
84
82
|
* `model` parameter controls which version of Claude responds to your request.
|
|
@@ -92,7 +90,7 @@ export interface CompletionCreateParamsBase {
|
|
|
92
90
|
model: (string & {}) | 'claude-2.1' | 'claude-instant-1';
|
|
93
91
|
|
|
94
92
|
/**
|
|
95
|
-
*
|
|
93
|
+
* The prompt that you want Claude to complete.
|
|
96
94
|
*
|
|
97
95
|
* For proper response generation you will need to format your prompt using
|
|
98
96
|
* alternating `\n\nHuman:` and `\n\nAssistant:` conversational turns. For example:
|
|
@@ -110,12 +108,12 @@ export interface CompletionCreateParamsBase {
|
|
|
110
108
|
prompt: string;
|
|
111
109
|
|
|
112
110
|
/**
|
|
113
|
-
*
|
|
111
|
+
* An object describing metadata about the request.
|
|
114
112
|
*/
|
|
115
113
|
metadata?: CompletionCreateParams.Metadata;
|
|
116
114
|
|
|
117
115
|
/**
|
|
118
|
-
*
|
|
116
|
+
* Sequences that will cause the model to stop generating.
|
|
119
117
|
*
|
|
120
118
|
* Our models stop on `"\n\nHuman:"`, and may include additional built-in stop
|
|
121
119
|
* sequences in the future. By providing the stop_sequences parameter, you may
|
|
@@ -124,8 +122,7 @@ export interface CompletionCreateParamsBase {
|
|
|
124
122
|
stop_sequences?: Array<string>;
|
|
125
123
|
|
|
126
124
|
/**
|
|
127
|
-
*
|
|
128
|
-
* events.
|
|
125
|
+
* Whether to incrementally stream the response using server-sent events.
|
|
129
126
|
*
|
|
130
127
|
* See [streaming](https://docs.anthropic.com/claude/reference/streaming) for
|
|
131
128
|
* details.
|
|
@@ -133,7 +130,7 @@ export interface CompletionCreateParamsBase {
|
|
|
133
130
|
stream?: boolean;
|
|
134
131
|
|
|
135
132
|
/**
|
|
136
|
-
*
|
|
133
|
+
* Amount of randomness injected into the response.
|
|
137
134
|
*
|
|
138
135
|
* Defaults to 1. Ranges from 0 to 1. Use temp closer to 0 for analytical /
|
|
139
136
|
* multiple choice, and closer to 1 for creative and generative tasks.
|
|
@@ -141,7 +138,7 @@ export interface CompletionCreateParamsBase {
|
|
|
141
138
|
temperature?: number;
|
|
142
139
|
|
|
143
140
|
/**
|
|
144
|
-
*
|
|
141
|
+
* Only sample from the top K options for each subsequent token.
|
|
145
142
|
*
|
|
146
143
|
* Used to remove "long tail" low probability responses.
|
|
147
144
|
* [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
|
|
@@ -149,7 +146,7 @@ export interface CompletionCreateParamsBase {
|
|
|
149
146
|
top_k?: number;
|
|
150
147
|
|
|
151
148
|
/**
|
|
152
|
-
*
|
|
149
|
+
* Use nucleus sampling.
|
|
153
150
|
*
|
|
154
151
|
* In nucleus sampling, we compute the cumulative distribution over all the options
|
|
155
152
|
* for each subsequent token in decreasing probability order and cut it off once it
|
|
@@ -157,11 +154,6 @@ export interface CompletionCreateParamsBase {
|
|
|
157
154
|
* `temperature` or `top_p`, but not both.
|
|
158
155
|
*/
|
|
159
156
|
top_p?: number;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Header param:
|
|
163
|
-
*/
|
|
164
|
-
'x-api-key'?: string;
|
|
165
157
|
}
|
|
166
158
|
|
|
167
159
|
export namespace CompletionCreateParams {
|
|
@@ -185,8 +177,7 @@ export namespace CompletionCreateParams {
|
|
|
185
177
|
|
|
186
178
|
export interface CompletionCreateParamsNonStreaming extends CompletionCreateParamsBase {
|
|
187
179
|
/**
|
|
188
|
-
*
|
|
189
|
-
* events.
|
|
180
|
+
* Whether to incrementally stream the response using server-sent events.
|
|
190
181
|
*
|
|
191
182
|
* See [streaming](https://docs.anthropic.com/claude/reference/streaming) for
|
|
192
183
|
* details.
|
|
@@ -196,8 +187,7 @@ export interface CompletionCreateParamsNonStreaming extends CompletionCreatePara
|
|
|
196
187
|
|
|
197
188
|
export interface CompletionCreateParamsStreaming extends CompletionCreateParamsBase {
|
|
198
189
|
/**
|
|
199
|
-
*
|
|
200
|
-
* events.
|
|
190
|
+
* Whether to incrementally stream the response using server-sent events.
|
|
201
191
|
*
|
|
202
192
|
* See [streaming](https://docs.anthropic.com/claude/reference/streaming) for
|
|
203
193
|
* details.
|
package/src/uploads.ts
CHANGED
|
@@ -184,7 +184,7 @@ export const isMultipartBody = (body: any): body is MultipartBody =>
|
|
|
184
184
|
* Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
|
|
185
185
|
* Otherwise returns the request as is.
|
|
186
186
|
*/
|
|
187
|
-
export const maybeMultipartFormRequestOptions = async <T
|
|
187
|
+
export const maybeMultipartFormRequestOptions = async <T = Record<string, unknown>>(
|
|
188
188
|
opts: RequestOptions<T>,
|
|
189
189
|
): Promise<RequestOptions<T | MultipartBody>> => {
|
|
190
190
|
if (!hasUploadableValue(opts.body)) return opts;
|
|
@@ -193,7 +193,7 @@ export const maybeMultipartFormRequestOptions = async <T extends {} = Record<str
|
|
|
193
193
|
return getMultipartRequestOptions(form, opts);
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
export const multipartFormRequestOptions = async <T
|
|
196
|
+
export const multipartFormRequestOptions = async <T = Record<string, unknown>>(
|
|
197
197
|
opts: RequestOptions<T>,
|
|
198
198
|
): Promise<RequestOptions<T | MultipartBody>> => {
|
|
199
199
|
const form = await createForm(opts.body);
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.12.1'; // x-release-please-version
|
package/uploads.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export declare const isMultipartBody: (body: any) => body is MultipartBody;
|
|
|
69
69
|
* Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
|
|
70
70
|
* Otherwise returns the request as is.
|
|
71
71
|
*/
|
|
72
|
-
export declare const maybeMultipartFormRequestOptions: <T
|
|
73
|
-
export declare const multipartFormRequestOptions: <T
|
|
72
|
+
export declare const maybeMultipartFormRequestOptions: <T = Record<string, unknown>>(opts: RequestOptions<T>) => Promise<RequestOptions<MultipartBody | T>>;
|
|
73
|
+
export declare const multipartFormRequestOptions: <T = Record<string, unknown>>(opts: RequestOptions<T>) => Promise<RequestOptions<MultipartBody | T>>;
|
|
74
74
|
export declare const createForm: <T = Record<string, unknown>>(body: T | undefined) => Promise<FormData>;
|
|
75
75
|
//# sourceMappingURL=uploads.d.ts.map
|
package/uploads.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploads.d.ts","sourceRoot":"","sources":["src/uploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EACL,QAAQ,EAER,KAAK,IAAI,EACT,KAAK,eAAe,EAEpB,KAAK,YAAY,EAElB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,KAAK,YAAY,GAAG,MAAM,GAAG,WAAW,GAAG,eAAe,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;AAC9F,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,eAAe,GAAG,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE7F;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,6EAA6E;IAC7E,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;CAE/C;AAED;;GAEG;AACH,MAAM,WAAW,QAAS,SAAQ,QAAQ;IACxC,oFAAoF;IACpF,QAAQ,CAAC,YAAY,EAAE,M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,aAAa,CAAC,YAAY,CAAC,CAAC;AAEnG;;;;;;;;GAQG;AACH,wBAAsB,MAAM,CAC1B,KAAK,EAAE,WAAW,GAAG,WAAW,CAAC,WAAW,CAAC,EAC7C,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,OAAO,GAAE,eAAe,GAAG,SAAc,GACxC,OAAO,CAAC,QAAQ,CAAC,CAuBnB;AAmDD,eAAO,MAAM,eAAe,SAAU,GAAG,0BACsD,CAAC;AAEhG;;;GAGG;AACH,eAAO,MAAM,gCAAgC,sGAO5C,CAAC;AAEF,eAAO,MAAM,2BAA2B,sGAKvC,CAAC;AAEF,eAAO,MAAM,UAAU,wDAA6D,QAAQ,QAAQ,CAInG,CAAC"}
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.12.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.12.1'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|