@effect/ai-openai-compat 4.0.0-rc.116 → 4.0.0-rc.118

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.
Files changed (59) hide show
  1. package/AGENTS.md +4 -4
  2. package/CLAUDE.md +4 -4
  3. package/ai-docs/package.json +3 -3
  4. package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +1 -1
  5. package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +1 -1
  6. package/ai-docs/src/03_stream/30_encoding.ts +1 -1
  7. package/ai-docs/src/08_observability/20_otlp-tracing.ts +2 -2
  8. package/ai-docs/src/08_observability/index.md +1 -1
  9. package/ai-docs/src/40_sql/10_basics.ts +2 -2
  10. package/ai-docs/src/40_sql/index.md +1 -1
  11. package/ai-docs/src/50_http-client/10_basics.ts +1 -1
  12. package/ai-docs/src/51_http-server/10_basics.ts +2 -2
  13. package/ai-docs/src/51_http-server/20_testing.ts +2 -2
  14. package/ai-docs/src/51_http-server/fixtures/api/Api.ts +1 -1
  15. package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +1 -1
  16. package/ai-docs/src/51_http-server/fixtures/api/System.ts +1 -1
  17. package/ai-docs/src/51_http-server/fixtures/api/Users.ts +1 -1
  18. package/ai-docs/src/51_http-server/fixtures/domain/User.ts +1 -1
  19. package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +1 -1
  20. package/ai-docs/src/51_http-server/fixtures/server/Users.ts +1 -1
  21. package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +1 -1
  22. package/ai-docs/src/60_child-process/index.md +1 -1
  23. package/ai-docs/src/70_cli/10_basics.ts +1 -1
  24. package/ai-docs/src/70_cli/index.md +1 -1
  25. package/ai-docs/src/71_ai/10_language-model.ts +2 -2
  26. package/ai-docs/src/71_ai/20_tools.ts +2 -2
  27. package/ai-docs/src/71_ai/30_chat.ts +2 -2
  28. package/ai-docs/src/80_cluster/10_entities.ts +3 -3
  29. package/dist/OpenAiClient.d.ts +18 -9
  30. package/dist/OpenAiClient.d.ts.map +1 -1
  31. package/dist/OpenAiClient.js +9 -16
  32. package/dist/OpenAiClient.js.map +1 -1
  33. package/dist/OpenAiConfig.d.ts +1 -1
  34. package/dist/OpenAiConfig.d.ts.map +1 -1
  35. package/dist/OpenAiEmbeddingModel.d.ts +2 -11
  36. package/dist/OpenAiEmbeddingModel.d.ts.map +1 -1
  37. package/dist/OpenAiEmbeddingModel.js +3 -3
  38. package/dist/OpenAiEmbeddingModel.js.map +1 -1
  39. package/dist/OpenAiError.d.ts +1 -1
  40. package/dist/OpenAiError.d.ts.map +1 -1
  41. package/dist/OpenAiLanguageModel.d.ts +4 -14
  42. package/dist/OpenAiLanguageModel.d.ts.map +1 -1
  43. package/dist/OpenAiLanguageModel.js +11 -8
  44. package/dist/OpenAiLanguageModel.js.map +1 -1
  45. package/dist/OpenAiTelemetry.d.ts +9 -1
  46. package/dist/OpenAiTelemetry.d.ts.map +1 -1
  47. package/dist/OpenAiTelemetry.js +1 -1
  48. package/dist/OpenAiTelemetry.js.map +1 -1
  49. package/dist/internal/errors.js +1 -1
  50. package/dist/internal/errors.js.map +1 -1
  51. package/package.json +3 -3
  52. package/src/OpenAiClient.ts +10 -8
  53. package/src/OpenAiConfig.ts +1 -1
  54. package/src/OpenAiEmbeddingModel.ts +3 -3
  55. package/src/OpenAiError.ts +1 -1
  56. package/src/OpenAiLanguageModel.ts +18 -14
  57. package/src/OpenAiTelemetry.ts +1 -1
  58. package/src/internal/errors.ts +6 -6
  59. package/src/internal/utilities.ts +1 -1
@@ -8,11 +8,20 @@
8
8
  *
9
9
  * @since 4.0.0
10
10
  */
11
+ import * as AiError from "effect/ai/AiError"
12
+ import * as LanguageModel from "effect/ai/LanguageModel"
13
+ import * as AiModel from "effect/ai/Model"
14
+ import { toCodecOpenAI } from "effect/ai/OpenAiStructuredOutput"
15
+ import type * as Prompt from "effect/ai/Prompt"
16
+ import type * as Response from "effect/ai/Response"
17
+ import * as Tool from "effect/ai/Tool"
11
18
  import * as Context from "effect/Context"
12
19
  import * as DateTime from "effect/DateTime"
13
20
  import * as Effect from "effect/Effect"
14
- import * as Encoding from "effect/Encoding"
21
+ import * as Base64 from "effect/encoding/Base64"
15
22
  import { dual } from "effect/Function"
23
+ import type * as HttpClientRequest from "effect/http/HttpClientRequest"
24
+ import type * as HttpClientResponse from "effect/http/HttpClientResponse"
16
25
  import * as Layer from "effect/Layer"
17
26
  import * as Option from "effect/Option"
18
27
  import * as Predicate from "effect/Predicate"
@@ -23,15 +32,6 @@ import * as AST from "effect/SchemaAST"
23
32
  import * as Stream from "effect/Stream"
24
33
  import type { Span } from "effect/Tracer"
25
34
  import type { DeepMutable, Simplify } from "effect/Types"
