@prompt-helm/sdk 0.1.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/LICENSE +21 -0
- package/README.md +167 -0
- package/dist/index.cjs +566 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +114 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.js +557 -0
- package/dist/index.js.map +1 -0
- package/package.json +74 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
type Environment = "production" | "development";
|
|
2
|
+
interface ExecuteRequest {
|
|
3
|
+
promptSlug?: string;
|
|
4
|
+
promptId?: string;
|
|
5
|
+
variables?: Record<string, string>;
|
|
6
|
+
system?: string;
|
|
7
|
+
user?: string;
|
|
8
|
+
model?: string;
|
|
9
|
+
temperature?: number;
|
|
10
|
+
maxTokens?: number;
|
|
11
|
+
topP?: number;
|
|
12
|
+
stopSequences?: string[];
|
|
13
|
+
environment?: Environment;
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
}
|
|
16
|
+
interface ExecuteResponse {
|
|
17
|
+
id: string;
|
|
18
|
+
output: string;
|
|
19
|
+
model: string;
|
|
20
|
+
inputTokens: number;
|
|
21
|
+
outputTokens: number;
|
|
22
|
+
totalTokens: number;
|
|
23
|
+
latencyMs: number;
|
|
24
|
+
cost: number;
|
|
25
|
+
timestamp: string;
|
|
26
|
+
}
|
|
27
|
+
interface StreamChunkEvent {
|
|
28
|
+
type: "chunk";
|
|
29
|
+
content: string;
|
|
30
|
+
}
|
|
31
|
+
interface StreamDoneEvent {
|
|
32
|
+
type: "done";
|
|
33
|
+
inputTokens: number;
|
|
34
|
+
outputTokens: number;
|
|
35
|
+
totalTokens: number;
|
|
36
|
+
cost: number;
|
|
37
|
+
model: string;
|
|
38
|
+
latencyMs: number;
|
|
39
|
+
}
|
|
40
|
+
interface StreamErrorEvent {
|
|
41
|
+
type: "error";
|
|
42
|
+
errorCode: string;
|
|
43
|
+
message: string;
|
|
44
|
+
requestId?: string;
|
|
45
|
+
}
|
|
46
|
+
type StreamEvent = StreamChunkEvent | StreamDoneEvent | StreamErrorEvent;
|
|
47
|
+
interface ErrorEnvelope {
|
|
48
|
+
statusCode: number;
|
|
49
|
+
error: string;
|
|
50
|
+
message: string;
|
|
51
|
+
code?: string;
|
|
52
|
+
correlationId?: string;
|
|
53
|
+
}
|
|
54
|
+
interface RequestOptions {
|
|
55
|
+
signal?: AbortSignal;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface PromptHelmConfig {
|
|
59
|
+
apiKey: string;
|
|
60
|
+
baseURL?: string;
|
|
61
|
+
timeout?: number;
|
|
62
|
+
maxRetries?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Prefix appended to the SDK's User-Agent header. Use it to identify the
|
|
65
|
+
* application or service making the call (helpful when one tenant runs
|
|
66
|
+
* many apps against the same prompt). Example: `"my-checkout-service/1.4.2"`.
|
|
67
|
+
*/
|
|
68
|
+
userAgent?: string;
|
|
69
|
+
fetch?: typeof globalThis.fetch;
|
|
70
|
+
headers?: Record<string, string>;
|
|
71
|
+
}
|
|
72
|
+
declare class PromptHelm {
|
|
73
|
+
private readonly apiKey;
|
|
74
|
+
private readonly baseURL;
|
|
75
|
+
private readonly timeout;
|
|
76
|
+
private readonly maxRetries;
|
|
77
|
+
private readonly fetchFn;
|
|
78
|
+
private readonly extraHeaders;
|
|
79
|
+
private readonly userAgent;
|
|
80
|
+
constructor(config: PromptHelmConfig);
|
|
81
|
+
execute(request: ExecuteRequest, options?: RequestOptions): Promise<ExecuteResponse>;
|
|
82
|
+
stream(request: ExecuteRequest, options?: RequestOptions): AsyncIterable<StreamEvent>;
|
|
83
|
+
private executeOnce;
|
|
84
|
+
private buildHeaders;
|
|
85
|
+
private isRetryable;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
declare class PromptHelmError extends Error {
|
|
89
|
+
readonly statusCode: number;
|
|
90
|
+
readonly code: string | undefined;
|
|
91
|
+
readonly correlationId: string | undefined;
|
|
92
|
+
constructor(statusCode: number, code: string | undefined, correlationId: string | undefined, message: string);
|
|
93
|
+
}
|
|
94
|
+
declare class AuthenticationError extends PromptHelmError {
|
|
95
|
+
constructor(statusCode: number, code: string | undefined, correlationId: string | undefined, message: string);
|
|
96
|
+
}
|
|
97
|
+
declare class AuthorizationError extends PromptHelmError {
|
|
98
|
+
constructor(statusCode: number, code: string | undefined, correlationId: string | undefined, message: string);
|
|
99
|
+
}
|
|
100
|
+
declare class RateLimitError extends PromptHelmError {
|
|
101
|
+
constructor(statusCode: number, code: string | undefined, correlationId: string | undefined, message: string);
|
|
102
|
+
}
|
|
103
|
+
declare class NotFoundError extends PromptHelmError {
|
|
104
|
+
constructor(statusCode: number, code: string | undefined, correlationId: string | undefined, message: string);
|
|
105
|
+
}
|
|
106
|
+
declare class ApiError extends PromptHelmError {
|
|
107
|
+
constructor(statusCode: number, code: string | undefined, correlationId: string | undefined, message: string);
|
|
108
|
+
}
|
|
109
|
+
declare class TimeoutError extends Error {
|
|
110
|
+
readonly timeoutMs: number;
|
|
111
|
+
constructor(timeoutMs: number, message?: string);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { ApiError, AuthenticationError, AuthorizationError, type Environment, type ErrorEnvelope, type ExecuteRequest, type ExecuteResponse, NotFoundError, PromptHelm, type PromptHelmConfig, PromptHelmError, RateLimitError, type RequestOptions, type StreamChunkEvent, type StreamDoneEvent, type StreamErrorEvent, type StreamEvent, TimeoutError };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
type Environment = "production" | "development";
|
|
2
|
+
interface ExecuteRequest {
|
|
3
|
+
promptSlug?: string;
|
|
4
|
+
promptId?: string;
|
|
5
|
+
variables?: Record<string, string>;
|
|
6
|
+
system?: string;
|
|
7
|
+
user?: string;
|
|
8
|
+
model?: string;
|
|
9
|
+
temperature?: number;
|
|
10
|
+
maxTokens?: number;
|
|
11
|
+
topP?: number;
|
|
12
|
+
stopSequences?: string[];
|
|
13
|
+
environment?: Environment;
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
}
|
|
16
|
+
interface ExecuteResponse {
|
|
17
|
+
id: string;
|
|
18
|
+
output: string;
|
|
19
|
+
model: string;
|
|
20
|
+
inputTokens: number;
|
|
21
|
+
outputTokens: number;
|
|
22
|
+
totalTokens: number;
|
|
23
|
+
latencyMs: number;
|
|
24
|
+
cost: number;
|
|
25
|
+
timestamp: string;
|
|
26
|
+
}
|
|
27
|
+
interface StreamChunkEvent {
|
|
28
|
+
type: "chunk";
|
|
29
|
+
content: string;
|
|
30
|
+
}
|
|
31
|
+
interface StreamDoneEvent {
|
|
32
|
+
type: "done";
|
|
33
|
+
inputTokens: number;
|
|
34
|
+
outputTokens: number;
|
|
35
|
+
totalTokens: number;
|
|
36
|
+
cost: number;
|
|
37
|
+
model: string;
|
|
38
|
+
latencyMs: number;
|
|
39
|
+
}
|
|
40
|
+
interface StreamErrorEvent {
|
|
41
|
+
type: "error";
|
|
42
|
+
errorCode: string;
|
|
43
|
+
message: string;
|
|
44
|
+
requestId?: string;
|
|
45
|
+
}
|
|
46
|
+
type StreamEvent = StreamChunkEvent | StreamDoneEvent | StreamErrorEvent;
|
|
47
|
+
interface ErrorEnvelope {
|
|
48
|
+
statusCode: number;
|
|
49
|
+
error: string;
|
|
50
|
+
message: string;
|
|
51
|
+
code?: string;
|
|
52
|
+
correlationId?: string;
|
|
53
|
+
}
|
|
54
|
+
interface RequestOptions {
|
|
55
|
+
signal?: AbortSignal;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface PromptHelmConfig {
|
|
59
|
+
apiKey: string;
|
|
60
|
+
baseURL?: string;
|
|
61
|
+
timeout?: number;
|
|
62
|
+
maxRetries?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Prefix appended to the SDK's User-Agent header. Use it to identify the
|
|
65
|
+
* application or service making the call (helpful when one tenant runs
|
|
66
|
+
* many apps against the same prompt). Example: `"my-checkout-service/1.4.2"`.
|
|
67
|
+
*/
|
|
68
|
+
userAgent?: string;
|
|
69
|
+
fetch?: typeof globalThis.fetch;
|
|
70
|
+
headers?: Record<string, string>;
|
|
71
|
+
}
|
|
72
|
+
declare class PromptHelm {
|
|
73
|
+
private readonly apiKey;
|
|
74
|
+
private readonly baseURL;
|
|
75
|
+
private readonly timeout;
|
|
76
|
+
private readonly maxRetries;
|
|
77
|
+
private readonly fetchFn;
|
|
78
|
+
private readonly extraHeaders;
|
|
79
|
+
private readonly userAgent;
|
|
80
|
+
constructor(config: PromptHelmConfig);
|
|
81
|
+
execute(request: ExecuteRequest, options?: RequestOptions): Promise<ExecuteResponse>;
|
|
82
|
+
stream(request: ExecuteRequest, options?: RequestOptions): AsyncIterable<StreamEvent>;
|
|
83
|
+
private executeOnce;
|
|
84
|
+
private buildHeaders;
|
|
85
|
+
private isRetryable;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
declare class PromptHelmError extends Error {
|
|
89
|
+
readonly statusCode: number;
|
|
90
|
+
readonly code: string | undefined;
|
|
91
|
+
readonly correlationId: string | undefined;
|
|
92
|
+
constructor(statusCode: number, code: string | undefined, correlationId: string | undefined, message: string);
|
|
93
|
+
}
|
|
94
|
+
declare class AuthenticationError extends PromptHelmError {
|
|
95
|
+
constructor(statusCode: number, code: string | undefined, correlationId: string | undefined, message: string);
|
|
96
|
+
}
|
|
97
|
+
declare class AuthorizationError extends PromptHelmError {
|
|
98
|
+
constructor(statusCode: number, code: string | undefined, correlationId: string | undefined, message: string);
|
|
99
|
+
}
|
|
100
|
+
declare class RateLimitError extends PromptHelmError {
|
|
101
|
+
constructor(statusCode: number, code: string | undefined, correlationId: string | undefined, message: string);
|
|
102
|
+
}
|
|
103
|
+
declare class NotFoundError extends PromptHelmError {
|
|
104
|
+
constructor(statusCode: number, code: string | undefined, correlationId: string | undefined, message: string);
|
|
105
|
+
}
|
|
106
|
+
declare class ApiError extends PromptHelmError {
|
|
107
|
+
constructor(statusCode: number, code: string | undefined, correlationId: string | undefined, message: string);
|
|
108
|
+
}
|
|
109
|
+
declare class TimeoutError extends Error {
|
|
110
|
+
readonly timeoutMs: number;
|
|
111
|
+
constructor(timeoutMs: number, message?: string);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { ApiError, AuthenticationError, AuthorizationError, type Environment, type ErrorEnvelope, type ExecuteRequest, type ExecuteResponse, NotFoundError, PromptHelm, type PromptHelmConfig, PromptHelmError, RateLimitError, type RequestOptions, type StreamChunkEvent, type StreamDoneEvent, type StreamErrorEvent, type StreamEvent, TimeoutError };
|