@tanstack/ai-anthropic 0.8.4 → 0.8.6
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/dist/esm/utils/client.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Anthropic_SDK from "@anthropic-ai/sdk";
|
|
2
|
+
import { generateId as generateId$1, getApiKeyFromEnv } from "@tanstack/ai-utils";
|
|
2
3
|
function createAnthropicClient(config) {
|
|
3
4
|
return new Anthropic_SDK({
|
|
4
5
|
...config,
|
|
@@ -6,17 +7,10 @@ function createAnthropicClient(config) {
|
|
|
6
7
|
});
|
|
7
8
|
}
|
|
8
9
|
function getAnthropicApiKeyFromEnv() {
|
|
9
|
-
|
|
10
|
-
const key = env?.ANTHROPIC_API_KEY;
|
|
11
|
-
if (!key) {
|
|
12
|
-
throw new Error(
|
|
13
|
-
"ANTHROPIC_API_KEY is required. Please set it in your environment variables or use the factory function with an explicit API key."
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
return key;
|
|
10
|
+
return getApiKeyFromEnv("ANTHROPIC_API_KEY");
|
|
17
11
|
}
|
|
18
12
|
function generateId(prefix) {
|
|
19
|
-
return
|
|
13
|
+
return generateId$1(prefix);
|
|
20
14
|
}
|
|
21
15
|
export {
|
|
22
16
|
createAnthropicClient,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../../src/utils/client.ts"],"sourcesContent":["import Anthropic_SDK from '@anthropic-ai/sdk'\nimport type { ClientOptions } from '@anthropic-ai/sdk'\n\nexport interface AnthropicClientConfig extends ClientOptions {\n apiKey: string\n}\n\n/**\n * Creates an Anthropic SDK client instance\n */\nexport function createAnthropicClient(\n config: AnthropicClientConfig,\n): Anthropic_SDK {\n return new Anthropic_SDK({\n ...config,\n apiKey: config.apiKey,\n })\n}\n\n/**\n * Gets Anthropic API key from environment variables\n * @throws Error if ANTHROPIC_API_KEY is not found\n */\nexport function getAnthropicApiKeyFromEnv(): string {\n
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../../src/utils/client.ts"],"sourcesContent":["import Anthropic_SDK from '@anthropic-ai/sdk'\nimport { generateId as _generateId, getApiKeyFromEnv } from '@tanstack/ai-utils'\nimport type { ClientOptions } from '@anthropic-ai/sdk'\n\nexport interface AnthropicClientConfig extends ClientOptions {\n apiKey: string\n}\n\n/**\n * Creates an Anthropic SDK client instance\n */\nexport function createAnthropicClient(\n config: AnthropicClientConfig,\n): Anthropic_SDK {\n return new Anthropic_SDK({\n ...config,\n apiKey: config.apiKey,\n })\n}\n\n/**\n * Gets Anthropic API key from environment variables\n * @throws Error if ANTHROPIC_API_KEY is not found\n */\nexport function getAnthropicApiKeyFromEnv(): string {\n return getApiKeyFromEnv('ANTHROPIC_API_KEY')\n}\n\n/**\n * Generates a unique ID with a prefix\n */\nexport function generateId(prefix: string): string {\n return _generateId(prefix)\n}\n"],"names":["_generateId"],"mappings":";;AAWO,SAAS,sBACd,QACe;AACf,SAAO,IAAI,cAAc;AAAA,IACvB,GAAG;AAAA,IACH,QAAQ,OAAO;AAAA,EAAA,CAChB;AACH;AAMO,SAAS,4BAAoC;AAClD,SAAO,iBAAiB,mBAAmB;AAC7C;AAKO,SAAS,WAAW,QAAwB;AACjD,SAAOA,aAAY,MAAM;AAC3B;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ai-anthropic",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"description": "Anthropic Claude adapter for TanStack AI",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,16 +34,17 @@
|
|
|
34
34
|
"src"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@anthropic-ai/sdk": "^0.71.2"
|
|
37
|
+
"@anthropic-ai/sdk": "^0.71.2",
|
|
38
|
+
"@tanstack/ai-utils": "0.2.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"zod": "^4.0.0",
|
|
41
|
-
"@tanstack/ai": "^0.
|
|
42
|
+
"@tanstack/ai": "^0.16.0"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@vitest/coverage-v8": "4.0.14",
|
|
45
46
|
"zod": "^4.2.0",
|
|
46
|
-
"@tanstack/ai": "0.
|
|
47
|
+
"@tanstack/ai": "0.16.0"
|
|
47
48
|
},
|
|
48
49
|
"scripts": {
|
|
49
50
|
"build": "vite build",
|
package/src/utils/client.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Anthropic_SDK from '@anthropic-ai/sdk'
|
|
2
|
+
import { generateId as _generateId, getApiKeyFromEnv } from '@tanstack/ai-utils'
|
|
2
3
|
import type { ClientOptions } from '@anthropic-ai/sdk'
|
|
3
4
|
|
|
4
5
|
export interface AnthropicClientConfig extends ClientOptions {
|
|
@@ -22,26 +23,12 @@ export function createAnthropicClient(
|
|
|
22
23
|
* @throws Error if ANTHROPIC_API_KEY is not found
|
|
23
24
|
*/
|
|
24
25
|
export function getAnthropicApiKeyFromEnv(): string {
|
|
25
|
-
|
|
26
|
-
typeof globalThis !== 'undefined' && (globalThis as any).window?.env
|
|
27
|
-
? (globalThis as any).window.env
|
|
28
|
-
: typeof process !== 'undefined'
|
|
29
|
-
? process.env
|
|
30
|
-
: undefined
|
|
31
|
-
const key = env?.ANTHROPIC_API_KEY
|
|
32
|
-
|
|
33
|
-
if (!key) {
|
|
34
|
-
throw new Error(
|
|
35
|
-
'ANTHROPIC_API_KEY is required. Please set it in your environment variables or use the factory function with an explicit API key.',
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return key
|
|
26
|
+
return getApiKeyFromEnv('ANTHROPIC_API_KEY')
|
|
40
27
|
}
|
|
41
28
|
|
|
42
29
|
/**
|
|
43
30
|
* Generates a unique ID with a prefix
|
|
44
31
|
*/
|
|
45
32
|
export function generateId(prefix: string): string {
|
|
46
|
-
return
|
|
33
|
+
return _generateId(prefix)
|
|
47
34
|
}
|