@luketandjung/dedalus-labs 2.1.0 → 2.1.2
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/DedalusClient.d.ts +321 -0
- package/dist/DedalusClient.d.ts.map +1 -0
- package/dist/DedalusClient.js +238 -0
- package/dist/DedalusClient.js.map +1 -0
- package/dist/DedalusConfig.d.ts +39 -0
- package/dist/DedalusConfig.d.ts.map +1 -0
- package/dist/DedalusConfig.js +22 -0
- package/dist/DedalusConfig.js.map +1 -0
- package/dist/DedalusEmbeddingModel.d.ts +100 -0
- package/dist/DedalusEmbeddingModel.d.ts.map +1 -0
- package/dist/DedalusEmbeddingModel.js +115 -0
- package/dist/DedalusEmbeddingModel.js.map +1 -0
- package/dist/DedalusLanguageModel.d.ts +68 -0
- package/dist/DedalusLanguageModel.d.ts.map +1 -0
- package/dist/DedalusLanguageModel.js +517 -0
- package/dist/DedalusLanguageModel.js.map +1 -0
- package/dist/Generated.d.ts +2660 -0
- package/dist/Generated.d.ts.map +1 -0
- package/dist/Generated.js +1049 -0
- package/dist/Generated.js.map +1 -0
- package/dist/index.d.ts +16 -3099
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -1293
- package/dist/index.js.map +1 -0
- package/dist/internal/utilities.d.ts +6 -0
- package/dist/internal/utilities.d.ts.map +1 -0
- package/dist/internal/utilities.js +17 -0
- package/dist/internal/utilities.js.map +1 -0
- package/package.json +7 -14
- package/dist/index.cjs +0 -1320
- package/dist/index.d.cts +0 -3104
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import * as HttpClient from "@effect/platform/HttpClient";
|
|
2
|
+
/**
|
|
3
|
+
* @since 1.0.0
|
|
4
|
+
*/
|
|
5
|
+
import { AiError } from "@luketandjung/ariadne";
|
|
6
|
+
import * as Config from "effect/Config";
|
|
7
|
+
import type { ConfigError } from "effect/ConfigError";
|
|
8
|
+
import * as Context from "effect/Context";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import * as Layer from "effect/Layer";
|
|
11
|
+
import * as Redacted from "effect/Redacted";
|
|
12
|
+
import * as Schema from "effect/Schema";
|
|
13
|
+
import type * as Scope from "effect/Scope";
|
|
14
|
+
import * as Stream from "effect/Stream";
|
|
15
|
+
import * as Generated from "./Generated.js";
|
|
16
|
+
declare const DedalusClient_base: Context.TagClass<DedalusClient, "@dedalus-labs/DedalusClient", Service>;
|
|
17
|
+
/**
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
* @category Context
|
|
20
|
+
*/
|
|
21
|
+
export declare class DedalusClient extends DedalusClient_base {
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @since 1.0.0
|
|
25
|
+
* @category Models
|
|
26
|
+
*/
|
|
27
|
+
export interface Service {
|
|
28
|
+
readonly client: Generated.Client;
|
|
29
|
+
readonly createChatCompletion: (options: typeof Generated.ChatCompletionRequest.Encoded) => Effect.Effect<Generated.ChatCompletion, AiError.AiError>;
|
|
30
|
+
readonly createChatCompletionStream: (options: Omit<typeof Generated.ChatCompletionRequest.Encoded, "stream">) => Stream.Stream<ChatCompletionChunk, AiError.AiError>;
|
|
31
|
+
readonly createEmbedding: (options: typeof Generated.CreateEmbeddingRequest.Encoded) => Effect.Effect<Generated.CreateEmbeddingResponse, AiError.AiError>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @since 1.0.0
|
|
35
|
+
* @category Models
|
|
36
|
+
*/
|
|
37
|
+
export type StreamChatCompletionRequest = Omit<typeof Generated.ChatCompletionRequest.Encoded, "stream">;
|
|
38
|
+
/**
|
|
39
|
+
* @since 1.0.0
|
|
40
|
+
* @category Constructors
|
|
41
|
+
*/
|
|
42
|
+
export declare const make: (options: {
|
|
43
|
+
/**
|
|
44
|
+
* Standard OAuth-style API key to use to communicate with the Dedalus API.
|
|
45
|
+
*/
|
|
46
|
+
readonly apiKey?: Redacted.Redacted | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* An alternative API gateway/proxy style API key to use to communicate with the Dedalus API.
|
|
49
|
+
*/
|
|
50
|
+
readonly xApiKey?: Redacted.Redacted | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* The model provider. Only for users with access to and using BYOK API key.
|
|
53
|
+
*/
|
|
54
|
+
readonly provider?: string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The model provider key. Only for users with access to and using BYOK API key.
|
|
57
|
+
*/
|
|
58
|
+
readonly providerKey?: Redacted.Redacted | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* The environment to use. Determines the base URL if `apiUrl` is not provided.
|
|
61
|
+
* - `"production"` uses https://api.dedaluslabs.ai/v1
|
|
62
|
+
* - `"development"` uses http://localhost:8080/v1
|
|
63
|
+
* Defaults to `"production"`.
|
|
64
|
+
*/
|
|
65
|
+
readonly environment?: "production" | "development" | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* The URL to use to communicate with the Dedalus API.
|
|
68
|
+
* Overrides the `environment` setting if provided.
|
|
69
|
+
*/
|
|
70
|
+
readonly apiUrl?: string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* A method which can be used to transform the underlying `HttpClient` which
|
|
73
|
+
* will be used to communicate with the Dedalus API.
|
|
74
|
+
*/
|
|
75
|
+
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined;
|
|
76
|
+
}) => Effect.Effect<Service, never, HttpClient.HttpClient | Scope.Scope>;
|
|
77
|
+
/**
|
|
78
|
+
* @since 1.0.0
|
|
79
|
+
* @category Layers
|
|
80
|
+
*/
|
|
81
|
+
export declare const layer: (options: {
|
|
82
|
+
readonly apiKey?: Redacted.Redacted | undefined;
|
|
83
|
+
readonly xApiKey?: Redacted.Redacted | undefined;
|
|
84
|
+
readonly provider?: string | undefined;
|
|
85
|
+
readonly providerKey?: Redacted.Redacted | undefined;
|
|
86
|
+
readonly environment?: "production" | "development" | undefined;
|
|
87
|
+
readonly apiUrl?: string | undefined;
|
|
88
|
+
readonly transformClient?: (client: HttpClient.HttpClient) => HttpClient.HttpClient;
|
|
89
|
+
}) => Layer.Layer<DedalusClient, never, HttpClient.HttpClient>;
|
|
90
|
+
/**
|
|
91
|
+
* @since 1.0.0
|
|
92
|
+
* @category Layers
|
|
93
|
+
*/
|
|
94
|
+
export declare const layerConfig: (options: {
|
|
95
|
+
readonly apiKey?: Config.Config<Redacted.Redacted | undefined> | undefined;
|
|
96
|
+
readonly xApiKey?: Config.Config<Redacted.Redacted | undefined> | undefined;
|
|
97
|
+
readonly provider?: Config.Config<string | undefined> | undefined;
|
|
98
|
+
readonly providerKey?: Config.Config<Redacted.Redacted | undefined> | undefined;
|
|
99
|
+
readonly environment?: Config.Config<"production" | "development" | undefined> | undefined;
|
|
100
|
+
readonly apiUrl?: Config.Config<string | undefined> | undefined;
|
|
101
|
+
readonly transformClient?: (client: HttpClient.HttpClient) => HttpClient.HttpClient;
|
|
102
|
+
}) => Layer.Layer<DedalusClient, ConfigError, HttpClient.HttpClient>;
|
|
103
|
+
declare const ChatCompletionChunkDelta_base: Schema.Class<ChatCompletionChunkDelta, {
|
|
104
|
+
/**
|
|
105
|
+
* The role of the author of this message delta.
|
|
106
|
+
*/
|
|
107
|
+
role: Schema.optional<Schema.Literal<["developer", "system", "user", "assistant", "tool"]>>;
|
|
108
|
+
/**
|
|
109
|
+
* The content delta.
|
|
110
|
+
*/
|
|
111
|
+
content: Schema.optional<Schema.NullOr<typeof Schema.String>>;
|
|
112
|
+
/**
|
|
113
|
+
* The refusal message delta.
|
|
114
|
+
*/
|
|
115
|
+
refusal: Schema.optional<Schema.NullOr<typeof Schema.String>>;
|
|
116
|
+
/**
|
|
117
|
+
* Tool calls delta.
|
|
118
|
+
*/
|
|
119
|
+
tool_calls: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
120
|
+
index: typeof Schema.Int;
|
|
121
|
+
id: Schema.optional<typeof Schema.String>;
|
|
122
|
+
type: Schema.optional<Schema.Literal<["function"]>>;
|
|
123
|
+
function: Schema.optional<Schema.Struct<{
|
|
124
|
+
name: Schema.optional<typeof Schema.String>;
|
|
125
|
+
arguments: Schema.optional<typeof Schema.String>;
|
|
126
|
+
}>>;
|
|
127
|
+
}>>>;
|
|
128
|
+
}, Schema.Struct.Encoded<{
|
|
129
|
+
/**
|
|
130
|
+
* The role of the author of this message delta.
|
|
131
|
+
*/
|
|
132
|
+
role: Schema.optional<Schema.Literal<["developer", "system", "user", "assistant", "tool"]>>;
|
|
133
|
+
/**
|
|
134
|
+
* The content delta.
|
|
135
|
+
*/
|
|
136
|
+
content: Schema.optional<Schema.NullOr<typeof Schema.String>>;
|
|
137
|
+
/**
|
|
138
|
+
* The refusal message delta.
|
|
139
|
+
*/
|
|
140
|
+
refusal: Schema.optional<Schema.NullOr<typeof Schema.String>>;
|
|
141
|
+
/**
|
|
142
|
+
* Tool calls delta.
|
|
143
|
+
*/
|
|
144
|
+
tool_calls: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
145
|
+
index: typeof Schema.Int;
|
|
146
|
+
id: Schema.optional<typeof Schema.String>;
|
|
147
|
+
type: Schema.optional<Schema.Literal<["function"]>>;
|
|
148
|
+
function: Schema.optional<Schema.Struct<{
|
|
149
|
+
name: Schema.optional<typeof Schema.String>;
|
|
150
|
+
arguments: Schema.optional<typeof Schema.String>;
|
|
151
|
+
}>>;
|
|
152
|
+
}>>>;
|
|
153
|
+
}>, never, {
|
|
154
|
+
readonly tool_calls?: readonly {
|
|
155
|
+
readonly function?: {
|
|
156
|
+
readonly name?: string | undefined;
|
|
157
|
+
readonly arguments?: string | undefined;
|
|
158
|
+
} | undefined;
|
|
159
|
+
readonly type?: "function" | undefined;
|
|
160
|
+
readonly id?: string | undefined;
|
|
161
|
+
readonly index: number;
|
|
162
|
+
}[] | undefined;
|
|
163
|
+
} & {
|
|
164
|
+
readonly content?: string | null | undefined;
|
|
165
|
+
} & {
|
|
166
|
+
readonly refusal?: string | null | undefined;
|
|
167
|
+
} & {
|
|
168
|
+
readonly role?: "user" | "system" | "assistant" | "developer" | "tool" | undefined;
|
|
169
|
+
}, {}, {}>;
|
|
170
|
+
/**
|
|
171
|
+
* A delta message in a streaming chat completion chunk.
|
|
172
|
+
*
|
|
173
|
+
* @since 1.0.0
|
|
174
|
+
* @category Schemas
|
|
175
|
+
*/
|
|
176
|
+
export declare class ChatCompletionChunkDelta extends ChatCompletionChunkDelta_base {
|
|
177
|
+
}
|
|
178
|
+
declare const ChatCompletionChunkChoice_base: Schema.Class<ChatCompletionChunkChoice, {
|
|
179
|
+
/**
|
|
180
|
+
* The index of this choice.
|
|
181
|
+
*/
|
|
182
|
+
index: typeof Schema.Int;
|
|
183
|
+
/**
|
|
184
|
+
* The delta content.
|
|
185
|
+
*/
|
|
186
|
+
delta: typeof ChatCompletionChunkDelta;
|
|
187
|
+
/**
|
|
188
|
+
* Log probability information.
|
|
189
|
+
*/
|
|
190
|
+
logprobs: Schema.optional<Schema.NullOr<typeof Generated.ChoiceLogprobs>>;
|
|
191
|
+
/**
|
|
192
|
+
* The reason the model stopped generating tokens.
|
|
193
|
+
*/
|
|
194
|
+
finish_reason: Schema.NullOr<typeof Generated.ChoiceFinishReasonEnum>;
|
|
195
|
+
}, Schema.Struct.Encoded<{
|
|
196
|
+
/**
|
|
197
|
+
* The index of this choice.
|
|
198
|
+
*/
|
|
199
|
+
index: typeof Schema.Int;
|
|
200
|
+
/**
|
|
201
|
+
* The delta content.
|
|
202
|
+
*/
|
|
203
|
+
delta: typeof ChatCompletionChunkDelta;
|
|
204
|
+
/**
|
|
205
|
+
* Log probability information.
|
|
206
|
+
*/
|
|
207
|
+
logprobs: Schema.optional<Schema.NullOr<typeof Generated.ChoiceLogprobs>>;
|
|
208
|
+
/**
|
|
209
|
+
* The reason the model stopped generating tokens.
|
|
210
|
+
*/
|
|
211
|
+
finish_reason: Schema.NullOr<typeof Generated.ChoiceFinishReasonEnum>;
|
|
212
|
+
}>, never, {
|
|
213
|
+
readonly logprobs?: Generated.ChoiceLogprobs | null | undefined;
|
|
214
|
+
} & {
|
|
215
|
+
readonly index: number;
|
|
216
|
+
} & {
|
|
217
|
+
readonly finish_reason: "length" | "stop" | "function_call" | "tool_calls" | "content_filter" | null;
|
|
218
|
+
} & {
|
|
219
|
+
readonly delta: ChatCompletionChunkDelta;
|
|
220
|
+
}, {}, {}>;
|
|
221
|
+
/**
|
|
222
|
+
* A choice in a streaming chat completion chunk.
|
|
223
|
+
*
|
|
224
|
+
* @since 1.0.0
|
|
225
|
+
* @category Schemas
|
|
226
|
+
*/
|
|
227
|
+
export declare class ChatCompletionChunkChoice extends ChatCompletionChunkChoice_base {
|
|
228
|
+
}
|
|
229
|
+
declare const ChatCompletionChunk_base: Schema.Class<ChatCompletionChunk, {
|
|
230
|
+
/**
|
|
231
|
+
* A unique identifier for the chat completion chunk.
|
|
232
|
+
*/
|
|
233
|
+
id: typeof Schema.String;
|
|
234
|
+
/**
|
|
235
|
+
* The object type, which is always `chat.completion.chunk`.
|
|
236
|
+
*/
|
|
237
|
+
object: Schema.Literal<["chat.completion.chunk"]>;
|
|
238
|
+
/**
|
|
239
|
+
* The Unix timestamp (in seconds) of when the chunk was created.
|
|
240
|
+
*/
|
|
241
|
+
created: typeof Schema.Int;
|
|
242
|
+
/**
|
|
243
|
+
* The model used for the chat completion.
|
|
244
|
+
*/
|
|
245
|
+
model: typeof Schema.String;
|
|
246
|
+
/**
|
|
247
|
+
* This fingerprint represents the backend configuration that the model runs with.
|
|
248
|
+
*/
|
|
249
|
+
system_fingerprint: Schema.optional<Schema.NullOr<typeof Schema.String>>;
|
|
250
|
+
/**
|
|
251
|
+
* A list of chat completion choices.
|
|
252
|
+
*/
|
|
253
|
+
choices: Schema.Array$<typeof ChatCompletionChunkChoice>;
|
|
254
|
+
/**
|
|
255
|
+
* Usage statistics (only present in final chunk if requested).
|
|
256
|
+
*/
|
|
257
|
+
usage: Schema.optional<Schema.NullOr<typeof Generated.CompletionUsage>>;
|
|
258
|
+
/**
|
|
259
|
+
* Service tier used for processing the request.
|
|
260
|
+
*/
|
|
261
|
+
service_tier: Schema.optional<Schema.NullOr<typeof Generated.ChatCompletionServiceTierEnum>>;
|
|
262
|
+
}, Schema.Struct.Encoded<{
|
|
263
|
+
/**
|
|
264
|
+
* A unique identifier for the chat completion chunk.
|
|
265
|
+
*/
|
|
266
|
+
id: typeof Schema.String;
|
|
267
|
+
/**
|
|
268
|
+
* The object type, which is always `chat.completion.chunk`.
|
|
269
|
+
*/
|
|
270
|
+
object: Schema.Literal<["chat.completion.chunk"]>;
|
|
271
|
+
/**
|
|
272
|
+
* The Unix timestamp (in seconds) of when the chunk was created.
|
|
273
|
+
*/
|
|
274
|
+
created: typeof Schema.Int;
|
|
275
|
+
/**
|
|
276
|
+
* The model used for the chat completion.
|
|
277
|
+
*/
|
|
278
|
+
model: typeof Schema.String;
|
|
279
|
+
/**
|
|
280
|
+
* This fingerprint represents the backend configuration that the model runs with.
|
|
281
|
+
*/
|
|
282
|
+
system_fingerprint: Schema.optional<Schema.NullOr<typeof Schema.String>>;
|
|
283
|
+
/**
|
|
284
|
+
* A list of chat completion choices.
|
|
285
|
+
*/
|
|
286
|
+
choices: Schema.Array$<typeof ChatCompletionChunkChoice>;
|
|
287
|
+
/**
|
|
288
|
+
* Usage statistics (only present in final chunk if requested).
|
|
289
|
+
*/
|
|
290
|
+
usage: Schema.optional<Schema.NullOr<typeof Generated.CompletionUsage>>;
|
|
291
|
+
/**
|
|
292
|
+
* Service tier used for processing the request.
|
|
293
|
+
*/
|
|
294
|
+
service_tier: Schema.optional<Schema.NullOr<typeof Generated.ChatCompletionServiceTierEnum>>;
|
|
295
|
+
}>, never, {
|
|
296
|
+
readonly object: "chat.completion.chunk";
|
|
297
|
+
} & {
|
|
298
|
+
readonly service_tier?: "default" | "auto" | "flex" | "scale" | "priority" | null | undefined;
|
|
299
|
+
} & {
|
|
300
|
+
readonly model: string;
|
|
301
|
+
} & {
|
|
302
|
+
readonly id: string;
|
|
303
|
+
} & {
|
|
304
|
+
readonly created: number;
|
|
305
|
+
} & {
|
|
306
|
+
readonly choices: readonly ChatCompletionChunkChoice[];
|
|
307
|
+
} & {
|
|
308
|
+
readonly system_fingerprint?: string | null | undefined;
|
|
309
|
+
} & {
|
|
310
|
+
readonly usage?: Generated.CompletionUsage | null | undefined;
|
|
311
|
+
}, {}, {}>;
|
|
312
|
+
/**
|
|
313
|
+
* A streaming chat completion chunk (OpenAI-compatible).
|
|
314
|
+
*
|
|
315
|
+
* @since 1.0.0
|
|
316
|
+
* @category Schemas
|
|
317
|
+
*/
|
|
318
|
+
export declare class ChatCompletionChunk extends ChatCompletionChunk_base {
|
|
319
|
+
}
|
|
320
|
+
export {};
|
|
321
|
+
//# sourceMappingURL=DedalusClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DedalusClient.d.ts","sourceRoot":"","sources":["../src/DedalusClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAC;AAE1D;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;;AAI5C;;;GAGG;AACH,qBAAa,aAAc,SAAQ,kBAGhC;CAAG;AAEN;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC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H;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;;;;;;;;;;;;;;;;;;AAvCL;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,wBAqCvC;CAAG"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import * as Sse from "@effect/experimental/Sse";
|
|
2
|
+
import * as HttpBody from "@effect/platform/HttpBody";
|
|
3
|
+
import * as HttpClient from "@effect/platform/HttpClient";
|
|
4
|
+
import * as HttpClientRequest from "@effect/platform/HttpClientRequest";
|
|
5
|
+
/**
|
|
6
|
+
* @since 1.0.0
|
|
7
|
+
*/
|
|
8
|
+
import { AiError } from "@luketandjung/ariadne";
|
|
9
|
+
import * as Config from "effect/Config";
|
|
10
|
+
import * as Context from "effect/Context";
|
|
11
|
+
import * as Effect from "effect/Effect";
|
|
12
|
+
import { identity } from "effect/Function";
|
|
13
|
+
import * as Layer from "effect/Layer";
|
|
14
|
+
import * as Redacted from "effect/Redacted";
|
|
15
|
+
import * as Schema from "effect/Schema";
|
|
16
|
+
import * as Stream from "effect/Stream";
|
|
17
|
+
import * as Generated from "./Generated.js";
|
|
18
|
+
import { DedalusConfig } from "./DedalusConfig.js";
|
|
19
|
+
import { uuid4 } from "./internal/utilities.js";
|
|
20
|
+
/**
|
|
21
|
+
* @since 1.0.0
|
|
22
|
+
* @category Context
|
|
23
|
+
*/
|
|
24
|
+
export class DedalusClient extends Context.Tag("@dedalus-labs/DedalusClient")() {
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @since 1.0.0
|
|
28
|
+
* @category Constructors
|
|
29
|
+
*/
|
|
30
|
+
export const make = (options) => Effect.gen(function* () {
|
|
31
|
+
const baseUrl = options.apiUrl ??
|
|
32
|
+
((options.environment ?? "production") === "production"
|
|
33
|
+
? "https://api.dedaluslabs.ai"
|
|
34
|
+
: "http://localhost:8080");
|
|
35
|
+
const httpClient = (yield* HttpClient.HttpClient).pipe(HttpClient.mapRequest((request) => {
|
|
36
|
+
const headers = {
|
|
37
|
+
"User-Agent": "Dedalus/JS 1.0.0",
|
|
38
|
+
"X-SDK-Version": "1.0.0",
|
|
39
|
+
};
|
|
40
|
+
if (options.provider) {
|
|
41
|
+
headers["X-Provider"] = options.provider;
|
|
42
|
+
}
|
|
43
|
+
if (options.providerKey) {
|
|
44
|
+
headers["X-Provider-Key"] = Redacted.value(options.providerKey);
|
|
45
|
+
}
|
|
46
|
+
if (request.method !== "GET") {
|
|
47
|
+
headers["Idempotency-Key"] = `stainless-node-retry-${uuid4()}`;
|
|
48
|
+
}
|
|
49
|
+
return request.pipe(HttpClientRequest.prependUrl(baseUrl), options.apiKey
|
|
50
|
+
? HttpClientRequest.bearerToken(options.apiKey)
|
|
51
|
+
: options.xApiKey
|
|
52
|
+
? HttpClientRequest.setHeader("x-api-key", Redacted.value(options.xApiKey))
|
|
53
|
+
: identity, HttpClientRequest.setHeaders(headers), HttpClientRequest.acceptJson);
|
|
54
|
+
}), options.transformClient ?? identity);
|
|
55
|
+
const httpClientOk = HttpClient.filterStatusOk(httpClient);
|
|
56
|
+
const client = Generated.make(httpClient, {
|
|
57
|
+
transformClient: (client) => DedalusConfig.getOrUndefined.pipe(Effect.map((config) => config?.transformClient ? config.transformClient(client) : client)),
|
|
58
|
+
});
|
|
59
|
+
const createChatCompletion = (options) => client.createChatCompletionV1ChatCompletionsPost(options).pipe(Effect.catchTags({
|
|
60
|
+
RequestError: (error) => AiError.HttpRequestError.fromRequestError({
|
|
61
|
+
module: "DedalusClient",
|
|
62
|
+
method: "createChatCompletion",
|
|
63
|
+
error,
|
|
64
|
+
}),
|
|
65
|
+
ResponseError: (error) => AiError.HttpResponseError.fromResponseError({
|
|
66
|
+
module: "DedalusClient",
|
|
67
|
+
method: "createChatCompletion",
|
|
68
|
+
error,
|
|
69
|
+
}),
|
|
70
|
+
ParseError: (error) => AiError.MalformedOutput.fromParseError({
|
|
71
|
+
module: "DedalusClient",
|
|
72
|
+
method: "createChatCompletion",
|
|
73
|
+
error,
|
|
74
|
+
}),
|
|
75
|
+
}));
|
|
76
|
+
const createChatCompletionStream = (options) => {
|
|
77
|
+
const request = HttpClientRequest.post("/v1/chat/completions", {
|
|
78
|
+
body: HttpBody.unsafeJson({ ...options, stream: true }),
|
|
79
|
+
});
|
|
80
|
+
const decodeChunk = Schema.decode(Schema.parseJson(ChatCompletionChunk));
|
|
81
|
+
return httpClientOk.execute(request).pipe(Effect.map((r) => r.stream), Stream.unwrapScoped, Stream.decodeText(), Stream.pipeThroughChannel(Sse.makeChannel()), Stream.mapEffect((event) => decodeChunk(event.data)), Stream.takeUntil((chunk) => chunk.choices.some((choice) => choice.finish_reason !== null)), Stream.catchTags({
|
|
82
|
+
RequestError: (error) => AiError.HttpRequestError.fromRequestError({
|
|
83
|
+
module: "DedalusClient",
|
|
84
|
+
method: "createChatCompletionStream",
|
|
85
|
+
error,
|
|
86
|
+
}),
|
|
87
|
+
ResponseError: (error) => AiError.HttpResponseError.fromResponseError({
|
|
88
|
+
module: "DedalusClient",
|
|
89
|
+
method: "createChatCompletionStream",
|
|
90
|
+
error,
|
|
91
|
+
}),
|
|
92
|
+
ParseError: (error) => AiError.MalformedOutput.fromParseError({
|
|
93
|
+
module: "DedalusClient",
|
|
94
|
+
method: "createChatCompletionStream",
|
|
95
|
+
error,
|
|
96
|
+
}),
|
|
97
|
+
}));
|
|
98
|
+
};
|
|
99
|
+
const createEmbedding = (options) => client.createEmbeddingsV1EmbeddingsPost(options).pipe(Effect.catchTags({
|
|
100
|
+
RequestError: (error) => AiError.HttpRequestError.fromRequestError({
|
|
101
|
+
module: "DedalusClient",
|
|
102
|
+
method: "createEmbedding",
|
|
103
|
+
error,
|
|
104
|
+
}),
|
|
105
|
+
ResponseError: (error) => AiError.HttpResponseError.fromResponseError({
|
|
106
|
+
module: "DedalusClient",
|
|
107
|
+
method: "createEmbedding",
|
|
108
|
+
error,
|
|
109
|
+
}),
|
|
110
|
+
ParseError: (error) => AiError.MalformedOutput.fromParseError({
|
|
111
|
+
module: "DedalusClient",
|
|
112
|
+
method: "createEmbedding",
|
|
113
|
+
error,
|
|
114
|
+
}),
|
|
115
|
+
}));
|
|
116
|
+
return DedalusClient.of({
|
|
117
|
+
client,
|
|
118
|
+
createChatCompletion,
|
|
119
|
+
createChatCompletionStream,
|
|
120
|
+
createEmbedding,
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
/**
|
|
124
|
+
* @since 1.0.0
|
|
125
|
+
* @category Layers
|
|
126
|
+
*/
|
|
127
|
+
export const layer = (options) => Layer.scoped(DedalusClient, make(options));
|
|
128
|
+
/**
|
|
129
|
+
* @since 1.0.0
|
|
130
|
+
* @category Layers
|
|
131
|
+
*/
|
|
132
|
+
export const layerConfig = (options) => {
|
|
133
|
+
const { transformClient, ...configs } = options;
|
|
134
|
+
return Config.all(configs).pipe(Effect.flatMap((configs) => make({ ...configs, transformClient })), Layer.scoped(DedalusClient));
|
|
135
|
+
};
|
|
136
|
+
// =============================================================================
|
|
137
|
+
// Chat Completion Streaming Schema (OpenAI-compatible)
|
|
138
|
+
// =============================================================================
|
|
139
|
+
/**
|
|
140
|
+
* A delta message in a streaming chat completion chunk.
|
|
141
|
+
*
|
|
142
|
+
* @since 1.0.0
|
|
143
|
+
* @category Schemas
|
|
144
|
+
*/
|
|
145
|
+
export class ChatCompletionChunkDelta extends Schema.Class("@dedalus-labs/ChatCompletionChunkDelta")({
|
|
146
|
+
/**
|
|
147
|
+
* The role of the author of this message delta.
|
|
148
|
+
*/
|
|
149
|
+
role: Schema.optional(Schema.Literal("developer", "system", "user", "assistant", "tool")),
|
|
150
|
+
/**
|
|
151
|
+
* The content delta.
|
|
152
|
+
*/
|
|
153
|
+
content: Schema.optional(Schema.NullOr(Schema.String)),
|
|
154
|
+
/**
|
|
155
|
+
* The refusal message delta.
|
|
156
|
+
*/
|
|
157
|
+
refusal: Schema.optional(Schema.NullOr(Schema.String)),
|
|
158
|
+
/**
|
|
159
|
+
* Tool calls delta.
|
|
160
|
+
*/
|
|
161
|
+
tool_calls: Schema.optional(Schema.Array(Schema.Struct({
|
|
162
|
+
index: Schema.Int,
|
|
163
|
+
id: Schema.optional(Schema.String),
|
|
164
|
+
type: Schema.optional(Schema.Literal("function")),
|
|
165
|
+
function: Schema.optional(Schema.Struct({
|
|
166
|
+
name: Schema.optional(Schema.String),
|
|
167
|
+
arguments: Schema.optional(Schema.String),
|
|
168
|
+
})),
|
|
169
|
+
}))),
|
|
170
|
+
}) {
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* A choice in a streaming chat completion chunk.
|
|
174
|
+
*
|
|
175
|
+
* @since 1.0.0
|
|
176
|
+
* @category Schemas
|
|
177
|
+
*/
|
|
178
|
+
export class ChatCompletionChunkChoice extends Schema.Class("@dedalus-labs/ChatCompletionChunkChoice")({
|
|
179
|
+
/**
|
|
180
|
+
* The index of this choice.
|
|
181
|
+
*/
|
|
182
|
+
index: Schema.Int,
|
|
183
|
+
/**
|
|
184
|
+
* The delta content.
|
|
185
|
+
*/
|
|
186
|
+
delta: ChatCompletionChunkDelta,
|
|
187
|
+
/**
|
|
188
|
+
* Log probability information.
|
|
189
|
+
*/
|
|
190
|
+
logprobs: Schema.optional(Schema.NullOr(Generated.ChoiceLogprobs)),
|
|
191
|
+
/**
|
|
192
|
+
* The reason the model stopped generating tokens.
|
|
193
|
+
*/
|
|
194
|
+
finish_reason: Schema.NullOr(Generated.ChoiceFinishReasonEnum),
|
|
195
|
+
}) {
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* A streaming chat completion chunk (OpenAI-compatible).
|
|
199
|
+
*
|
|
200
|
+
* @since 1.0.0
|
|
201
|
+
* @category Schemas
|
|
202
|
+
*/
|
|
203
|
+
export class ChatCompletionChunk extends Schema.Class("@dedalus-labs/ChatCompletionChunk")({
|
|
204
|
+
/**
|
|
205
|
+
* A unique identifier for the chat completion chunk.
|
|
206
|
+
*/
|
|
207
|
+
id: Schema.String,
|
|
208
|
+
/**
|
|
209
|
+
* The object type, which is always `chat.completion.chunk`.
|
|
210
|
+
*/
|
|
211
|
+
object: Schema.Literal("chat.completion.chunk"),
|
|
212
|
+
/**
|
|
213
|
+
* The Unix timestamp (in seconds) of when the chunk was created.
|
|
214
|
+
*/
|
|
215
|
+
created: Schema.Int,
|
|
216
|
+
/**
|
|
217
|
+
* The model used for the chat completion.
|
|
218
|
+
*/
|
|
219
|
+
model: Schema.String,
|
|
220
|
+
/**
|
|
221
|
+
* This fingerprint represents the backend configuration that the model runs with.
|
|
222
|
+
*/
|
|
223
|
+
system_fingerprint: Schema.optional(Schema.NullOr(Schema.String)),
|
|
224
|
+
/**
|
|
225
|
+
* A list of chat completion choices.
|
|
226
|
+
*/
|
|
227
|
+
choices: Schema.Array(ChatCompletionChunkChoice),
|
|
228
|
+
/**
|
|
229
|
+
* Usage statistics (only present in final chunk if requested).
|
|
230
|
+
*/
|
|
231
|
+
usage: Schema.optional(Schema.NullOr(Generated.CompletionUsage)),
|
|
232
|
+
/**
|
|
233
|
+
* Service tier used for processing the request.
|
|
234
|
+
*/
|
|
235
|
+
service_tier: Schema.optional(Schema.NullOr(Generated.ChatCompletionServiceTierEnum)),
|
|
236
|
+
}) {
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=DedalusClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DedalusClient.js","sourceRoot":"","sources":["../src/DedalusClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAC;AAC1D,OAAO,KAAK,iBAAiB,MAAM,oCAAoC,CAAC;AACxE;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,OAAO,MAAM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/C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,GAAG;IACnB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjE;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC;IAChD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IAChE;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC,QAAQ,CAC3B,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,6BAA6B,CAAC,CACvD;CACF,CAAC;CAAG"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
*/
|
|
4
|
+
import type { HttpClient } from "@effect/platform/HttpClient";
|
|
5
|
+
import * as Context from "effect/Context";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
declare const DedalusConfig_base: Context.TagClass<DedalusConfig, "@dedalus-labs/DedalusConfig", DedalusConfig.Service>;
|
|
8
|
+
/**
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
* @category Context
|
|
11
|
+
*/
|
|
12
|
+
export declare class DedalusConfig extends DedalusConfig_base {
|
|
13
|
+
/**
|
|
14
|
+
* @since 1.0.0
|
|
15
|
+
*/
|
|
16
|
+
static readonly getOrUndefined: Effect.Effect<typeof DedalusConfig.Service | undefined>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @since 1.0.0
|
|
20
|
+
*/
|
|
21
|
+
export declare namespace DedalusConfig {
|
|
22
|
+
/**
|
|
23
|
+
* @since 1.0.
|
|
24
|
+
* @category Models
|
|
25
|
+
*/
|
|
26
|
+
interface Service {
|
|
27
|
+
readonly transformClient?: (client: HttpClient) => HttpClient;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @since 1.0.0
|
|
32
|
+
* @category Configuration
|
|
33
|
+
*/
|
|
34
|
+
export declare const withClientTransform: {
|
|
35
|
+
(transform: (client: HttpClient) => HttpClient): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
36
|
+
<A, E, R>(self: Effect.Effect<A, E, R>, transform: (client: HttpClient) => HttpClient): Effect.Effect<A, E, R>;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=DedalusConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DedalusConfig.d.ts","sourceRoot":"","sources":["../src/DedalusConfig.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;AAGxC;;;GAGG;AACH,qBAAa,aAAc,SAAQ,kBAEM;IACvC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,CAC3C,OAAO,aAAa,CAAC,OAAO,GAAG,SAAS,CACzC,CAEC;CACH;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,WAAW,aAAa,CAAC;IACrC;;;OAGG;IACH,UAAiB,OAAO;QACtB,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,UAAU,CAAC;KAC/D;CACF;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE;IAChC,CACE,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,UAAU,GAC5C,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACrE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACN,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC5B,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,UAAU,GAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CAgB3B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { dual } from "effect/Function";
|
|
4
|
+
/**
|
|
5
|
+
* @since 1.0.0
|
|
6
|
+
* @category Context
|
|
7
|
+
*/
|
|
8
|
+
export class DedalusConfig extends Context.Tag("@dedalus-labs/DedalusConfig")() {
|
|
9
|
+
/**
|
|
10
|
+
* @since 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
static getOrUndefined = Effect.map(Effect.context(), (context) => context.unsafeMap.get(DedalusConfig.key));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @since 1.0.0
|
|
16
|
+
* @category Configuration
|
|
17
|
+
*/
|
|
18
|
+
export const withClientTransform = dual(2, (self, transformClient) => Effect.flatMap(DedalusConfig.getOrUndefined, (config) => Effect.provideService(self, DedalusConfig, {
|
|
19
|
+
...config,
|
|
20
|
+
transformClient,
|
|
21
|
+
})));
|
|
22
|
+
//# sourceMappingURL=DedalusConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DedalusConfig.js","sourceRoot":"","sources":["../src/DedalusConfig.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,OAAO,CAAC,GAAG,CAC5C,6BAA6B,CAC9B,EAAwC;IACvC;;OAEG;IACH,MAAM,CAAU,cAAc,GAE1B,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAClD,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CACzC,CAAC;;AAgBJ;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAQ5B,IAAI,CAQN,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,EAAE,CAC7B,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CACtD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,EAAE;IACzC,GAAG,MAAM;IACT,eAAe;CAChB,CAAC,CACH,CACF,CAAC"}
|