26
- import * as AiError from "effect/unstable/ai/AiError"
27
- import * as LanguageModel from "effect/unstable/ai/LanguageModel"
28
- import * as AiModel from "effect/unstable/ai/Model"
29
- import { toCodecOpenAI } from "effect/unstable/ai/OpenAiStructuredOutput"
30
- import type * as Prompt from "effect/unstable/ai/Prompt"
31
- import type * as Response from "effect/unstable/ai/Response"
32
- import * as Tool from "effect/unstable/ai/Tool"
33
- import type * as HttpClientRequest from "effect/unstable/http/HttpClientRequest"
34
- import type * as HttpClientResponse from "effect/unstable/http/HttpClientResponse"
35
35
  import * as InternalUtilities from "./internal/utilities.ts"
36
36
  import {
37
37
  type Annotation,
@@ -123,7 +123,7 @@ export class Config extends Context.Service<
123
123
  // Provider Options / Metadata
124
124
  // =============================================================================
125
125
 
126
- declare module "effect/unstable/ai/Prompt" {
126
+ declare module "effect/ai/Prompt" {
127
127
  /**
128
128
  * OpenAI-compatible options for file prompt parts.
129
129
  *
@@ -237,7 +237,7 @@ declare module "effect/unstable/ai/Prompt" {
237
237
  }
238
238
  }
239
239
 
240
- declare module "effect/unstable/ai/Response" {
240
+ declare module "effect/ai/Response" {
241
241
  /**
242
242
  * OpenAI-compatible metadata attached to a complete text response part.
243
243
  *
@@ -861,7 +861,7 @@ const prepareMessages = Effect.fnUntraced(
861
861
  const imageUrl = part.data instanceof URL
862
862
  ? part.data.toString()
863
863
  : part.data instanceof Uint8Array
864
- ? `data:${mediaType};base64,${Encoding.encodeBase64(part.data)}`
864
+ ? `data:${mediaType};base64,${Base64.encode(part.data)}`
865
865
  : /^(data:|https?:\/\/)/i.test(part.data)
866
866
  ? part.data
867
867
  : `data:${mediaType};base64,${part.data}`
@@ -877,7 +877,7 @@ const prepareMessages = Effect.fnUntraced(
877
877
  }
878
878
 
879
879
  if (part.data instanceof Uint8Array) {
880
- const base64 = Encoding.encodeBase64(part.data)
880
+ const base64 = Base64.encode(part.data)
881
881
  const fileName = part.fileName ?? `part-${index}.pdf`
882
882
  const fileData = `data:application/pdf;base64,${base64}`
883
883
  content.push({ type: "input_file", filename: fileName, file_data: fileData })
@@ -1515,6 +1515,10 @@ const transformToolCallParams = Effect.fnUntraced(function*<Tools extends Readon
1515
1515
  })
1516
1516
  }
1517
1517
 
1518
+ if (Tool.isDynamic(tool) && tool.jsonSchema !== undefined) {
1519
+ return toolParams
1520
+ }
1521
+
1518
1522
  const { codec } = yield* tryCodecTransform(tool.parametersSchema, "makeResponse")
1519
1523
 
1520
1524
  // Normalize valid parameters; leave invalid ones for Toolkit.
@@ -6,11 +6,11 @@
6
6
  *
7
7
  * @since 4.0.0
8
8
  */
9
+ import * as Telemetry from "effect/ai/Telemetry"
9
10
  import { dual } from "effect/Function"
10
11
  import * as String from "effect/String"
11
12
  import type { Span } from "effect/Tracer"
12
13
  import type { Simplify } from "effect/Types"
13
- import * as Telemetry from "effect/unstable/ai/Telemetry"
14
14
 
15
15
  /**
16
16
  * The attributes used to describe telemetry in the context of Generative
@@ -1,19 +1,19 @@
1
+ import * as AiError from "effect/ai/AiError"
2
+ import type * as Response from "effect/ai/Response"
1
3
  import * as Arr from "effect/Array"
2
4
  import * as Duration from "effect/Duration"
3
5
  import * as Effect from "effect/Effect"
6
+ import type * as Sse from "effect/encoding/Sse"
4
7
  import { dual } from "effect/Function"
8
+ import type * as HttpClientError from "effect/http/HttpClientError"
9
+ import type * as HttpClientRequest from "effect/http/HttpClientRequest"
10
+ import type * as HttpClientResponse from "effect/http/HttpClientResponse"
5
11
  import * as Number from "effect/Number"
6
12
  import * as Option from "effect/Option"
7
13
  import * as Redactable from "effect/Redactable"
8
14
  import * as Schema from "effect/Schema"
9
15
  import * as SchemaTransformation from "effect/SchemaTransformation"
10
16
  import * as String from "effect/String"
11
- import * as AiError from "effect/unstable/ai/AiError"
12
- import type * as Response from "effect/unstable/ai/Response"
13
- import type * as Sse from "effect/unstable/encoding/Sse"
14
- import type * as HttpClientError from "effect/unstable/http/HttpClientError"
15
- import type * as HttpClientRequest from "effect/unstable/http/HttpClientRequest"
16
- import type * as HttpClientResponse from "effect/unstable/http/HttpClientResponse"
17
17
  import type { OpenAiErrorMetadata } from "../OpenAiError.ts"
18
18
 
19
19
  /** @internal */
@@ -1,4 +1,4 @@
1
- import type * as Response from "effect/unstable/ai/Response"
1
+ import type * as Response from "effect/ai/Response"
2
2
 
3
3
  const finishReasonMap: Record<string, Response.FinishReason> = {
4
4
  content_filter: "content-filter",