@smarter.sh/api 0.0.0-stage → 1.0.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/LICENSE.txt +671 -0
- package/README.md +193 -2
- package/dist/client.d.ts +146 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +178 -0
- package/dist/client.js.map +1 -0
- package/dist/core/config.d.ts +148 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +212 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/errors.d.ts +189 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +187 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/http.d.ts +207 -0
- package/dist/core/http.d.ts.map +1 -0
- package/dist/core/http.js +456 -0
- package/dist/core/http.js.map +1 -0
- package/dist/core/log.d.ts +62 -0
- package/dist/core/log.d.ts.map +1 -0
- package/dist/core/log.js +68 -0
- package/dist/core/log.js.map +1 -0
- package/dist/core/sse.d.ts +38 -0
- package/dist/core/sse.d.ts.map +1 -0
- package/dist/core/sse.js +79 -0
- package/dist/core/sse.js.map +1 -0
- package/dist/core/typing.d.ts +21 -0
- package/dist/core/typing.d.ts.map +1 -0
- package/dist/core/typing.js +13 -0
- package/dist/core/typing.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/models/account.d.ts +112 -0
- package/dist/models/account.d.ts.map +1 -0
- package/dist/models/account.js +55 -0
- package/dist/models/account.js.map +1 -0
- package/dist/models/base.d.ts +99 -0
- package/dist/models/base.d.ts.map +1 -0
- package/dist/models/base.js +111 -0
- package/dist/models/base.js.map +1 -0
- package/dist/models/chat.d.ts +2243 -0
- package/dist/models/chat.d.ts.map +1 -0
- package/dist/models/chat.js +451 -0
- package/dist/models/chat.js.map +1 -0
- package/dist/models/guardrail.d.ts +109 -0
- package/dist/models/guardrail.d.ts.map +1 -0
- package/dist/models/guardrail.js +68 -0
- package/dist/models/guardrail.js.map +1 -0
- package/dist/models/journal.d.ts +159 -0
- package/dist/models/journal.d.ts.map +1 -0
- package/dist/models/journal.js +115 -0
- package/dist/models/journal.js.map +1 -0
- package/dist/models/llmclient.d.ts +183 -0
- package/dist/models/llmclient.d.ts.map +1 -0
- package/dist/models/llmclient.js +105 -0
- package/dist/models/llmclient.js.map +1 -0
- package/dist/models/llmhost.d.ts +121 -0
- package/dist/models/llmhost.d.ts.map +1 -0
- package/dist/models/llmhost.js +79 -0
- package/dist/models/llmhost.js.map +1 -0
- package/dist/models/manifest.d.ts +211 -0
- package/dist/models/manifest.d.ts.map +1 -0
- package/dist/models/manifest.js +290 -0
- package/dist/models/manifest.js.map +1 -0
- package/dist/models/mcpclient.d.ts +99 -0
- package/dist/models/mcpclient.d.ts.map +1 -0
- package/dist/models/mcpclient.js +65 -0
- package/dist/models/mcpclient.js.map +1 -0
- package/dist/models/misc.d.ts +232 -0
- package/dist/models/misc.d.ts.map +1 -0
- package/dist/models/misc.js +110 -0
- package/dist/models/misc.js.map +1 -0
- package/dist/models/platform.d.ts +88 -0
- package/dist/models/platform.d.ts.map +1 -0
- package/dist/models/platform.js +35 -0
- package/dist/models/platform.js.map +1 -0
- package/dist/models/plugin.d.ts +36 -0
- package/dist/models/plugin.d.ts.map +1 -0
- package/dist/models/plugin.js +16 -0
- package/dist/models/plugin.js.map +1 -0
- package/dist/models/react.d.ts +104 -0
- package/dist/models/react.d.ts.map +1 -0
- package/dist/models/react.js +136 -0
- package/dist/models/react.js.map +1 -0
- package/dist/models/sam/account.d.ts +155 -0
- package/dist/models/sam/account.d.ts.map +1 -0
- package/dist/models/sam/account.js +7 -0
- package/dist/models/sam/account.js.map +1 -0
- package/dist/models/sam/apiconnection.d.ts +147 -0
- package/dist/models/sam/apiconnection.d.ts.map +1 -0
- package/dist/models/sam/apiconnection.js +7 -0
- package/dist/models/sam/apiconnection.js.map +1 -0
- package/dist/models/sam/apiplugin.d.ts +278 -0
- package/dist/models/sam/apiplugin.d.ts.map +1 -0
- package/dist/models/sam/apiplugin.js +7 -0
- package/dist/models/sam/apiplugin.js.map +1 -0
- package/dist/models/sam/budget.d.ts +219 -0
- package/dist/models/sam/budget.d.ts.map +1 -0
- package/dist/models/sam/budget.js +7 -0
- package/dist/models/sam/budget.js.map +1 -0
- package/dist/models/sam/customdomain.d.ts +139 -0
- package/dist/models/sam/customdomain.d.ts.map +1 -0
- package/dist/models/sam/customdomain.js +7 -0
- package/dist/models/sam/customdomain.js.map +1 -0
- package/dist/models/sam/guardrail.d.ts +222 -0
- package/dist/models/sam/guardrail.d.ts.map +1 -0
- package/dist/models/sam/guardrail.js +7 -0
- package/dist/models/sam/guardrail.js.map +1 -0
- package/dist/models/sam/imagesearchplugin.d.ts +235 -0
- package/dist/models/sam/imagesearchplugin.d.ts.map +1 -0
- package/dist/models/sam/imagesearchplugin.js +7 -0
- package/dist/models/sam/imagesearchplugin.js.map +1 -0
- package/dist/models/sam/index.d.ts +104 -0
- package/dist/models/sam/index.d.ts.map +1 -0
- package/dist/models/sam/index.js +50 -0
- package/dist/models/sam/index.js.map +1 -0
- package/dist/models/sam/llmclient.d.ts +490 -0
- package/dist/models/sam/llmclient.d.ts.map +1 -0
- package/dist/models/sam/llmclient.js +7 -0
- package/dist/models/sam/llmclient.js.map +1 -0
- package/dist/models/sam/llmhost.d.ts +429 -0
- package/dist/models/sam/llmhost.d.ts.map +1 -0
- package/dist/models/sam/llmhost.js +7 -0
- package/dist/models/sam/llmhost.js.map +1 -0
- package/dist/models/sam/llmhostcompute.d.ts +221 -0
- package/dist/models/sam/llmhostcompute.d.ts.map +1 -0
- package/dist/models/sam/llmhostcompute.js +7 -0
- package/dist/models/sam/llmhostcompute.js.map +1 -0
- package/dist/models/sam/mcpclient.d.ts +195 -0
- package/dist/models/sam/mcpclient.d.ts.map +1 -0
- package/dist/models/sam/mcpclient.js +7 -0
- package/dist/models/sam/mcpclient.js.map +1 -0
- package/dist/models/sam/orchestrator.d.ts +163 -0
- package/dist/models/sam/orchestrator.d.ts.map +1 -0
- package/dist/models/sam/orchestrator.js +7 -0
- package/dist/models/sam/orchestrator.js.map +1 -0
- package/dist/models/sam/plugin.d.ts +163 -0
- package/dist/models/sam/plugin.d.ts.map +1 -0
- package/dist/models/sam/plugin.js +7 -0
- package/dist/models/sam/plugin.js.map +1 -0
- package/dist/models/sam/prompt.d.ts +116 -0
- package/dist/models/sam/prompt.d.ts.map +1 -0
- package/dist/models/sam/prompt.js +7 -0
- package/dist/models/sam/prompt.js.map +1 -0
- package/dist/models/sam/provider.d.ts +195 -0
- package/dist/models/sam/provider.d.ts.map +1 -0
- package/dist/models/sam/provider.js +7 -0
- package/dist/models/sam/provider.js.map +1 -0
- package/dist/models/sam/proxy.d.ts +163 -0
- package/dist/models/sam/proxy.d.ts.map +1 -0
- package/dist/models/sam/proxy.js +7 -0
- package/dist/models/sam/proxy.js.map +1 -0
- package/dist/models/sam/schemas.d.ts +8 -0
- package/dist/models/sam/schemas.d.ts.map +1 -0
- package/dist/models/sam/schemas.js +6059 -0
- package/dist/models/sam/schemas.js.map +1 -0
- package/dist/models/sam/secret.d.ts +123 -0
- package/dist/models/sam/secret.d.ts.map +1 -0
- package/dist/models/sam/secret.js +7 -0
- package/dist/models/sam/secret.js.map +1 -0
- package/dist/models/sam/skillplugin.d.ts +181 -0
- package/dist/models/sam/skillplugin.d.ts.map +1 -0
- package/dist/models/sam/skillplugin.js +7 -0
- package/dist/models/sam/skillplugin.js.map +1 -0
- package/dist/models/sam/smarterauthtoken.d.ts +115 -0
- package/dist/models/sam/smarterauthtoken.d.ts.map +1 -0
- package/dist/models/sam/smarterauthtoken.js +7 -0
- package/dist/models/sam/smarterauthtoken.js.map +1 -0
- package/dist/models/sam/sqlconnection.d.ts +187 -0
- package/dist/models/sam/sqlconnection.d.ts.map +1 -0
- package/dist/models/sam/sqlconnection.js +7 -0
- package/dist/models/sam/sqlconnection.js.map +1 -0
- package/dist/models/sam/sqlplugin.d.ts +232 -0
- package/dist/models/sam/sqlplugin.d.ts.map +1 -0
- package/dist/models/sam/sqlplugin.js +7 -0
- package/dist/models/sam/sqlplugin.js.map +1 -0
- package/dist/models/sam/user.d.ts +135 -0
- package/dist/models/sam/user.d.ts.map +1 -0
- package/dist/models/sam/user.js +7 -0
- package/dist/models/sam/user.js.map +1 -0
- package/dist/models/sam/vectorsearch.d.ts +150 -0
- package/dist/models/sam/vectorsearch.d.ts.map +1 -0
- package/dist/models/sam/vectorsearch.js +7 -0
- package/dist/models/sam/vectorsearch.js.map +1 -0
- package/dist/models/sam/vectorstore.d.ts +291 -0
- package/dist/models/sam/vectorstore.d.ts.map +1 -0
- package/dist/models/sam/vectorstore.js +7 -0
- package/dist/models/sam/vectorstore.js.map +1 -0
- package/dist/models/sam/websearchplugin.d.ts +229 -0
- package/dist/models/sam/websearchplugin.d.ts.map +1 -0
- package/dist/models/sam/websearchplugin.js +7 -0
- package/dist/models/sam/websearchplugin.js.map +1 -0
- package/dist/models/vectorstore.d.ts +165 -0
- package/dist/models/vectorstore.d.ts.map +1 -0
- package/dist/models/vectorstore.js +90 -0
- package/dist/models/vectorstore.js.map +1 -0
- package/dist/resources/accounts.d.ts +107 -0
- package/dist/resources/accounts.d.ts.map +1 -0
- package/dist/resources/accounts.js +84 -0
- package/dist/resources/accounts.js.map +1 -0
- package/dist/resources/base.d.ts +127 -0
- package/dist/resources/base.d.ts.map +1 -0
- package/dist/resources/base.js +139 -0
- package/dist/resources/base.js.map +1 -0
- package/dist/resources/catalog.d.ts +209 -0
- package/dist/resources/catalog.d.ts.map +1 -0
- package/dist/resources/catalog.js +124 -0
- package/dist/resources/catalog.js.map +1 -0
- package/dist/resources/guardrails.d.ts +82 -0
- package/dist/resources/guardrails.d.ts.map +1 -0
- package/dist/resources/guardrails.js +46 -0
- package/dist/resources/guardrails.js.map +1 -0
- package/dist/resources/history.d.ts +97 -0
- package/dist/resources/history.d.ts.map +1 -0
- package/dist/resources/history.js +109 -0
- package/dist/resources/history.js.map +1 -0
- package/dist/resources/llmclients.d.ts +348 -0
- package/dist/resources/llmclients.d.ts.map +1 -0
- package/dist/resources/llmclients.js +367 -0
- package/dist/resources/llmclients.js.map +1 -0
- package/dist/resources/llmhosts.d.ts +146 -0
- package/dist/resources/llmhosts.d.ts.map +1 -0
- package/dist/resources/llmhosts.js +128 -0
- package/dist/resources/llmhosts.js.map +1 -0
- package/dist/resources/manifests.d.ts +153 -0
- package/dist/resources/manifests.d.ts.map +1 -0
- package/dist/resources/manifests.js +203 -0
- package/dist/resources/manifests.js.map +1 -0
- package/dist/resources/mcpclients.d.ts +90 -0
- package/dist/resources/mcpclients.d.ts.map +1 -0
- package/dist/resources/mcpclients.js +57 -0
- package/dist/resources/mcpclients.js.map +1 -0
- package/dist/resources/providers.d.ts +33 -0
- package/dist/resources/providers.d.ts.map +1 -0
- package/dist/resources/providers.js +39 -0
- package/dist/resources/providers.js.map +1 -0
- package/dist/resources/proxies.d.ts +61 -0
- package/dist/resources/proxies.d.ts.map +1 -0
- package/dist/resources/proxies.js +57 -0
- package/dist/resources/proxies.js.map +1 -0
- package/dist/resources/vectorstores.d.ts +194 -0
- package/dist/resources/vectorstores.d.ts.map +1 -0
- package/dist/resources/vectorstores.js +200 -0
- package/dist/resources/vectorstores.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +81 -4
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** The history of chat sessions, tool calls and plugin uses: `/api/v1/prompts/history/`, and the Smarter Journal. */
|
|
2
|
+
import type { RequestOptions } from "../core/http.ts";
|
|
3
|
+
import type { SmarterId } from "../core/typing.ts";
|
|
4
|
+
import { JournalEntry, JournalPage } from "../models/journal.ts";
|
|
5
|
+
import { PromptPluginUsage, PromptSession, PromptToolCall } from "../models/misc.ts";
|
|
6
|
+
import { SmarterAPIResource } from "./base.ts";
|
|
7
|
+
/**
|
|
8
|
+
* The chat sessions of the api key's user, and their tool calls and plugin uses, newest first.
|
|
9
|
+
*
|
|
10
|
+
* An account admin also reads the sessions of their account's users, and a superuser every session.
|
|
11
|
+
*/
|
|
12
|
+
export declare class PromptHistory extends SmarterAPIResource {
|
|
13
|
+
/** The history's endpoint. */
|
|
14
|
+
readonly path = "prompts/history/";
|
|
15
|
+
/**
|
|
16
|
+
* The chat sessions.
|
|
17
|
+
*
|
|
18
|
+
* @param options - Per-request options.
|
|
19
|
+
* @returns The sessions.
|
|
20
|
+
*/
|
|
21
|
+
sessions(options?: RequestOptions): Promise<PromptSession[]>;
|
|
22
|
+
/**
|
|
23
|
+
* A chat session, by id.
|
|
24
|
+
*
|
|
25
|
+
* @param id - The session's id.
|
|
26
|
+
* @param options - Per-request options.
|
|
27
|
+
* @returns The session.
|
|
28
|
+
*/
|
|
29
|
+
session(id: SmarterId, options?: RequestOptions): Promise<PromptSession>;
|
|
30
|
+
/**
|
|
31
|
+
* The tool calls of the chat sessions, with the LLM requests that made them.
|
|
32
|
+
*
|
|
33
|
+
* @param options - Per-request options.
|
|
34
|
+
* @returns The tool calls.
|
|
35
|
+
*/
|
|
36
|
+
toolCalls(options?: RequestOptions): Promise<PromptToolCall[]>;
|
|
37
|
+
/**
|
|
38
|
+
* A tool call, by id.
|
|
39
|
+
*
|
|
40
|
+
* @param id - The tool call's id.
|
|
41
|
+
* @param options - Per-request options.
|
|
42
|
+
* @returns The tool call.
|
|
43
|
+
*/
|
|
44
|
+
toolCall(id: SmarterId, options?: RequestOptions): Promise<PromptToolCall>;
|
|
45
|
+
/**
|
|
46
|
+
* The plugin uses of the chat sessions.
|
|
47
|
+
*
|
|
48
|
+
* @param options - Per-request options.
|
|
49
|
+
* @returns The plugin uses.
|
|
50
|
+
*/
|
|
51
|
+
pluginUsage(options?: RequestOptions): Promise<PromptPluginUsage[]>;
|
|
52
|
+
/**
|
|
53
|
+
* A plugin use, by id.
|
|
54
|
+
*
|
|
55
|
+
* @param id - The plugin use's id.
|
|
56
|
+
* @param options - Per-request options.
|
|
57
|
+
* @returns The plugin use.
|
|
58
|
+
*/
|
|
59
|
+
pluginUse(id: SmarterId, options?: RequestOptions): Promise<PromptPluginUsage>;
|
|
60
|
+
}
|
|
61
|
+
/** The options of a page of the journal, beside the per-request options. */
|
|
62
|
+
export interface JournalListOptions extends RequestOptions {
|
|
63
|
+
/** The page number, from 1. */
|
|
64
|
+
page?: number;
|
|
65
|
+
/** Entries per page, or none for the platform's default. */
|
|
66
|
+
pageSize?: number | null;
|
|
67
|
+
/** Only entries whose key, thing or command contains this text. */
|
|
68
|
+
search?: string | null;
|
|
69
|
+
/** A sort field, e.g. `createdAt` or `-statusCode`. */
|
|
70
|
+
ordering?: string | null;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The Smarter Journal: a record of every journaled api request and response. Superusers only.
|
|
74
|
+
*
|
|
75
|
+
* Each entry's request document holds the caller's headers, including their api key, so only
|
|
76
|
+
* superusers may read the journal.
|
|
77
|
+
*/
|
|
78
|
+
export declare class Journal extends SmarterAPIResource {
|
|
79
|
+
/** The journal's endpoint. */
|
|
80
|
+
readonly path = "journal/";
|
|
81
|
+
/**
|
|
82
|
+
* One page of the journal's entries, newest first, without their request and response documents.
|
|
83
|
+
*
|
|
84
|
+
* @param options - `page`, `pageSize`, `search` and `ordering`.
|
|
85
|
+
* @returns The page, and its pagination.
|
|
86
|
+
*/
|
|
87
|
+
list(options?: JournalListOptions): Promise<JournalPage>;
|
|
88
|
+
/**
|
|
89
|
+
* A journal entry, with its request and response documents.
|
|
90
|
+
*
|
|
91
|
+
* @param key - The entry's key: the `metadata.key` of a journaled response.
|
|
92
|
+
* @param options - Per-request options.
|
|
93
|
+
* @returns The entry.
|
|
94
|
+
*/
|
|
95
|
+
retrieve(key: string, options?: RequestOptions): Promise<JournalEntry>;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0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AAC,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;;;GAKG;AACH,qBAAa,OAAQ,SAAQ,kBAAkB;IAC7C,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,cAAc;IAE3B;;;;;OAKG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAY9D;;;;;;OAMG;IACG,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;CAG7E"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/** The history of chat sessions, tool calls and plugin uses: `/api/v1/prompts/history/`, and the Smarter Journal. */
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { JournalEntry, JournalPage } from "../models/journal.js";
|
|
4
|
+
import { PromptPluginUsage, PromptSession, PromptToolCall } from "../models/misc.js";
|
|
5
|
+
import { resourceId, SmarterAPIResource } from "./base.js";
|
|
6
|
+
/**
|
|
7
|
+
* The chat sessions of the api key's user, and their tool calls and plugin uses, newest first.
|
|
8
|
+
*
|
|
9
|
+
* An account admin also reads the sessions of their account's users, and a superuser every session.
|
|
10
|
+
*/
|
|
11
|
+
export class PromptHistory extends SmarterAPIResource {
|
|
12
|
+
/** The history's endpoint. */
|
|
13
|
+
path = "prompts/history/";
|
|
14
|
+
/**
|
|
15
|
+
* The chat sessions.
|
|
16
|
+
*
|
|
17
|
+
* @param options - Per-request options.
|
|
18
|
+
* @returns The sessions.
|
|
19
|
+
*/
|
|
20
|
+
async sessions(options) {
|
|
21
|
+
return this.http.request("GET", `${this.path}prompt/`, z.array(PromptSession), options);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A chat session, by id.
|
|
25
|
+
*
|
|
26
|
+
* @param id - The session's id.
|
|
27
|
+
* @param options - Per-request options.
|
|
28
|
+
* @returns The session.
|
|
29
|
+
*/
|
|
30
|
+
async session(id, options) {
|
|
31
|
+
return this.http.request("GET", `${this.path}prompt/${resourceId(id)}/`, PromptSession, options);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The tool calls of the chat sessions, with the LLM requests that made them.
|
|
35
|
+
*
|
|
36
|
+
* @param options - Per-request options.
|
|
37
|
+
* @returns The tool calls.
|
|
38
|
+
*/
|
|
39
|
+
async toolCalls(options) {
|
|
40
|
+
return this.http.request("GET", `${this.path}tool-calls/`, z.array(PromptToolCall), options);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A tool call, by id.
|
|
44
|
+
*
|
|
45
|
+
* @param id - The tool call's id.
|
|
46
|
+
* @param options - Per-request options.
|
|
47
|
+
* @returns The tool call.
|
|
48
|
+
*/
|
|
49
|
+
async toolCall(id, options) {
|
|
50
|
+
return this.http.request("GET", `${this.path}tool-calls/${resourceId(id)}/`, PromptToolCall, options);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The plugin uses of the chat sessions.
|
|
54
|
+
*
|
|
55
|
+
* @param options - Per-request options.
|
|
56
|
+
* @returns The plugin uses.
|
|
57
|
+
*/
|
|
58
|
+
async pluginUsage(options) {
|
|
59
|
+
return this.http.request("GET", `${this.path}plugin-usage/`, z.array(PromptPluginUsage), options);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A plugin use, by id.
|
|
63
|
+
*
|
|
64
|
+
* @param id - The plugin use's id.
|
|
65
|
+
* @param options - Per-request options.
|
|
66
|
+
* @returns The plugin use.
|
|
67
|
+
*/
|
|
68
|
+
async pluginUse(id, options) {
|
|
69
|
+
return this.http.request("GET", `${this.path}plugin-usage/${resourceId(id)}/`, PromptPluginUsage, options);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The Smarter Journal: a record of every journaled api request and response. Superusers only.
|
|
74
|
+
*
|
|
75
|
+
* Each entry's request document holds the caller's headers, including their api key, so only
|
|
76
|
+
* superusers may read the journal.
|
|
77
|
+
*/
|
|
78
|
+
export class Journal extends SmarterAPIResource {
|
|
79
|
+
/** The journal's endpoint. */
|
|
80
|
+
path = "journal/";
|
|
81
|
+
/**
|
|
82
|
+
* One page of the journal's entries, newest first, without their request and response documents.
|
|
83
|
+
*
|
|
84
|
+
* @param options - `page`, `pageSize`, `search` and `ordering`.
|
|
85
|
+
* @returns The page, and its pagination.
|
|
86
|
+
*/
|
|
87
|
+
async list(options) {
|
|
88
|
+
return this.http.request("GET", this.path, JournalPage, {
|
|
89
|
+
...options,
|
|
90
|
+
params: {
|
|
91
|
+
page: options?.page ?? 1,
|
|
92
|
+
page_size: options?.pageSize,
|
|
93
|
+
search: options?.search,
|
|
94
|
+
ordering: options?.ordering,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A journal entry, with its request and response documents.
|
|
100
|
+
*
|
|
101
|
+
* @param key - The entry's key: the `metadata.key` of a journaled response.
|
|
102
|
+
* @param options - Per-request options.
|
|
103
|
+
* @returns The entry.
|
|
104
|
+
*/
|
|
105
|
+
async retrieve(key, options) {
|
|
106
|
+
return this.http.request("GET", `${this.path}${resourceId(key)}/`, JournalEntry, options);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/resources/history.ts"],"names":[],"mappings":"AAAA,qHAAqH;AAErH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,iBAAiB,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
|
+
* ```ts
|
|
6
|
+
* import { Smarter } from "@smarter.sh/api";
|
|
7
|
+
*
|
|
8
|
+
* const client = new Smarter();
|
|
9
|
+
* const llmclient = await client.llmClients.find("calculator");
|
|
10
|
+
*
|
|
11
|
+
* // one prompt
|
|
12
|
+
* const response = await client.llmClients.prompt(llmclient.id, "What is 17 times 23?");
|
|
13
|
+
* console.log(response.text);
|
|
14
|
+
*
|
|
15
|
+
* // a conversation, which keeps its session and thread
|
|
16
|
+
* const chat = await client.llmClients.chat(llmclient.id);
|
|
17
|
+
* console.log((await chat.send("What is 2 to the 10th power?")).text);
|
|
18
|
+
* console.log((await chat.send("And divided by 4?")).text);
|
|
19
|
+
*
|
|
20
|
+
* // the prompt's progress, e.g. its tool calls, while it runs
|
|
21
|
+
* const stream = client.llmClients.stream(llmclient.id, "What is sin(pi / 2)?");
|
|
22
|
+
* for await (const event of stream) console.log(event.message);
|
|
23
|
+
* console.log(stream.response.text);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import { z } from "zod";
|
|
27
|
+
import type { RequestOptions } from "../core/http.ts";
|
|
28
|
+
import type { ServerSentEvent } from "../core/sse.ts";
|
|
29
|
+
import type { JsonValue, SmarterId } from "../core/typing.ts";
|
|
30
|
+
import { PromptChatApiMessage, PromptChatApiProgressEvent, PromptChatApiProgressResult, type PromptChatApiConfig, type PromptResponse } from "../models/chat.ts";
|
|
31
|
+
import type { SmarterJournalMessage } from "../models/journal.ts";
|
|
32
|
+
import { LLMClient, LLMClientApiKey, LLMClientCustomDomain, LLMClientExtension, LLMClientPlugin } from "../models/llmclient.ts";
|
|
33
|
+
import { SmarterKindResource } from "./base.ts";
|
|
34
|
+
/** A message: a {@link PromptChatApiMessage}, e.g. `{ role: "user", content: "Hi" }`. */
|
|
35
|
+
export type MessageInput = PromptChatApiMessage;
|
|
36
|
+
/** A prompt: the text of one user message, or a list of messages. */
|
|
37
|
+
export type PromptInput = string | readonly MessageInput[];
|
|
38
|
+
/** The options of a prompt, beside the per-request options. */
|
|
39
|
+
export interface PromptOptions extends RequestOptions {
|
|
40
|
+
/** The chat session's key, from {@link LLMClients.config}, to keep the prompt's history in that session. */
|
|
41
|
+
sessionKey?: string | null | undefined;
|
|
42
|
+
}
|
|
43
|
+
/** The options of an LLMClient's chat configuration, beside the session's key and the per-request options. */
|
|
44
|
+
export interface ConfigOptions extends PromptOptions {
|
|
45
|
+
/**
|
|
46
|
+
* True to add the configuration's diagnostic parts: the session's tool calls
|
|
47
|
+
* (`history.prompt_tool_call_history`), the complete `meta_data`, and the lists of the LLMClient's
|
|
48
|
+
* plugins and extensions. Without it, the configuration has what a chat needs, and the counts of the
|
|
49
|
+
* plugins and extensions. A deployed LLMClient's own host ignores it. Default false.
|
|
50
|
+
*/
|
|
51
|
+
verbose?: boolean | undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A prompt as a list of messages.
|
|
55
|
+
*
|
|
56
|
+
* @param prompt - A user message's text, or a list of messages.
|
|
57
|
+
* @returns The messages.
|
|
58
|
+
*/
|
|
59
|
+
export declare function toMessages(prompt: PromptInput): PromptChatApiMessage[];
|
|
60
|
+
/**
|
|
61
|
+
* Messages as the prompt api's request sends them: only those that the LLM accepts.
|
|
62
|
+
*
|
|
63
|
+
* Smarter's own `smarter` and `smarter_error` messages are left out, as Smarter Chat leaves them out.
|
|
64
|
+
* Every message keeps its `content`, even when it is null, e.g. an assistant's tool calls: the
|
|
65
|
+
* platform requires the key.
|
|
66
|
+
*
|
|
67
|
+
* @param messages - A chat thread.
|
|
68
|
+
* @returns The messages, as JSON.
|
|
69
|
+
*/
|
|
70
|
+
export declare function requestMessages(messages: readonly PromptChatApiMessage[]): JsonValue[];
|
|
71
|
+
/**
|
|
72
|
+
* A prompt whose progress is streamed as Server-Sent Events.
|
|
73
|
+
*
|
|
74
|
+
* Iterate it with `for await` for the {@link PromptChatApiProgressEvent} events, e.g. "Calling tool
|
|
75
|
+
* calculator". The request is sent when the iteration starts, and its connection is closed when the
|
|
76
|
+
* iteration ends, also when the loop exits early. When the stream has been read to its end,
|
|
77
|
+
* {@link PromptStream.response} is the prompt's response, exactly as a non-streaming prompt returns it.
|
|
78
|
+
*/
|
|
79
|
+
export declare class PromptStream implements AsyncIterable<PromptChatApiProgressEvent> {
|
|
80
|
+
#private;
|
|
81
|
+
/**
|
|
82
|
+
* @param events - Starts the request, and iterates its Server-Sent Events.
|
|
83
|
+
* @param onResult - Called with the final `result` event, before the iteration ends.
|
|
84
|
+
*/
|
|
85
|
+
constructor(events: () => AsyncGenerator<ServerSentEvent>, onResult?: (result: PromptChatApiProgressResult) => void);
|
|
86
|
+
[Symbol.asyncIterator](): AsyncGenerator<PromptChatApiProgressEvent>;
|
|
87
|
+
/**
|
|
88
|
+
* Read the stream to its end, discarding the progress events.
|
|
89
|
+
*
|
|
90
|
+
* @returns The prompt's response.
|
|
91
|
+
*/
|
|
92
|
+
untilDone(): Promise<PromptResponse>;
|
|
93
|
+
/** The final `result` event, once the stream has been read: the prompt's status and response. */
|
|
94
|
+
get result(): PromptChatApiProgressResult | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* The prompt's response, once the stream has been read.
|
|
97
|
+
*
|
|
98
|
+
* @throws {@link SmarterPromptError} If the prompt failed.
|
|
99
|
+
* @throws {@link SmarterError} If the stream has not been read, or ended without a result.
|
|
100
|
+
*/
|
|
101
|
+
get response(): PromptResponse;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* A multi-turn conversation with an LLMClient.
|
|
105
|
+
*
|
|
106
|
+
* It keeps the chat session's key, so that the platform keeps the session's history, and the
|
|
107
|
+
* thread, which it sends with each prompt as Smarter Chat does. Create one with {@link LLMClients.chat}.
|
|
108
|
+
*/
|
|
109
|
+
export declare class ChatSession {
|
|
110
|
+
#private;
|
|
111
|
+
/** The LLMClient's id or hashed id. */
|
|
112
|
+
readonly llmclientId: SmarterId;
|
|
113
|
+
/** The chat session's configuration. */
|
|
114
|
+
readonly config: PromptChatApiConfig;
|
|
115
|
+
/** The chat thread. */
|
|
116
|
+
messages: PromptChatApiMessage[];
|
|
117
|
+
/**
|
|
118
|
+
* @param llmclients - The LLMClients resource.
|
|
119
|
+
* @param llmclientId - The LLMClient's id or hashed id.
|
|
120
|
+
* @param config - The chat session's configuration.
|
|
121
|
+
*/
|
|
122
|
+
constructor(llmclients: LLMClients, llmclientId: SmarterId, config: PromptChatApiConfig);
|
|
123
|
+
/** The chat session's key, with which the session can be resumed: see {@link LLMClients.chat}. */
|
|
124
|
+
get sessionKey(): string;
|
|
125
|
+
/**
|
|
126
|
+
* Send a message, and add it and the prompt's messages to the thread.
|
|
127
|
+
*
|
|
128
|
+
* @param content - A user message's text, or a message.
|
|
129
|
+
* @param options - Per-request options.
|
|
130
|
+
* @returns The prompt's response. `text` is the LLM's reply.
|
|
131
|
+
*/
|
|
132
|
+
send(content: string | MessageInput, options?: RequestOptions): Promise<PromptResponse>;
|
|
133
|
+
/**
|
|
134
|
+
* Send a message, and stream the prompt's progress. The thread is updated when the stream has been read to its end.
|
|
135
|
+
*
|
|
136
|
+
* @param content - A user message's text, or a message.
|
|
137
|
+
* @param options - Per-request options.
|
|
138
|
+
* @returns The stream.
|
|
139
|
+
*/
|
|
140
|
+
stream(content: string | MessageInput, options?: RequestOptions): ChatStream;
|
|
141
|
+
}
|
|
142
|
+
/** A {@link PromptStream} of a {@link ChatSession}, which adds the prompt's messages to the session's thread. */
|
|
143
|
+
export declare class ChatStream extends PromptStream {
|
|
144
|
+
/**
|
|
145
|
+
* @param events - Starts the request, and iterates its Server-Sent Events.
|
|
146
|
+
* @param onMessages - Called with a successful prompt's messages.
|
|
147
|
+
*/
|
|
148
|
+
constructor(events: () => AsyncGenerator<ServerSentEvent>, onMessages: (messages: PromptChatApiMessage[]) => void);
|
|
149
|
+
}
|
|
150
|
+
/** LLMClients: `/api/v1/llm-clients/`, and the manifest api's `LLMClient` kind. */
|
|
151
|
+
export declare class LLMClients extends SmarterKindResource<typeof LLMClient> {
|
|
152
|
+
readonly kind = "LLMClient";
|
|
153
|
+
readonly path = "llm-clients/";
|
|
154
|
+
readonly model: z.ZodObject<{
|
|
155
|
+
id: z.ZodNumber;
|
|
156
|
+
hashedId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
157
|
+
name: z.ZodString;
|
|
158
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
159
|
+
version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
160
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
161
|
+
annotations: z.ZodOptional<z.ZodNullable<z.ZodPreprocess<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>, unknown>>>;
|
|
162
|
+
createdAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
163
|
+
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
164
|
+
userProfile: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
165
|
+
user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
166
|
+
username: z.ZodString;
|
|
167
|
+
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
168
|
+
}, z.core.$loose>>>;
|
|
169
|
+
account: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
170
|
+
accountNumber: z.ZodString;
|
|
171
|
+
}, z.core.$loose>>>;
|
|
172
|
+
}, z.core.$loose>>>;
|
|
173
|
+
canDelete: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
174
|
+
manifestUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
175
|
+
detailUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
176
|
+
ready: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
177
|
+
rfc1034CompliantName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
178
|
+
provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
179
|
+
defaultModel: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
180
|
+
defaultSystemRole: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
181
|
+
deployed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
182
|
+
defaultHost: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
183
|
+
defaultUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
184
|
+
customHost: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
185
|
+
customUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
186
|
+
sandboxHost: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
187
|
+
sandboxUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
188
|
+
urlLlmclient: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
189
|
+
urlChatConfig: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
190
|
+
isAuthenticationRequired: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
191
|
+
extensions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
192
|
+
id: z.ZodNumber;
|
|
193
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
194
|
+
extension: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
195
|
+
llmclient: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
196
|
+
createdAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
197
|
+
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
198
|
+
}, z.core.$loose>>>;
|
|
199
|
+
plugins: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
200
|
+
id: z.ZodNumber;
|
|
201
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
202
|
+
}, z.core.$loose>>>;
|
|
203
|
+
mcpclients: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
204
|
+
id: z.ZodNumber;
|
|
205
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
206
|
+
}, z.core.$loose>>>;
|
|
207
|
+
guardrails: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
208
|
+
id: z.ZodNumber;
|
|
209
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
210
|
+
}, z.core.$loose>>>;
|
|
211
|
+
tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
212
|
+
id: z.ZodNumber;
|
|
213
|
+
name: z.ZodString;
|
|
214
|
+
kind: z.ZodString;
|
|
215
|
+
}, z.core.$loose>>>;
|
|
216
|
+
apiKeys: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
217
|
+
id: z.ZodNumber;
|
|
218
|
+
llmclient: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
219
|
+
apiKey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
220
|
+
createdAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
221
|
+
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
222
|
+
}, z.core.$loose>>>;
|
|
223
|
+
customDomains: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
224
|
+
id: z.ZodNumber;
|
|
225
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
226
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
227
|
+
version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
228
|
+
domainName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
229
|
+
verificationStatus: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
230
|
+
verifiedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
231
|
+
verificationMessage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
232
|
+
userProfile: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
233
|
+
createdAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
234
|
+
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
235
|
+
}, z.core.$loose>>>;
|
|
236
|
+
}, z.core.$loose>;
|
|
237
|
+
/**
|
|
238
|
+
* An LLMClient's chat configuration, and a chat session.
|
|
239
|
+
*
|
|
240
|
+
* By default, the configuration has what a chat needs: the LLMClient, the session's key and chat
|
|
241
|
+
* history, a short `meta_data`, and the counts of the LLMClient's plugins and extensions. `verbose`
|
|
242
|
+
* adds the diagnostic parts: the lists of plugins and extensions, the session's tool calls and the
|
|
243
|
+
* complete `meta_data`.
|
|
244
|
+
*
|
|
245
|
+
* @param id - The LLMClient's id or hashed id.
|
|
246
|
+
* @param options - `sessionKey`: an existing session's key, to resume it with its history, or none for a new session. `verbose`: true to add the diagnostic parts (`?verbose=true`).
|
|
247
|
+
* @returns The configuration, whose `session_key` identifies the session.
|
|
248
|
+
* @example
|
|
249
|
+
* ```ts
|
|
250
|
+
* const config = await client.llmClients.config("calculator", { verbose: true });
|
|
251
|
+
* console.log(config.plugins.plugins.map((plugin) => plugin.plugin_meta.name));
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
config(id: SmarterId, options?: ConfigOptions): Promise<PromptChatApiConfig>;
|
|
255
|
+
/**
|
|
256
|
+
* Prompt an LLMClient.
|
|
257
|
+
*
|
|
258
|
+
* The platform runs the LLMClient's whole prompt: it selects plugins, calls the LLM, runs the tools
|
|
259
|
+
* that the LLM calls, and applies the Guardrails. Prompts are billed by the LLM provider.
|
|
260
|
+
*
|
|
261
|
+
* @param id - The LLMClient's id or hashed id.
|
|
262
|
+
* @param prompt - The text of one user message, or the chat thread as a list of messages.
|
|
263
|
+
* @param options - `sessionKey`, the chat session's key, and per-request options.
|
|
264
|
+
* @returns The response. `text` is the LLM's final reply, and `data.messages` every message that
|
|
265
|
+
* the prompt added, including Smarter's own.
|
|
266
|
+
* @throws {@link APIStatusError} If the prompt failed, e.g. the LLM provider returned an error. The
|
|
267
|
+
* error's `body` is the error response.
|
|
268
|
+
*/
|
|
269
|
+
prompt(id: SmarterId, prompt: PromptInput, options?: PromptOptions): Promise<PromptResponse>;
|
|
270
|
+
/**
|
|
271
|
+
* Prompt an LLMClient, and stream its progress: the LLM requests, tool calls and plugin calls.
|
|
272
|
+
*
|
|
273
|
+
* @param id - The LLMClient's id or hashed id.
|
|
274
|
+
* @param prompt - The text of one user message, or the chat thread as a list of messages.
|
|
275
|
+
* @param options - `sessionKey`, and per-request options. The timeout applies to each event.
|
|
276
|
+
* @returns The stream. Iterate it with `for await` for the progress events.
|
|
277
|
+
*/
|
|
278
|
+
stream(id: SmarterId, prompt: PromptInput, options?: PromptOptions): PromptStream;
|
|
279
|
+
/**
|
|
280
|
+
* The Server-Sent Events of a prompt, which are requested when the iteration starts.
|
|
281
|
+
*
|
|
282
|
+
* @param id - The LLMClient's id or hashed id.
|
|
283
|
+
* @param prompt - The prompt.
|
|
284
|
+
* @param options - `sessionKey`, and per-request options.
|
|
285
|
+
* @returns A function that starts the request.
|
|
286
|
+
*/
|
|
287
|
+
events(id: SmarterId, prompt: PromptInput, options?: PromptOptions): () => AsyncGenerator<ServerSentEvent>;
|
|
288
|
+
/**
|
|
289
|
+
* Start or resume a conversation with an LLMClient.
|
|
290
|
+
*
|
|
291
|
+
* @param id - The LLMClient's id or hashed id.
|
|
292
|
+
* @param options - `sessionKey`: an existing session's key, to resume it, or none for a new session.
|
|
293
|
+
* @returns The chat session.
|
|
294
|
+
*/
|
|
295
|
+
chat(id: SmarterId, options?: PromptOptions): Promise<ChatSession>;
|
|
296
|
+
/**
|
|
297
|
+
* An LLMClient's plugins.
|
|
298
|
+
*
|
|
299
|
+
* @param id - The LLMClient's integer id.
|
|
300
|
+
* @param options - Per-request options.
|
|
301
|
+
* @returns The plugins.
|
|
302
|
+
*/
|
|
303
|
+
plugins(id: SmarterId, options?: RequestOptions): Promise<LLMClientPlugin[]>;
|
|
304
|
+
/**
|
|
305
|
+
* The extensions whose tools an LLMClient offers the LLM, e.g. `calculator`.
|
|
306
|
+
*
|
|
307
|
+
* @param id - The LLMClient's integer id.
|
|
308
|
+
* @param options - Per-request options.
|
|
309
|
+
* @returns The extensions.
|
|
310
|
+
*/
|
|
311
|
+
extensions(id: SmarterId, options?: RequestOptions): Promise<LLMClientExtension[]>;
|
|
312
|
+
/**
|
|
313
|
+
* The api keys that may call an LLMClient that requires authentication.
|
|
314
|
+
*
|
|
315
|
+
* @param id - The LLMClient's integer id.
|
|
316
|
+
* @param options - Per-request options.
|
|
317
|
+
* @returns The api keys.
|
|
318
|
+
*/
|
|
319
|
+
apiKeys(id: SmarterId, options?: RequestOptions): Promise<LLMClientApiKey[]>;
|
|
320
|
+
/**
|
|
321
|
+
* The custom domains of an LLMClient.
|
|
322
|
+
*
|
|
323
|
+
* @param id - The LLMClient's integer id.
|
|
324
|
+
* @param options - Per-request options.
|
|
325
|
+
* @returns The custom domains.
|
|
326
|
+
*/
|
|
327
|
+
customDomains(id: SmarterId, options?: RequestOptions): Promise<LLMClientCustomDomain[]>;
|
|
328
|
+
/**
|
|
329
|
+
* Deploy an LLMClient on its own host name.
|
|
330
|
+
*
|
|
331
|
+
* This creates real, possibly billable infrastructure: DNS records, a TLS certificate and a
|
|
332
|
+
* Kubernetes ingress.
|
|
333
|
+
*
|
|
334
|
+
* @param name - The LLMClient's name.
|
|
335
|
+
* @param options - Per-request options.
|
|
336
|
+
* @returns The platform's response.
|
|
337
|
+
*/
|
|
338
|
+
deploy(name: string, options?: RequestOptions): Promise<SmarterJournalMessage>;
|
|
339
|
+
/**
|
|
340
|
+
* Undo an LLMClient's deployment.
|
|
341
|
+
*
|
|
342
|
+
* @param name - The LLMClient's name.
|
|
343
|
+
* @param options - Per-request options.
|
|
344
|
+
* @returns The platform's response.
|
|
345
|
+
*/
|
|
346
|
+
undeploy(name: string, options?: RequestOptions): Promise<SmarterJournalMessage>;
|
|
347
|
+
}
|
|
348
|
+
//# sourceMappingURL=llmclients.d.ts.map
|
|
@@ -0,0 +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