@effect/ai-openai 0.11.4 → 0.12.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/dist/cjs/Generated.js +284 -334
- package/dist/cjs/Generated.js.map +1 -1
- package/dist/cjs/OpenAiClient.js +4 -1
- package/dist/cjs/OpenAiClient.js.map +1 -1
- package/dist/cjs/OpenAiConfig.js +10 -5
- package/dist/cjs/OpenAiConfig.js.map +1 -1
- package/dist/dts/Generated.d.ts +91 -75
- package/dist/dts/Generated.d.ts.map +1 -1
- package/dist/dts/OpenAiClient.d.ts.map +1 -1
- package/dist/dts/OpenAiConfig.d.ts +22 -58
- package/dist/dts/OpenAiConfig.d.ts.map +1 -1
- package/dist/esm/Generated.js +280 -331
- package/dist/esm/Generated.js.map +1 -1
- package/dist/esm/OpenAiClient.js +4 -1
- package/dist/esm/OpenAiClient.js.map +1 -1
- package/dist/esm/OpenAiConfig.js +9 -3
- package/dist/esm/OpenAiConfig.js.map +1 -1
- package/package.json +5 -5
- package/src/Generated.ts +983 -750
- package/src/OpenAiClient.ts +7 -1
- package/src/OpenAiConfig.ts +53 -8
package/src/OpenAiClient.ts
CHANGED
|
@@ -20,6 +20,7 @@ import * as Option from "effect/Option"
|
|
|
20
20
|
import * as Redacted from "effect/Redacted"
|
|
21
21
|
import * as Stream from "effect/Stream"
|
|
22
22
|
import * as Generated from "./Generated.js"
|
|
23
|
+
import { OpenAiConfig } from "./OpenAiConfig.js"
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* @since 1.0.0
|
|
@@ -79,7 +80,12 @@ export const make = (options: {
|
|
|
79
80
|
options.transformClient ? options.transformClient : identity
|
|
80
81
|
)
|
|
81
82
|
const httpClientOk = HttpClient.filterStatusOk(httpClient)
|
|
82
|
-
const client = Generated.make(httpClient
|
|
83
|
+
const client = Generated.make(httpClient, {
|
|
84
|
+
transformClient: (client) =>
|
|
85
|
+
OpenAiConfig.getOrUndefined.pipe(
|
|
86
|
+
Effect.map((config) => config?.transformClient ? config.transformClient(client) : client)
|
|
87
|
+
)
|
|
88
|
+
})
|
|
83
89
|
const streamRequest = <A = unknown>(request: HttpClientRequest.HttpClientRequest) =>
|
|
84
90
|
httpClientOk.execute(request).pipe(
|
|
85
91
|
Effect.map((r) => r.stream),
|
package/src/OpenAiConfig.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
+
import type { HttpClient } from "@effect/platform/HttpClient"
|
|
4
5
|
import * as Context from "effect/Context"
|
|
5
6
|
import * as Effect from "effect/Effect"
|
|
7
|
+
import { dual } from "effect/Function"
|
|
6
8
|
import type { Simplify } from "effect/Types"
|
|
7
9
|
import type * as Generated from "./Generated.js"
|
|
8
10
|
|
|
@@ -12,14 +14,7 @@ import type * as Generated from "./Generated.js"
|
|
|
12
14
|
*/
|
|
13
15
|
export class OpenAiConfig extends Context.Tag("@effect/ai-openai/OpenAiConfig")<
|
|
14
16
|
OpenAiConfig,
|
|
15
|
-
|
|
16
|
-
Partial<
|
|
17
|
-
Omit<
|
|
18
|
-
typeof Generated.CreateChatCompletionRequest.Encoded,
|
|
19
|
-
"messages" | "tools" | "tool_choice" | "stream" | "stream_options" | "functions"
|
|
20
|
-
>
|
|
21
|
-
>
|
|
22
|
-
>
|
|
17
|
+
OpenAiConfig.Service
|
|
23
18
|
>() {
|
|
24
19
|
/**
|
|
25
20
|
* @since 1.0.0
|
|
@@ -29,3 +24,53 @@ export class OpenAiConfig extends Context.Tag("@effect/ai-openai/OpenAiConfig")<
|
|
|
29
24
|
(context) => context.unsafeMap.get(OpenAiConfig.key)
|
|
30
25
|
)
|
|
31
26
|
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @since 1.0.0
|
|
30
|
+
* @category models
|
|
31
|
+
*/
|
|
32
|
+
export declare namespace OpenAiConfig {
|
|
33
|
+
/**
|
|
34
|
+
* @since 1.0.0
|
|
35
|
+
* @category models
|
|
36
|
+
*/
|
|
37
|
+
export interface Service extends
|
|
38
|
+
Simplify<
|
|
39
|
+
Partial<
|
|
40
|
+
Omit<
|
|
41
|
+
typeof Generated.CreateChatCompletionRequest.Encoded,
|
|
42
|
+
"messages" | "tools" | "tool_choice" | "stream" | "stream_options" | "functions"
|
|
43
|
+
>
|
|
44
|
+
>
|
|
45
|
+
>
|
|
46
|
+
{
|
|
47
|
+
readonly transformClient?: (client: HttpClient) => HttpClient
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @since 1.0.0
|
|
53
|
+
* @category configuration
|
|
54
|
+
*/
|
|
55
|
+
export const withClientTransform = dual<
|
|
56
|
+
/**
|
|
57
|
+
* @since 1.0.0
|
|
58
|
+
* @category configuration
|
|
59
|
+
*/
|
|
60
|
+
(transform: (client: HttpClient) => HttpClient) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>,
|
|
61
|
+
/**
|
|
62
|
+
* @since 1.0.0
|
|
63
|
+
* @category configuration
|
|
64
|
+
*/
|
|
65
|
+
<A, E, R>(
|
|
66
|
+
self: Effect.Effect<A, E, R>,
|
|
67
|
+
transform: (client: HttpClient) => HttpClient
|
|
68
|
+
) => Effect.Effect<A, E, R>
|
|
69
|
+
>(
|
|
70
|
+
2,
|
|
71
|
+
(self, transformClient) =>
|
|
72
|
+
Effect.flatMap(
|
|
73
|
+
OpenAiConfig.getOrUndefined,
|
|
74
|
+
(config) => Effect.provideService(self, OpenAiConfig, { ...config, transformClient })
|
|
75
|
+
)
|
|
76
|
+
)
|