@myapihq/sdk 2.20.1 → 2.21.0
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/llm.d.ts +20 -0
- package/dist/llm.js +20 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/llm.d.ts
CHANGED
|
@@ -11,11 +11,13 @@ export interface CompleteRequest {
|
|
|
11
11
|
max_tokens?: number;
|
|
12
12
|
temperature?: number;
|
|
13
13
|
stop?: string[];
|
|
14
|
+
cache_id?: string;
|
|
14
15
|
}
|
|
15
16
|
export interface RawUsage {
|
|
16
17
|
input_tokens: number;
|
|
17
18
|
output_tokens?: number;
|
|
18
19
|
cost_cents: number;
|
|
20
|
+
cached_input_tokens?: number;
|
|
19
21
|
}
|
|
20
22
|
export interface CompleteResponse {
|
|
21
23
|
model: string;
|
|
@@ -46,6 +48,24 @@ export interface ModelsResponse {
|
|
|
46
48
|
export declare function complete(apiKey: string, orgId: string, req: CompleteRequest): Promise<CompleteResponse>;
|
|
47
49
|
export declare function embed(apiKey: string, orgId: string, req: EmbedRequest): Promise<EmbedResponse>;
|
|
48
50
|
export declare function listModels(apiKey: string, orgId: string): Promise<ModelsResponse>;
|
|
51
|
+
export interface CreateCacheRequest {
|
|
52
|
+
model: string;
|
|
53
|
+
content: string;
|
|
54
|
+
ttl_seconds?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface Cache {
|
|
57
|
+
id: string;
|
|
58
|
+
model: string;
|
|
59
|
+
tokens: number;
|
|
60
|
+
expires_at: string;
|
|
61
|
+
}
|
|
62
|
+
export interface CachesResponse {
|
|
63
|
+
caches: Cache[];
|
|
64
|
+
total: number;
|
|
65
|
+
}
|
|
66
|
+
export declare function createCache(apiKey: string, orgId: string, req: CreateCacheRequest): Promise<Cache>;
|
|
67
|
+
export declare function listCaches(apiKey: string, orgId: string): Promise<CachesResponse>;
|
|
68
|
+
export declare function deleteCache(apiKey: string, orgId: string, id: string): Promise<void>;
|
|
49
69
|
export type Verb = 'classify' | 'extract' | 'summarize' | 'draft';
|
|
50
70
|
/** Routing hint; opaque — the server picks the model. With one served
|
|
51
71
|
* model today every tier resolves to it. `tier_used` echoes back what was
|
package/dist/llm.js
CHANGED
|
@@ -9,6 +9,9 @@ exports.EXPOSES = void 0;
|
|
|
9
9
|
exports.complete = complete;
|
|
10
10
|
exports.embed = embed;
|
|
11
11
|
exports.listModels = listModels;
|
|
12
|
+
exports.createCache = createCache;
|
|
13
|
+
exports.listCaches = listCaches;
|
|
14
|
+
exports.deleteCache = deleteCache;
|
|
12
15
|
exports.classify = classify;
|
|
13
16
|
exports.extract = extract;
|
|
14
17
|
exports.summarize = summarize;
|
|
@@ -20,6 +23,9 @@ exports.EXPOSES = [
|
|
|
20
23
|
'POST /llm/orgs/{org_id}/embed',
|
|
21
24
|
'GET /llm/orgs/{org_id}/models',
|
|
22
25
|
'POST /llm/orgs/{org_id}/tasks/{verb}',
|
|
26
|
+
'POST /llm/orgs/{org_id}/caches',
|
|
27
|
+
'GET /llm/orgs/{org_id}/caches',
|
|
28
|
+
'DELETE /llm/orgs/{org_id}/caches/{id}',
|
|
23
29
|
];
|
|
24
30
|
async function complete(apiKey, orgId, req) {
|
|
25
31
|
return (0, client_1.request)('POST', `${config_1.LLM_BASE}/llm/orgs/${encodeURIComponent(orgId)}/complete`, apiKey, req);
|
|
@@ -30,6 +36,20 @@ async function embed(apiKey, orgId, req) {
|
|
|
30
36
|
async function listModels(apiKey, orgId) {
|
|
31
37
|
return (0, client_1.request)('GET', `${config_1.LLM_BASE}/llm/orgs/${encodeURIComponent(orgId)}/models`, apiKey);
|
|
32
38
|
}
|
|
39
|
+
function cachesUrl(orgId) {
|
|
40
|
+
return `${config_1.LLM_BASE}/llm/orgs/${encodeURIComponent(orgId)}/caches`;
|
|
41
|
+
}
|
|
42
|
+
async function createCache(apiKey, orgId, req) {
|
|
43
|
+
return (0, client_1.request)('POST', cachesUrl(orgId), apiKey, req);
|
|
44
|
+
}
|
|
45
|
+
// Expired caches are not listed — the list is what you are currently paying
|
|
46
|
+
// for, which is the only question worth asking of it.
|
|
47
|
+
async function listCaches(apiKey, orgId) {
|
|
48
|
+
return (0, client_1.request)('GET', cachesUrl(orgId), apiKey);
|
|
49
|
+
}
|
|
50
|
+
async function deleteCache(apiKey, orgId, id) {
|
|
51
|
+
return (0, client_1.request)('DELETE', `${cachesUrl(orgId)}/${encodeURIComponent(id)}`, apiKey);
|
|
52
|
+
}
|
|
33
53
|
function verbUrl(orgId, verb) {
|
|
34
54
|
return `${config_1.LLM_BASE}/llm/orgs/${encodeURIComponent(orgId)}/tasks/${verb}`;
|
|
35
55
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.
|
|
1
|
+
export declare const SDK_VERSION = "2.21.0";
|
package/dist/version.js
CHANGED
|
@@ -8,4 +8,4 @@ exports.SDK_VERSION = void 0;
|
|
|
8
8
|
// Why a constant and not a package.json read: the SDK runs inside edge
|
|
9
9
|
// functions (Cloudflare Workers), so it must not import node:fs. A literal
|
|
10
10
|
// is the only version source that works in every runtime we ship to.
|
|
11
|
-
exports.SDK_VERSION = '2.
|
|
11
|
+
exports.SDK_VERSION = '2.21.0';
|