@effect/ai-openai-compat 4.0.0-rc.117 → 4.0.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/AGENTS.md +4 -4
- package/CLAUDE.md +4 -4
- package/README.md +15 -4
- package/ai-docs/package.json +1 -1
- package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +1 -1
- package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +1 -1
- package/ai-docs/src/03_stream/30_encoding.ts +1 -1
- package/ai-docs/src/08_observability/20_otlp-tracing.ts +2 -2
- package/ai-docs/src/08_observability/index.md +1 -1
- package/ai-docs/src/40_sql/10_basics.ts +2 -2
- package/ai-docs/src/40_sql/index.md +1 -1
- package/ai-docs/src/50_http-client/10_basics.ts +1 -1
- package/ai-docs/src/51_http-server/10_basics.ts +2 -2
- package/ai-docs/src/51_http-server/20_testing.ts +2 -2
- package/ai-docs/src/51_http-server/fixtures/api/Api.ts +1 -1
- package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +1 -1
- package/ai-docs/src/51_http-server/fixtures/api/System.ts +1 -1
- package/ai-docs/src/51_http-server/fixtures/api/Users.ts +1 -1
- package/ai-docs/src/51_http-server/fixtures/domain/User.ts +1 -1
- package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +1 -1
- package/ai-docs/src/51_http-server/fixtures/server/Users.ts +1 -1
- package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +1 -1
- package/ai-docs/src/60_child-process/index.md +1 -1
- package/ai-docs/src/70_cli/10_basics.ts +1 -1
- package/ai-docs/src/70_cli/index.md +1 -1
- package/ai-docs/src/71_ai/10_language-model.ts +2 -2
- package/ai-docs/src/71_ai/20_tools.ts +2 -2
- package/ai-docs/src/71_ai/30_chat.ts +2 -2
- package/ai-docs/src/80_cluster/10_entities.ts +3 -3
- package/dist/OpenAiClient.d.ts +61 -9
- package/dist/OpenAiClient.d.ts.map +1 -1
- package/dist/OpenAiClient.js +13 -16
- package/dist/OpenAiClient.js.map +1 -1
- package/dist/OpenAiConfig.d.ts +1 -1
- package/dist/OpenAiConfig.d.ts.map +1 -1
- package/dist/OpenAiEmbeddingModel.d.ts +10 -11
- package/dist/OpenAiEmbeddingModel.d.ts.map +1 -1
- package/dist/OpenAiEmbeddingModel.js +9 -3
- package/dist/OpenAiEmbeddingModel.js.map +1 -1
- package/dist/OpenAiError.d.ts +1 -1
- package/dist/OpenAiError.d.ts.map +1 -1
- package/dist/OpenAiLanguageModel.d.ts +27 -14
- package/dist/OpenAiLanguageModel.d.ts.map +1 -1
- package/dist/OpenAiLanguageModel.js +17 -8
- package/dist/OpenAiLanguageModel.js.map +1 -1
- package/dist/OpenAiTelemetry.d.ts +9 -1
- package/dist/OpenAiTelemetry.d.ts.map +1 -1
- package/dist/OpenAiTelemetry.js +1 -1
- package/dist/OpenAiTelemetry.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/errors.js +1 -1
- package/dist/internal/errors.js.map +1 -1
- package/package.json +3 -3
- package/src/OpenAiClient.ts +53 -8
- package/src/OpenAiConfig.ts +1 -1
- package/src/OpenAiEmbeddingModel.ts +14 -3
- package/src/OpenAiError.ts +1 -1
- package/src/OpenAiLanguageModel.ts +44 -14
- package/src/OpenAiTelemetry.ts +1 -1
- package/src/index.ts +3 -0
- package/src/internal/errors.ts +6 -6
- package/src/internal/utilities.ts +1 -1
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* endpoints to Effect's embedding model service. It sends embedding requests
|
|
4
|
-
* through {@link OpenAiClient}, exposes constructors for layers and `AiModel`
|
|
5
|
-
* values, supports scoped request configuration overrides, and checks that the
|
|
6
|
-
* provider returns one numeric vector for each requested input.
|
|
7
|
-
*
|
|
8
|
-
* @since 4.0.0
|
|
9
|
-
*/
|
|
1
|
+
import * as EmbeddingModel from "effect/ai/EmbeddingModel";
|
|
2
|
+
import * as AiModel from "effect/ai/Model";
|
|
10
3
|
import * as Context from "effect/Context";
|
|
11
4
|
import * as Effect from "effect/Effect";
|
|
12
5
|
import * as Layer from "effect/Layer";
|
|
13
6
|
import type { Simplify } from "effect/Types";
|
|
14
|
-
import * as EmbeddingModel from "effect/unstable/ai/EmbeddingModel";
|
|
15
|
-
import * as AiModel from "effect/unstable/ai/Model";
|
|
16
7
|
import type { CreateEmbeddingRequestJson } from "./OpenAiClient.ts";
|
|
17
8
|
import { OpenAiClient } from "./OpenAiClient.ts";
|
|
18
9
|
/**
|
|
19
10
|
* A model identifier accepted by an OpenAI-compatible embeddings endpoint.
|
|
20
11
|
*
|
|
12
|
+
* @stability unstable
|
|
21
13
|
* @category models
|
|
22
14
|
* @since 4.0.0
|
|
23
15
|
*/
|
|
@@ -51,6 +43,7 @@ declare const Config_base: Context.ServiceClass<Config, "@effect/ai-openai-compa
|
|
|
51
43
|
*
|
|
52
44
|
* @see {@link withConfigOverride} for scoping embedding request overrides
|
|
53
45
|
*
|
|
46
|
+
* @stability unstable
|
|
54
47
|
* @category services
|
|
55
48
|
* @since 4.0.0
|
|
56
49
|
*/
|
|
@@ -67,6 +60,7 @@ export declare class Config extends Config_base {
|
|
|
67
60
|
* @see {@link layer} for providing only the embedding model service
|
|
68
61
|
* @see {@link withConfigOverride} for scoped request configuration overrides
|
|
69
62
|
*
|
|
63
|
+
* @stability unstable
|
|
70
64
|
* @category constructors
|
|
71
65
|
* @since 4.0.0
|
|
72
66
|
*/
|
|
@@ -99,6 +93,7 @@ export declare const model: (model: string, options: Omit<ConfigOptions, "model"
|
|
|
99
93
|
* @see {@link layer} for providing the service as a `Layer`
|
|
100
94
|
* @see {@link withConfigOverride} for scoping embedding request overrides
|
|
101
95
|
*
|
|
96
|
+
* @stability unstable
|
|
102
97
|
* @category constructors
|
|
103
98
|
* @since 4.0.0
|
|
104
99
|
*/
|
|
@@ -118,6 +113,7 @@ export declare const make: (args_0: {
|
|
|
118
113
|
* @see {@link make} for constructing the embedding model service effectfully
|
|
119
114
|
* @see {@link model} for creating an `AiModel` with configured dimensions
|
|
120
115
|
*
|
|
116
|
+
* @stability unstable
|
|
121
117
|
* @category layers
|
|
122
118
|
* @since 4.0.0
|
|
123
119
|
*/
|
|
@@ -142,6 +138,7 @@ export declare const layer: (options: {
|
|
|
142
138
|
*
|
|
143
139
|
* @see {@link Config} for available OpenAI-compatible embedding request configuration fields
|
|
144
140
|
*
|
|
141
|
+
* @stability unstable
|
|
145
142
|
* @category configuration
|
|
146
143
|
* @since 4.0.0
|
|
147
144
|
*/
|
|
@@ -163,6 +160,7 @@ export declare const withConfigOverride: {
|
|
|
163
160
|
*
|
|
164
161
|
* @see {@link Config} for available OpenAI-compatible embedding request configuration fields
|
|
165
162
|
*
|
|
163
|
+
* @stability unstable
|
|
166
164
|
* @category configuration
|
|
167
165
|
* @since 4.0.0
|
|
168
166
|
*/
|
|
@@ -184,6 +182,7 @@ export declare const withConfigOverride: {
|
|
|
184
182
|
*
|
|
185
183
|
* @see {@link Config} for available OpenAI-compatible embedding request configuration fields
|
|
186
184
|
*
|
|
185
|
+
* @stability unstable
|
|
187
186
|
* @category configuration
|
|
188
187
|
* @since 4.0.0
|
|
189
188
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAiEmbeddingModel.d.ts","sourceRoot":"","sources":["../src/OpenAiEmbeddingModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OpenAiEmbeddingModel.d.ts","sourceRoot":"","sources":["../src/OpenAiEmbeddingModel.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,cAAc,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAC1C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACr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,KAAK,EAAE,YAAY,CACN,CAAA;AAE5D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,kBAAkB,EAAE;IAC/B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,CAAC,SAAS,EAAE,OAAO,MAAM,CAAC,OAAO,GAAG,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,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;IACtH;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;CAsDhH,CAAA"}
|
|
@@ -5,15 +5,16 @@
|
|
|
5
5
|
* values, supports scoped request configuration overrides, and checks that the
|
|
6
6
|
* provider returns one numeric vector for each requested input.
|
|
7
7
|
*
|
|
8
|
+
* @stability unstable
|
|
8
9
|
* @since 4.0.0
|
|
9
10
|
*/
|
|
11
|
+
import * as AiError from "effect/ai/AiError";
|
|
12
|
+
import * as EmbeddingModel from "effect/ai/EmbeddingModel";
|
|
13
|
+
import * as AiModel from "effect/ai/Model";
|
|
10
14
|
import * as Context from "effect/Context";
|
|
11
15
|
import * as Effect from "effect/Effect";
|
|
12
16
|
import { dual } from "effect/Function";
|
|
13
17
|
import * as Layer from "effect/Layer";
|
|
14
|
-
import * as AiError from "effect/unstable/ai/AiError";
|
|
15
|
-
import * as EmbeddingModel from "effect/unstable/ai/EmbeddingModel";
|
|
16
|
-
import * as AiModel from "effect/unstable/ai/Model";
|
|
17
18
|
import { OpenAiClient } from "./OpenAiClient.js";
|
|
18
19
|
/**
|
|
19
20
|
* Context service for OpenAI embedding model configuration.
|
|
@@ -32,6 +33,7 @@ import { OpenAiClient } from "./OpenAiClient.js";
|
|
|
32
33
|
*
|
|
33
34
|
* @see {@link withConfigOverride} for scoping embedding request overrides
|
|
34
35
|
*
|
|
36
|
+
* @stability unstable
|
|
35
37
|
* @category services
|
|
36
38
|
* @since 4.0.0
|
|
37
39
|
*/
|
|
@@ -47,6 +49,7 @@ export class Config extends /*#__PURE__*/Context.Service()("@effect/ai-openai-co
|
|
|
47
49
|
* @see {@link layer} for providing only the embedding model service
|
|
48
50
|
* @see {@link withConfigOverride} for scoped request configuration overrides
|
|
49
51
|
*
|
|
52
|
+
* @stability unstable
|
|
50
53
|
* @category constructors
|
|
51
54
|
* @since 4.0.0
|
|
52
55
|
*/
|
|
@@ -79,6 +82,7 @@ export const model = (model, options) => AiModel.make("openai", model, Layer.mer
|
|
|
79
82
|
* @see {@link layer} for providing the service as a `Layer`
|
|
80
83
|
* @see {@link withConfigOverride} for scoping embedding request overrides
|
|
81
84
|
*
|
|
85
|
+
* @stability unstable
|
|
82
86
|
* @category constructors
|
|
83
87
|
* @since 4.0.0
|
|
84
88
|
*/
|
|
@@ -117,6 +121,7 @@ export const make = /*#__PURE__*/Effect.fnUntraced(function* ({
|
|
|
117
121
|
* @see {@link make} for constructing the embedding model service effectfully
|
|
118
122
|
* @see {@link model} for creating an `AiModel` with configured dimensions
|
|
119
123
|
*
|
|
124
|
+
* @stability unstable
|
|
120
125
|
* @category layers
|
|
121
126
|
* @since 4.0.0
|
|
122
127
|
*/
|
|
@@ -138,6 +143,7 @@ export const layer = options => Layer.effect(EmbeddingModel.EmbeddingModel, make
|
|
|
138
143
|
*
|
|
139
144
|
* @see {@link Config} for available OpenAI-compatible embedding request configuration fields
|
|
140
145
|
*
|
|
146
|
+
* @stability unstable
|
|
141
147
|
* @category configuration
|
|
142
148
|
* @since 4.0.0
|
|
143
149
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAiEmbeddingModel.js","names":[],"sources":["../src/OpenAiEmbeddingModel.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"OpenAiEmbeddingModel.js","names":[],"sources":["../src/OpenAiEmbeddingModel.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;AAUA,OAAO,KAAK,OAAO,MAAM,mBAAmB;AAC5C,OAAO,KAAK,cAAc,MAAM,0BAA0B;AAC1D,OAAO,KAAK,OAAO,MAAM,iBAAiB;AAC1C,OAAO,KAAK,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,SAAS,IAAI,QAAQ,iBAAiB;AACtC,OAAO,KAAK,KAAK,MAAM,cAAc;AAGrC,SAAS,YAAY,QAAQ,mBAAmB;AAchD;;;;;;;;;;;;;;;;;;;;;AAqBA,OAAM,MAAO,MAAO,sBAAQ,OAAO,CAAC,OAAO,EAGxC,CAAC,sDAAsD,CAAC;AAE3D;;;;;;;;;;;;;;;AAeA,OAAO,MAAM,KAAK,GAAG,CACnB,KAAa,EACb,OAGC,KAED,OAAO,CAAC,IAAI,CACV,QAAQ,EACR,KAAK,EACL,KAAK,CAAC,KAAK,CACT,KAAK,CAAC;EACJ,KAAK;EACL,MAAM,EAAE;CACT,CAAC,EACF,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,CAC7D,CACF;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,OAAO,MAAM,IAAI,gBAAG,MAAM,CAAC,UAAU,CAAC,WAAU;EAAE,KAAK;EAAE,MAAM,EAAE;AAAc,CAG9E;EACC,MAAM,MAAM,GAAG,OAAO,YAAY;EAElC,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAE,QAAgC,IACr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AmB,IACxC,OAAO,CAAC,IAAI,CAAC;EACX,MAAM,EAAE,sBAAsB;EAC9B,MAAM,EAAE,WAAW;EACnB,MAAM,EAAE,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAAE;EAAW,CAAE;CACvD,CAAC","ignoreList":[]}
|
package/dist/OpenAiError.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export type OpenAiRateLimitMetadata = OpenAiErrorMetadata & {
|
|
|
63
63
|
*/
|
|
64
64
|
readonly resetTokens: string | null;
|
|
65
65
|
};
|
|
66
|
-
declare module "effect/
|
|
66
|
+
declare module "effect/ai/AiError" {
|
|
67
67
|
/**
|
|
68
68
|
* Metadata attached to rate limit errors returned by OpenAI-compatible APIs.
|
|
69
69
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAiError.d.ts","sourceRoot":"","sources":["../src/OpenAiError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,GAAG;IAC1D;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC,CAAA;AAED,OAAO,QAAQ,
|
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1C,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAA;KAC7C;IAED;;;;;;OAMG;IACH,UAAiB,6BAA6B;QAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAA;KAC7C;IAED;;;;;;OAMG;IACH,UAAiB,0BAA0B;QACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAA;KAC7C;IAED;;;;;;OAMG;IACH,UAAiB,6BAA6B;QAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAA;KAC7C;IAED;;;;;;OAMG;IACH,UAAiB,8BAA8B;QAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAA;KAC7C;IAED;;;;;;OAMG;IACH,UAAiB,oBAAoB;QACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAA;KAC7C;CACF"}
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* providers to Effect AI's `LanguageModel` service. It builds a model service
|
|
4
|
-
* from a model id, translates prompts, files, tools, structured output schemas,
|
|
5
|
-
* and provider-specific options into `OpenAiClient` requests, and maps normal
|
|
6
|
-
* or streaming chat completion results back into Effect AI response content and
|
|
7
|
-
* metadata.
|
|
8
|
-
*
|
|
9
|
-
* @since 4.0.0
|
|
10
|
-
*/
|
|
1
|
+
import * as LanguageModel from "effect/ai/LanguageModel";
|
|
2
|
+
import * as AiModel from "effect/ai/Model";
|
|
11
3
|
import * as Context from "effect/Context";
|
|
12
4
|
import * as Effect from "effect/Effect";
|
|
13
5
|
import * as Layer from "effect/Layer";
|
|
14
6
|
import type { Simplify } from "effect/Types";
|
|
15
|
-
import * as LanguageModel from "effect/unstable/ai/LanguageModel";
|
|
16
|
-
import * as AiModel from "effect/unstable/ai/Model";
|
|
17
7
|
import { type Annotation, type CreateResponse, type IncludeEnum, type MessageStatus, OpenAiClient } from "./OpenAiClient.ts";
|
|
18
8
|
/**
|
|
19
9
|
* Image detail level for vision requests.
|
|
@@ -102,15 +92,17 @@ declare const Config_base: Context.ServiceClass<Config, "@effect/ai-openai-compa
|
|
|
102
92
|
*
|
|
103
93
|
* @see {@link withConfigOverride} for scoping language model request overrides
|
|
104
94
|
*
|
|
95
|
+
* @stability unstable
|
|
105
96
|
* @category services
|
|
106
97
|
* @since 4.0.0
|
|
107
98
|
*/
|
|
108
99
|
export declare class Config extends Config_base {
|
|
109
100
|
}
|
|
110
|
-
declare module "effect/
|
|
101
|
+
declare module "effect/ai/Prompt" {
|
|
111
102
|
/**
|
|
112
103
|
* OpenAI-compatible options for file prompt parts.
|
|
113
104
|
*
|
|
105
|
+
* @stability unstable
|
|
114
106
|
* @category models
|
|
115
107
|
* @since 4.0.0
|
|
116
108
|
*/
|
|
@@ -128,6 +120,7 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
128
120
|
/**
|
|
129
121
|
* OpenAI-compatible options for reasoning prompt parts.
|
|
130
122
|
*
|
|
123
|
+
* @stability unstable
|
|
131
124
|
* @category models
|
|
132
125
|
* @since 4.0.0
|
|
133
126
|
*/
|
|
@@ -151,6 +144,7 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
151
144
|
/**
|
|
152
145
|
* OpenAI-compatible options for assistant tool-call prompt parts.
|
|
153
146
|
*
|
|
147
|
+
* @stability unstable
|
|
154
148
|
* @category models
|
|
155
149
|
* @since 4.0.0
|
|
156
150
|
*/
|
|
@@ -172,6 +166,7 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
172
166
|
/**
|
|
173
167
|
* OpenAI-compatible options for tool-result prompt parts.
|
|
174
168
|
*
|
|
169
|
+
* @stability unstable
|
|
175
170
|
* @category models
|
|
176
171
|
* @since 4.0.0
|
|
177
172
|
*/
|
|
@@ -193,6 +188,7 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
193
188
|
/**
|
|
194
189
|
* OpenAI-compatible options for text prompt parts.
|
|
195
190
|
*
|
|
191
|
+
* @stability unstable
|
|
196
192
|
* @category models
|
|
197
193
|
* @since 4.0.0
|
|
198
194
|
*/
|
|
@@ -216,10 +212,11 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
216
212
|
} | null;
|
|
217
213
|
}
|
|
218
214
|
}
|
|
219
|
-
declare module "effect/
|
|
215
|
+
declare module "effect/ai/Response" {
|
|
220
216
|
/**
|
|
221
217
|
* OpenAI-compatible metadata attached to a complete text response part.
|
|
222
218
|
*
|
|
219
|
+
* @stability unstable
|
|
223
220
|
* @category models
|
|
224
221
|
* @since 4.0.0
|
|
225
222
|
*/
|
|
@@ -251,6 +248,7 @@ declare module "effect/unstable/ai/Response" {
|
|
|
251
248
|
/**
|
|
252
249
|
* OpenAI-compatible metadata emitted when a streamed text part starts.
|
|
253
250
|
*
|
|
251
|
+
* @stability unstable
|
|
254
252
|
* @category models
|
|
255
253
|
* @since 4.0.0
|
|
256
254
|
*/
|
|
@@ -268,6 +266,7 @@ declare module "effect/unstable/ai/Response" {
|
|
|
268
266
|
/**
|
|
269
267
|
* OpenAI-compatible metadata emitted when a streamed text part ends.
|
|
270
268
|
*
|
|
269
|
+
* @stability unstable
|
|
271
270
|
* @category models
|
|
272
271
|
* @since 4.0.0
|
|
273
272
|
*/
|
|
@@ -289,6 +288,7 @@ declare module "effect/unstable/ai/Response" {
|
|
|
289
288
|
/**
|
|
290
289
|
* OpenAI-compatible metadata attached to a complete reasoning response part.
|
|
291
290
|
*
|
|
291
|
+
* @stability unstable
|
|
292
292
|
* @category models
|
|
293
293
|
* @since 4.0.0
|
|
294
294
|
*/
|
|
@@ -310,6 +310,7 @@ declare module "effect/unstable/ai/Response" {
|
|
|
310
310
|
/**
|
|
311
311
|
* OpenAI-compatible metadata emitted when a streamed reasoning part starts.
|
|
312
312
|
*
|
|
313
|
+
* @stability unstable
|
|
313
314
|
* @category models
|
|
314
315
|
* @since 4.0.0
|
|
315
316
|
*/
|
|
@@ -331,6 +332,7 @@ declare module "effect/unstable/ai/Response" {
|
|
|
331
332
|
/**
|
|
332
333
|
* OpenAI-compatible metadata emitted for a streamed reasoning delta.
|
|
333
334
|
*
|
|
335
|
+
* @stability unstable
|
|
334
336
|
* @category models
|
|
335
337
|
* @since 4.0.0
|
|
336
338
|
*/
|
|
@@ -348,6 +350,7 @@ declare module "effect/unstable/ai/Response" {
|
|
|
348
350
|
/**
|
|
349
351
|
* OpenAI-compatible metadata emitted when a streamed reasoning part ends.
|
|
350
352
|
*
|
|
353
|
+
* @stability unstable
|
|
351
354
|
* @category models
|
|
352
355
|
* @since 4.0.0
|
|
353
356
|
*/
|
|
@@ -369,6 +372,7 @@ declare module "effect/unstable/ai/Response" {
|
|
|
369
372
|
/**
|
|
370
373
|
* OpenAI-compatible metadata attached to tool-call response parts.
|
|
371
374
|
*
|
|
375
|
+
* @stability unstable
|
|
372
376
|
* @category models
|
|
373
377
|
* @since 4.0.0
|
|
374
378
|
*/
|
|
@@ -386,6 +390,7 @@ declare module "effect/unstable/ai/Response" {
|
|
|
386
390
|
/**
|
|
387
391
|
* OpenAI-compatible metadata attached to document source citations.
|
|
388
392
|
*
|
|
393
|
+
* @stability unstable
|
|
389
394
|
* @category models
|
|
390
395
|
* @since 4.0.0
|
|
391
396
|
*/
|
|
@@ -437,6 +442,7 @@ declare module "effect/unstable/ai/Response" {
|
|
|
437
442
|
/**
|
|
438
443
|
* OpenAI-compatible metadata attached to URL source citations.
|
|
439
444
|
*
|
|
445
|
+
* @stability unstable
|
|
440
446
|
* @category models
|
|
441
447
|
* @since 4.0.0
|
|
442
448
|
*/
|
|
@@ -462,6 +468,7 @@ declare module "effect/unstable/ai/Response" {
|
|
|
462
468
|
/**
|
|
463
469
|
* OpenAI-compatible metadata attached to finish response parts.
|
|
464
470
|
*
|
|
471
|
+
* @stability unstable
|
|
465
472
|
* @category models
|
|
466
473
|
* @since 4.0.0
|
|
467
474
|
*/
|
|
@@ -488,6 +495,7 @@ declare module "effect/unstable/ai/Response" {
|
|
|
488
495
|
* @see {@link layer} for creating a `LanguageModel.LanguageModel` layer directly
|
|
489
496
|
* @see {@link make} for constructing the language model service effectfully
|
|
490
497
|
*
|
|
498
|
+
* @stability unstable
|
|
491
499
|
* @category constructors
|
|
492
500
|
* @since 4.0.0
|
|
493
501
|
*/
|
|
@@ -510,6 +518,7 @@ export declare const model: (model: string, config?: ModelConfig) => AiModel.Mod
|
|
|
510
518
|
* @see {@link layer} for providing the service as a `Layer`
|
|
511
519
|
* @see {@link model} for creating a model descriptor for `AiModel.provide`
|
|
512
520
|
*
|
|
521
|
+
* @stability unstable
|
|
513
522
|
* @category constructors
|
|
514
523
|
* @since 4.0.0
|
|
515
524
|
*/
|
|
@@ -529,6 +538,7 @@ export declare const make: (args_0: {
|
|
|
529
538
|
* @see {@link make} for constructing the language model service effectfully
|
|
530
539
|
* @see {@link model} for creating an AI model descriptor
|
|
531
540
|
*
|
|
541
|
+
* @stability unstable
|
|
532
542
|
* @category layers
|
|
533
543
|
* @since 4.0.0
|
|
534
544
|
*/
|
|
@@ -551,6 +561,7 @@ export declare const layer: (options: {
|
|
|
551
561
|
*
|
|
552
562
|
* @see {@link Config} for the configuration shape
|
|
553
563
|
*
|
|
564
|
+
* @stability unstable
|
|
554
565
|
* @category configuration
|
|
555
566
|
* @since 4.0.0
|
|
556
567
|
*/
|
|
@@ -570,6 +581,7 @@ export declare const withConfigOverride: {
|
|
|
570
581
|
*
|
|
571
582
|
* @see {@link Config} for the configuration shape
|
|
572
583
|
*
|
|
584
|
+
* @stability unstable
|
|
573
585
|
* @category configuration
|
|
574
586
|
* @since 4.0.0
|
|
575
587
|
*/
|
|
@@ -589,6 +601,7 @@ export declare const withConfigOverride: {
|
|
|
589
601
|
*
|
|
590
602
|
* @see {@link Config} for the configuration shape
|
|
591
603
|
*
|
|
604
|
+
* @stability unstable
|
|
592
605
|
* @category configuration
|
|
593
606
|
* @since 4.0.0
|
|
594
607
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAiLanguageModel.d.ts","sourceRoot":"","sources":["../src/OpenAiLanguageModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OpenAiLanguageModel.d.ts","sourceRoot":"","sources":["../src/OpenAiLanguageModel.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,aAAa,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAK1C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAKvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AASrC,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEzD,OAAO,EACL,KAAK,UAAU,EAGf,KAAK,cAAc,EAInB,KAAK,WAAW,EAGhB,KAAK,aAAa,EAClB,YAAY,EAMb,MAAM,mBAAmB,CAAA;AAG1B;;GAEG;AACH,KAAK,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAA;AAM1C,KAAK,aAAa,GAAG,QAAQ,CACzB,OAAO,CACP,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,OAAO,GAAG,aAAa,GAAG,QAAQ,GAAG,MAAM,CAAC,CAC5E,GACC;IACA;;;;;;;OAOG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;IAC3D;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE;QACd;;;;;;WAMG;QACH,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAA;KAC3D,GAAG,SAAS,CAAA;IACb;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAChD,CACF,CAAA;AACD,KAAK,WAAW,GAAG,I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E,MAAM,CAAC,CAAC,CAAA;IACtH;;;;;;;;;;;;;;;;;;OAkBG;IACH,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;CAkDhH,CAAA"}
|
|
@@ -6,12 +6,18 @@
|
|
|
6
6
|
* or streaming chat completion results back into Effect AI response content and
|
|
7
7
|
* metadata.
|
|
8
8
|
*
|
|
9
|
+
* @stability unstable
|
|
9
10
|
* @since 4.0.0
|
|
10
11
|
*/
|
|
12
|
+
import * as AiError from "effect/ai/AiError";
|
|
13
|
+
import * as LanguageModel from "effect/ai/LanguageModel";
|
|
14
|
+
import * as AiModel from "effect/ai/Model";
|
|
15
|
+
import { toCodecOpenAI } from "effect/ai/OpenAiStructuredOutput";
|
|
16
|
+
import * as Tool from "effect/ai/Tool";
|
|
11
17
|
import * as Context from "effect/Context";
|
|
12
18
|
import * as DateTime from "effect/DateTime";
|
|
13
19
|
import * as Effect from "effect/Effect";
|
|
14
|
-
import * as
|
|
20
|
+
import * as Base64 from "effect/encoding/Base64";
|
|
15
21
|
import { dual } from "effect/Function";
|
|
16
22
|
import * as Layer from "effect/Layer";
|
|
17
23
|
import * as Option from "effect/Option";
|
|
@@ -21,11 +27,6 @@ import * as Redactable from "effect/Redactable";
|
|
|
21
27
|
import * as Schema from "effect/Schema";
|
|
22
28
|
import * as AST from "effect/SchemaAST";
|
|
23
29
|
import * as Stream from "effect/Stream";
|
|
24
|
-
import * as AiError from "effect/unstable/ai/AiError";
|
|
25
|
-
import * as LanguageModel from "effect/unstable/ai/LanguageModel";
|
|
26
|
-
import * as AiModel from "effect/unstable/ai/Model";
|
|
27
|
-
import { toCodecOpenAI } from "effect/unstable/ai/OpenAiStructuredOutput";
|
|
28
|
-
import * as Tool from "effect/unstable/ai/Tool";
|
|
29
30
|
import * as InternalUtilities from "./internal/utilities.js";
|
|
30
31
|
import { OpenAiClient } from "./OpenAiClient.js";
|
|
31
32
|
import { addGenAIAnnotations } from "./OpenAiTelemetry.js";
|
|
@@ -40,6 +41,7 @@ import { addGenAIAnnotations } from "./OpenAiTelemetry.js";
|
|
|
40
41
|
*
|
|
41
42
|
* @see {@link withConfigOverride} for scoping language model request overrides
|
|
42
43
|
*
|
|
44
|
+
* @stability unstable
|
|
43
45
|
* @category services
|
|
44
46
|
* @since 4.0.0
|
|
45
47
|
*/
|
|
@@ -58,6 +60,7 @@ export class Config extends /*#__PURE__*/Context.Service()("@effect/ai-openai-co
|
|
|
58
60
|
* @see {@link layer} for creating a `LanguageModel.LanguageModel` layer directly
|
|
59
61
|
* @see {@link make} for constructing the language model service effectfully
|
|
60
62
|
*
|
|
63
|
+
* @stability unstable
|
|
61
64
|
* @category constructors
|
|
62
65
|
* @since 4.0.0
|
|
63
66
|
*/
|
|
@@ -93,6 +96,7 @@ export const model = (model, config) => AiModel.make("openai", model, layer({
|
|
|
93
96
|
* @see {@link layer} for providing the service as a `Layer`
|
|
94
97
|
* @see {@link model} for creating a model descriptor for `AiModel.provide`
|
|
95
98
|
*
|
|
99
|
+
* @stability unstable
|
|
96
100
|
* @category constructors
|
|
97
101
|
* @since 4.0.0
|
|
98
102
|
*/
|
|
@@ -208,6 +212,7 @@ export const make = /*#__PURE__*/Effect.fnUntraced(function* ({
|
|
|
208
212
|
* @see {@link make} for constructing the language model service effectfully
|
|
209
213
|
* @see {@link model} for creating an AI model descriptor
|
|
210
214
|
*
|
|
215
|
+
* @stability unstable
|
|
211
216
|
* @category layers
|
|
212
217
|
* @since 4.0.0
|
|
213
218
|
*/
|
|
@@ -227,6 +232,7 @@ export const layer = options => Layer.effect(LanguageModel.LanguageModel, make(o
|
|
|
227
232
|
*
|
|
228
233
|
* @see {@link Config} for the configuration shape
|
|
229
234
|
*
|
|
235
|
+
* @stability unstable
|
|
230
236
|
* @category configuration
|
|
231
237
|
* @since 4.0.0
|
|
232
238
|
*/
|
|
@@ -290,7 +296,7 @@ const prepareMessages = /*#__PURE__*/Effect.fnUntraced(function* ({
|
|
|
290
296
|
detail
|
|
291
297
|
});
|
|
292
298
|
} else {
|
|
293
|
-
const imageUrl = part.data instanceof URL ? part.data.toString() : part.data instanceof Uint8Array ? `data:${mediaType};base64,${
|
|
299
|
+
const imageUrl = part.data instanceof URL ? part.data.toString() : part.data instanceof Uint8Array ? `data:${mediaType};base64,${Base64.encode(part.data)}` : /^(data:|https?:\/\/)/i.test(part.data) ? part.data : `data:${mediaType};base64,${part.data}`;
|
|
294
300
|
content.push({
|
|
295
301
|
type: "input_image",
|
|
296
302
|
image_url: imageUrl,
|
|
@@ -311,7 +317,7 @@ const prepareMessages = /*#__PURE__*/Effect.fnUntraced(function* ({
|
|
|
311
317
|
});
|
|
312
318
|
}
|
|
313
319
|
if (part.data instanceof Uint8Array) {
|
|
314
|
-
const base64 =
|
|
320
|
+
const base64 = Base64.encode(part.data);
|
|
315
321
|
const fileName = part.fileName ?? `part-${index}.pdf`;
|
|
316
322
|
const fileData = `data:application/pdf;base64,${base64}`;
|
|
317
323
|
content.push({
|
|
@@ -906,6 +912,9 @@ const transformToolCallParams = /*#__PURE__*/Effect.fnUntraced(function* (tools,
|
|
|
906
912
|
})
|
|
907
913
|
});
|
|
908
914
|
}
|
|
915
|
+
if (Tool.isDynamic(tool) && tool.jsonSchema !== undefined) {
|
|
916
|
+
return toolParams;
|
|
917
|
+
}
|
|
909
918
|
const {
|
|
910
919
|
codec
|
|
911
920
|
} = yield* tryCodecTransform(tool.parametersSchema, "makeResponse");
|