@effect/ai-openrouter 4.0.0-beta.70 → 4.0.0-beta.72
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/OpenRouterClient.d.ts +57 -6
- package/dist/OpenRouterClient.d.ts.map +1 -1
- package/dist/OpenRouterClient.js +55 -4
- package/dist/OpenRouterClient.js.map +1 -1
- package/dist/OpenRouterConfig.d.ts +87 -13
- package/dist/OpenRouterConfig.d.ts.map +1 -1
- package/dist/OpenRouterConfig.js +51 -13
- package/dist/OpenRouterConfig.js.map +1 -1
- package/dist/OpenRouterLanguageModel.d.ts +99 -4
- package/dist/OpenRouterLanguageModel.d.ts.map +1 -1
- package/dist/OpenRouterLanguageModel.js +106 -20
- package/dist/OpenRouterLanguageModel.js.map +1 -1
- package/dist/index.d.ts +0 -65
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -65
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/OpenRouterClient.ts +57 -6
- package/src/OpenRouterConfig.ts +123 -13
- package/src/OpenRouterLanguageModel.ts +163 -21
- package/src/index.ts +0 -65
|
@@ -69,7 +69,16 @@ export interface Service {
|
|
|
69
69
|
export type ChatStreamingResponseChunkData = typeof Generated.ChatStreamingResponseChunk.fields.data.Type;
|
|
70
70
|
declare const OpenRouterClient_base: Context.ServiceClass<OpenRouterClient, "@effect/ai-openrouter/OpenRouterClient", Service>;
|
|
71
71
|
/**
|
|
72
|
-
* Service
|
|
72
|
+
* Service tag for the OpenRouter client.
|
|
73
|
+
*
|
|
74
|
+
* **When to use**
|
|
75
|
+
*
|
|
76
|
+
* Use when accessing or providing the OpenRouter client service through
|
|
77
|
+
* Effect's context.
|
|
78
|
+
*
|
|
79
|
+
* @see {@link make} for constructing an OpenRouter client effectfully
|
|
80
|
+
* @see {@link layer} for providing a client from explicit options
|
|
81
|
+
* @see {@link layerConfig} for providing a client from `Config`
|
|
73
82
|
*
|
|
74
83
|
* @category services
|
|
75
84
|
* @since 4.0.0
|
|
@@ -77,7 +86,7 @@ declare const OpenRouterClient_base: Context.ServiceClass<OpenRouterClient, "@ef
|
|
|
77
86
|
export declare class OpenRouterClient extends OpenRouterClient_base {
|
|
78
87
|
}
|
|
79
88
|
/**
|
|
80
|
-
* Configuration
|
|
89
|
+
* Configuration for creating an OpenRouter client.
|
|
81
90
|
*
|
|
82
91
|
* @category models
|
|
83
92
|
* @since 4.0.0
|
|
@@ -98,12 +107,33 @@ export type Options = {
|
|
|
98
107
|
*
|
|
99
108
|
* **When to use**
|
|
100
109
|
*
|
|
101
|
-
* Use
|
|
110
|
+
* Use to add middleware, logging, or custom request/response handling.
|
|
102
111
|
*/
|
|
103
112
|
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined;
|
|
104
113
|
};
|
|
105
114
|
/**
|
|
106
|
-
* Creates an OpenRouter client service
|
|
115
|
+
* Creates an OpenRouter client service from explicit options.
|
|
116
|
+
*
|
|
117
|
+
* **When to use**
|
|
118
|
+
*
|
|
119
|
+
* Use to construct the OpenRouter client service inside an effect when you need
|
|
120
|
+
* the service value directly.
|
|
121
|
+
*
|
|
122
|
+
* **Details**
|
|
123
|
+
*
|
|
124
|
+
* The returned service uses the current `HttpClient`, prepends `apiUrl` or
|
|
125
|
+
* `https://openrouter.ai/api/v1`, adds the bearer token and optional
|
|
126
|
+
* `HTTP-Referer` and `X-Title` headers, accepts JSON responses, and applies
|
|
127
|
+
* `transformClient` when provided.
|
|
128
|
+
*
|
|
129
|
+
* **Gotchas**
|
|
130
|
+
*
|
|
131
|
+
* Scoped `OpenRouterConfig.withClientTransform` applies to generated client
|
|
132
|
+
* request methods. Streaming chat completion requests are sent directly by this
|
|
133
|
+
* module and do not read that scoped transform.
|
|
134
|
+
*
|
|
135
|
+
* @see {@link layer} for providing this client from explicit options
|
|
136
|
+
* @see {@link layerConfig} for loading client settings from `Config`
|
|
107
137
|
*
|
|
108
138
|
* @category constructors
|
|
109
139
|
* @since 4.0.0
|
|
@@ -112,13 +142,34 @@ export declare const make: (options: Options) => Effect.Effect<Service, never, H
|
|
|
112
142
|
/**
|
|
113
143
|
* Creates a layer for the OpenRouter client with the given options.
|
|
114
144
|
*
|
|
145
|
+
* **When to use**
|
|
146
|
+
*
|
|
147
|
+
* Use when you already have the OpenRouter client options in code and want to
|
|
148
|
+
* provide `OpenRouterClient` as a layer.
|
|
149
|
+
*
|
|
150
|
+
* @see {@link make} for constructing the client service effectfully
|
|
151
|
+
* @see {@link layerConfig} for loading client settings from `Config`
|
|
152
|
+
*
|
|
115
153
|
* @category layers
|
|
116
154
|
* @since 4.0.0
|
|
117
155
|
*/
|
|
118
156
|
export declare const layer: (options: Options) => Layer.Layer<OpenRouterClient, never, HttpClient.HttpClient>;
|
|
119
157
|
/**
|
|
120
|
-
* Creates a layer for the OpenRouter client
|
|
121
|
-
*
|
|
158
|
+
* Creates a layer for the OpenRouter client from provided `Config` values.
|
|
159
|
+
*
|
|
160
|
+
* **When to use**
|
|
161
|
+
*
|
|
162
|
+
* Use when OpenRouter client settings should be read from Effect `Config`
|
|
163
|
+
* values while providing `OpenRouterClient` as a layer.
|
|
164
|
+
*
|
|
165
|
+
* **Details**
|
|
166
|
+
*
|
|
167
|
+
* Only config values supplied in `options` are loaded. Omitted fields are
|
|
168
|
+
* passed to `make` as `undefined`, and `transformClient` is forwarded as a
|
|
169
|
+
* plain option.
|
|
170
|
+
*
|
|
171
|
+
* @see {@link make} for constructing the client service effectfully
|
|
172
|
+
* @see {@link layer} for providing the client from already-resolved options
|
|
122
173
|
*
|
|
123
174
|
* @category layers
|
|
124
175
|
* @since 4.0.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenRouterClient.d.ts","sourceRoot":"","sources":["../src/OpenRouterClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,K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AA;IAElF;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;IAEnD;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;IAEzD;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;IAEtD;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,UAAU,KAAK,UAAU,CAAC,UAAU,CAAC,GAAG,SAAS,CAAA;CAClG,KAAG,KAAK,CAAC,KAAK,CAAC,gBAAgB,EAAE,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,UAAU,CAwBxE,CAAA"}
|
package/dist/OpenRouterClient.js
CHANGED
|
@@ -16,7 +16,16 @@ import { OpenRouterConfig } from "./OpenRouterConfig.js";
|
|
|
16
16
|
// Service Identifier
|
|
17
17
|
// =============================================================================
|
|
18
18
|
/**
|
|
19
|
-
* Service
|
|
19
|
+
* Service tag for the OpenRouter client.
|
|
20
|
+
*
|
|
21
|
+
* **When to use**
|
|
22
|
+
*
|
|
23
|
+
* Use when accessing or providing the OpenRouter client service through
|
|
24
|
+
* Effect's context.
|
|
25
|
+
*
|
|
26
|
+
* @see {@link make} for constructing an OpenRouter client effectfully
|
|
27
|
+
* @see {@link layer} for providing a client from explicit options
|
|
28
|
+
* @see {@link layerConfig} for providing a client from `Config`
|
|
20
29
|
*
|
|
21
30
|
* @category services
|
|
22
31
|
* @since 4.0.0
|
|
@@ -26,7 +35,28 @@ export class OpenRouterClient extends /*#__PURE__*/Context.Service()("@effect/ai
|
|
|
26
35
|
// Constructor
|
|
27
36
|
// =============================================================================
|
|
28
37
|
/**
|
|
29
|
-
* Creates an OpenRouter client service
|
|
38
|
+
* Creates an OpenRouter client service from explicit options.
|
|
39
|
+
*
|
|
40
|
+
* **When to use**
|
|
41
|
+
*
|
|
42
|
+
* Use to construct the OpenRouter client service inside an effect when you need
|
|
43
|
+
* the service value directly.
|
|
44
|
+
*
|
|
45
|
+
* **Details**
|
|
46
|
+
*
|
|
47
|
+
* The returned service uses the current `HttpClient`, prepends `apiUrl` or
|
|
48
|
+
* `https://openrouter.ai/api/v1`, adds the bearer token and optional
|
|
49
|
+
* `HTTP-Referer` and `X-Title` headers, accepts JSON responses, and applies
|
|
50
|
+
* `transformClient` when provided.
|
|
51
|
+
*
|
|
52
|
+
* **Gotchas**
|
|
53
|
+
*
|
|
54
|
+
* Scoped `OpenRouterConfig.withClientTransform` applies to generated client
|
|
55
|
+
* request methods. Streaming chat completion requests are sent directly by this
|
|
56
|
+
* module and do not read that scoped transform.
|
|
57
|
+
*
|
|
58
|
+
* @see {@link layer} for providing this client from explicit options
|
|
59
|
+
* @see {@link layerConfig} for loading client settings from `Config`
|
|
30
60
|
*
|
|
31
61
|
* @category constructors
|
|
32
62
|
* @since 4.0.0
|
|
@@ -87,13 +117,34 @@ export const make = /*#__PURE__*/Effect.fnUntraced(function* (options) {
|
|
|
87
117
|
/**
|
|
88
118
|
* Creates a layer for the OpenRouter client with the given options.
|
|
89
119
|
*
|
|
120
|
+
* **When to use**
|
|
121
|
+
*
|
|
122
|
+
* Use when you already have the OpenRouter client options in code and want to
|
|
123
|
+
* provide `OpenRouterClient` as a layer.
|
|
124
|
+
*
|
|
125
|
+
* @see {@link make} for constructing the client service effectfully
|
|
126
|
+
* @see {@link layerConfig} for loading client settings from `Config`
|
|
127
|
+
*
|
|
90
128
|
* @category layers
|
|
91
129
|
* @since 4.0.0
|
|
92
130
|
*/
|
|
93
131
|
export const layer = options => Layer.effect(OpenRouterClient, make(options));
|
|
94
132
|
/**
|
|
95
|
-
* Creates a layer for the OpenRouter client
|
|
96
|
-
*
|
|
133
|
+
* Creates a layer for the OpenRouter client from provided `Config` values.
|
|
134
|
+
*
|
|
135
|
+
* **When to use**
|
|
136
|
+
*
|
|
137
|
+
* Use when OpenRouter client settings should be read from Effect `Config`
|
|
138
|
+
* values while providing `OpenRouterClient` as a layer.
|
|
139
|
+
*
|
|
140
|
+
* **Details**
|
|
141
|
+
*
|
|
142
|
+
* Only config values supplied in `options` are loaded. Omitted fields are
|
|
143
|
+
* passed to `make` as `undefined`, and `transformClient` is forwarded as a
|
|
144
|
+
* plain option.
|
|
145
|
+
*
|
|
146
|
+
* @see {@link make} for constructing the client service effectfully
|
|
147
|
+
* @see {@link layer} for providing the client from already-resolved options
|
|
97
148
|
*
|
|
98
149
|
* @category layers
|
|
99
150
|
* @since 4.0.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenRouterClient.js","names":["Context","Effect","identity","Layer","Predicate","Schema","Stream","Sse","HttpBody","HttpClient","HttpClientRequest","Generated","Errors","OpenRouterConfig","OpenRouterClient","Service","make","fnUntraced","options","baseClient","httpClient","pipe","mapRequest","request","prependUrl","apiUrl","apiKey","bearerToken","siteReferrer","setHeader","siteTitle","acceptJson","transformClient","httpClientOk","filterStatusOk","client","config","getOrUndefined","isNotUndefined","createChatCompletion","payload","sendChatCompletionRequest","includeResponse","catchTags","SendChatCompletionRequest400","error","fail","mapClientError","SendChatCompletionRequest401","SendChatCompletionRequest429","SendChatCompletionRequest500","HttpClientError","mapHttpClientError","SchemaError","mapSchemaError","buildChatCompletionStream","response","stream","decodeText","pipeThroughChannel","decode","mapEffect","event","decodeChatCompletionSseData","data","takeWhile","Retry","die","fromEffect","createChatCompletionStream","execute","post","body","jsonUnsafe","stream_options","include_usage","map","catchTag","of","layer","effect","layerConfig","gen","undefined","ChatStreamingResponseChunkDataFromString","fromJsonString","ChatStreamingResponseChunk","fields","decodeChatStreamingResponseChunkData","decodeUnknownEffect","succeed"],"sources":["../src/OpenRouterClient.ts"],"sourcesContent":[null],"mappings":"AA0BA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAE7C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,OAAO,KAAKC,GAAG,MAAM,8BAA8B;AACnD,OAAO,KAAKC,QAAQ,MAAM,+BAA+B;AACzD,OAAO,KAAKC,UAAU,MAAM,iCAAiC;AAC7D,OAAO,KAAKC,iBAAiB,MAAM,wCAAwC;AAE3E,OAAO,KAAKC,SAAS,MAAM,gBAAgB;AAC3C,OAAO,KAAKC,MAAM,MAAM,sBAAsB;AAC9C,SAASC,gBAAgB,QAAQ,uBAAuB;AAmDxD;AACA;AACA;AAEA
|
|
1
|
+
{"version":3,"file":"OpenRouterClient.js","names":["Context","Effect","identity","Layer","Predicate","Schema","Stream","Sse","HttpBody","HttpClient","HttpClientRequest","Generated","Errors","OpenRouterConfig","OpenRouterClient","Service","make","fnUntraced","options","baseClient","httpClient","pipe","mapRequest","request","prependUrl","apiUrl","apiKey","bearerToken","siteReferrer","setHeader","siteTitle","acceptJson","transformClient","httpClientOk","filterStatusOk","client","config","getOrUndefined","isNotUndefined","createChatCompletion","payload","sendChatCompletionRequest","includeResponse","catchTags","SendChatCompletionRequest400","error","fail","mapClientError","SendChatCompletionRequest401","SendChatCompletionRequest429","SendChatCompletionRequest500","HttpClientError","mapHttpClientError","SchemaError","mapSchemaError","buildChatCompletionStream","response","stream","decodeText","pipeThroughChannel","decode","mapEffect","event","decodeChatCompletionSseData","data","takeWhile","Retry","die","fromEffect","createChatCompletionStream","execute","post","body","jsonUnsafe","stream_options","include_usage","map","catchTag","of","layer","effect","layerConfig","gen","undefined","ChatStreamingResponseChunkDataFromString","fromJsonString","ChatStreamingResponseChunk","fields","decodeChatStreamingResponseChunkData","decodeUnknownEffect","succeed"],"sources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S,CAACkC,cAAc,CAACpB,OAAO,EAAEY,SAAS,CAAC,GAC1D,OAAOZ,OAAO,CAACY,SAAS,GACxBqD,SAAS;EACb,OAAO,OAAOnE,IAAI,CAAC;IACjBU,MAAM;IACND,MAAM;IACNG,YAAY;IACZE,SAAS;IACTE,eAAe,EAAEd,OAAO,EAAEc;GAC3B,CAAC;AACJ,CAAC,CAAC,CACH;AAEH;AACA;AACA;AAEA,MAAMoD,wCAAwC,gBAAG/E,MAAM,CAACgF,cAAc,CAAC1E,SAAS,CAAC2E,0BAA0B,CAACC,MAAM,CAACvB,IAAI,CAAC;AACxH,MAAMwB,oCAAoC,gBAAGnF,MAAM,CAACoF,mBAAmB,CAACL,wCAAwC,CAAC;AAEjH,MAAMrB,2BAA2B,GAC/BC,IAAY,IAEZA,IAAI,KAAK,QAAQ,GACb/D,MAAM,CAACyF,OAAO,CAAC1B,IAAI,CAAC,GACpBwB,oCAAoC,CAACxB,IAAI,CAAC","ignoreList":[]}
|
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `OpenRouterConfig` module provides contextual configuration for
|
|
3
|
-
* OpenRouter
|
|
4
|
-
*
|
|
2
|
+
* The `OpenRouterConfig` module provides scoped contextual configuration for
|
|
3
|
+
* OpenRouter request execution. It lets a workflow customize the HTTP client
|
|
4
|
+
* used by generated OpenRouter request methods without rebuilding the
|
|
5
|
+
* `OpenRouterClient` layer.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* **Mental model**
|
|
8
|
+
*
|
|
9
|
+
* - {@link OpenRouterConfig} is a context service carrying optional
|
|
10
|
+
* OpenRouter-specific request configuration
|
|
11
|
+
* - {@link withClientTransform} provides that service around one effect
|
|
12
|
+
* - Generated request methods read the current context and apply the transform
|
|
13
|
+
* to their `HttpClient`
|
|
14
|
+
* - The scoped configuration only applies while the returned effect is run
|
|
15
|
+
*
|
|
16
|
+
* **Common tasks**
|
|
17
|
+
*
|
|
18
|
+
* - Add request logging, retries, proxy routing, headers, or test doubles with
|
|
19
|
+
* {@link withClientTransform}
|
|
20
|
+
* - Scope OpenRouter client customization to one workflow without changing the
|
|
21
|
+
* shared client layer
|
|
11
22
|
*
|
|
12
23
|
* **Gotchas**
|
|
13
24
|
*
|
|
14
|
-
* - Each
|
|
15
|
-
* transform for the
|
|
16
|
-
* behaviors should apply
|
|
25
|
+
* - Each {@link withClientTransform} call replaces the current scoped
|
|
26
|
+
* transform for the supplied effect; compose transforms manually when both
|
|
27
|
+
* behaviors should apply
|
|
17
28
|
* - The transform receives and returns an `HttpClient`, so it should preserve
|
|
18
|
-
* the OpenRouter
|
|
29
|
+
* the OpenRouter request contract while adding behavior around it
|
|
30
|
+
* - Streaming chat completion requests are sent directly by `OpenRouterClient`
|
|
31
|
+
* and do not read this scoped transform
|
|
19
32
|
*
|
|
20
33
|
* @since 4.0.0
|
|
21
34
|
*/
|
|
@@ -24,9 +37,16 @@ import * as Effect from "effect/Effect";
|
|
|
24
37
|
import type { HttpClient } from "effect/unstable/http/HttpClient";
|
|
25
38
|
declare const OpenRouterConfig_base: Context.ServiceClass<OpenRouterConfig, "@effect/ai-openrouter/OpenRouterConfig", OpenRouterConfig.Service>;
|
|
26
39
|
/**
|
|
27
|
-
* Context service
|
|
40
|
+
* Context service for scoped OpenRouter provider configuration used by client
|
|
28
41
|
* operations.
|
|
29
42
|
*
|
|
43
|
+
* **When to use**
|
|
44
|
+
*
|
|
45
|
+
* Use as the context service tag when manually providing or reading scoped
|
|
46
|
+
* OpenRouter provider configuration in an Effect context.
|
|
47
|
+
*
|
|
48
|
+
* @see {@link withClientTransform} for scoping an HTTP client transformation
|
|
49
|
+
*
|
|
30
50
|
* @category services
|
|
31
51
|
* @since 4.0.0
|
|
32
52
|
*/
|
|
@@ -59,6 +79,24 @@ export declare namespace OpenRouterConfig {
|
|
|
59
79
|
* Provides a scoped transform for the OpenRouter HTTP client used by provider
|
|
60
80
|
* operations.
|
|
61
81
|
*
|
|
82
|
+
* **When to use**
|
|
83
|
+
*
|
|
84
|
+
* Use when a single effect or workflow needs temporary OpenRouter HTTP client
|
|
85
|
+
* customization without rebuilding the client layer.
|
|
86
|
+
*
|
|
87
|
+
* **Details**
|
|
88
|
+
*
|
|
89
|
+
* Supports both data-first and data-last forms. The transform is stored in the
|
|
90
|
+
* scoped `OpenRouterConfig` service and read by generated OpenRouter request
|
|
91
|
+
* operations while running the supplied effect.
|
|
92
|
+
*
|
|
93
|
+
* **Gotchas**
|
|
94
|
+
*
|
|
95
|
+
* If a transform is already present in the scoped config, this helper replaces
|
|
96
|
+
* it. Compose transforms manually when both should apply. Streaming chat
|
|
97
|
+
* completion requests are sent directly by `OpenRouterClient.make` and do not
|
|
98
|
+
* read this scoped transform.
|
|
99
|
+
*
|
|
62
100
|
* @category configuration
|
|
63
101
|
* @since 4.0.0
|
|
64
102
|
*/
|
|
@@ -67,6 +105,24 @@ export declare const withClientTransform: {
|
|
|
67
105
|
* Provides a scoped transform for the OpenRouter HTTP client used by provider
|
|
68
106
|
* operations.
|
|
69
107
|
*
|
|
108
|
+
* **When to use**
|
|
109
|
+
*
|
|
110
|
+
* Use when a single effect or workflow needs temporary OpenRouter HTTP client
|
|
111
|
+
* customization without rebuilding the client layer.
|
|
112
|
+
*
|
|
113
|
+
* **Details**
|
|
114
|
+
*
|
|
115
|
+
* Supports both data-first and data-last forms. The transform is stored in the
|
|
116
|
+
* scoped `OpenRouterConfig` service and read by generated OpenRouter request
|
|
117
|
+
* operations while running the supplied effect.
|
|
118
|
+
*
|
|
119
|
+
* **Gotchas**
|
|
120
|
+
*
|
|
121
|
+
* If a transform is already present in the scoped config, this helper replaces
|
|
122
|
+
* it. Compose transforms manually when both should apply. Streaming chat
|
|
123
|
+
* completion requests are sent directly by `OpenRouterClient.make` and do not
|
|
124
|
+
* read this scoped transform.
|
|
125
|
+
*
|
|
70
126
|
* @category configuration
|
|
71
127
|
* @since 4.0.0
|
|
72
128
|
*/
|
|
@@ -75,6 +131,24 @@ export declare const withClientTransform: {
|
|
|
75
131
|
* Provides a scoped transform for the OpenRouter HTTP client used by provider
|
|
76
132
|
* operations.
|
|
77
133
|
*
|
|
134
|
+
* **When to use**
|
|
135
|
+
*
|
|
136
|
+
* Use when a single effect or workflow needs temporary OpenRouter HTTP client
|
|
137
|
+
* customization without rebuilding the client layer.
|
|
138
|
+
*
|
|
139
|
+
* **Details**
|
|
140
|
+
*
|
|
141
|
+
* Supports both data-first and data-last forms. The transform is stored in the
|
|
142
|
+
* scoped `OpenRouterConfig` service and read by generated OpenRouter request
|
|
143
|
+
* operations while running the supplied effect.
|
|
144
|
+
*
|
|
145
|
+
* **Gotchas**
|
|
146
|
+
*
|
|
147
|
+
* If a transform is already present in the scoped config, this helper replaces
|
|
148
|
+
* it. Compose transforms manually when both should apply. Streaming chat
|
|
149
|
+
* completion requests are sent directly by `OpenRouterClient.make` and do not
|
|
150
|
+
* read this scoped transform.
|
|
151
|
+
*
|
|
78
152
|
* @category configuration
|
|
79
153
|
* @since 4.0.0
|
|
80
154
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenRouterConfig.d.ts","sourceRoot":"","sources":["../src/OpenRouterConfig.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"OpenRouterConfig.d.ts","sourceRoot":"","sources":["../src/OpenRouterConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;;AAEjE;;;;;;;;;;;;;GAaG;AACH,qBAAa,gBAAiB,SAAQ,qBAGO;IAC3C;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC,CAGzF;CACF;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,WAAW,gBAAgB,CAAC;IACxC;;;;;;OAMG;IACH,UAAiB,OAAO;QACtB,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,UAAU,KAAK,UAAU,CAAC,GAAG,SAAS,CAAA;KAC5E;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,mBAAmB,EAAE;IAChC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,UAAU,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,CAAC,CAAC,CAAA;IAClH;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,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,CAAA;CAgE1B,CAAA"}
|
package/dist/OpenRouterConfig.js
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `OpenRouterConfig` module provides contextual configuration for
|
|
3
|
-
* OpenRouter
|
|
4
|
-
*
|
|
2
|
+
* The `OpenRouterConfig` module provides scoped contextual configuration for
|
|
3
|
+
* OpenRouter request execution. It lets a workflow customize the HTTP client
|
|
4
|
+
* used by generated OpenRouter request methods without rebuilding the
|
|
5
|
+
* `OpenRouterClient` layer.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* **Mental model**
|
|
8
|
+
*
|
|
9
|
+
* - {@link OpenRouterConfig} is a context service carrying optional
|
|
10
|
+
* OpenRouter-specific request configuration
|
|
11
|
+
* - {@link withClientTransform} provides that service around one effect
|
|
12
|
+
* - Generated request methods read the current context and apply the transform
|
|
13
|
+
* to their `HttpClient`
|
|
14
|
+
* - The scoped configuration only applies while the returned effect is run
|
|
15
|
+
*
|
|
16
|
+
* **Common tasks**
|
|
17
|
+
*
|
|
18
|
+
* - Add request logging, retries, proxy routing, headers, or test doubles with
|
|
19
|
+
* {@link withClientTransform}
|
|
20
|
+
* - Scope OpenRouter client customization to one workflow without changing the
|
|
21
|
+
* shared client layer
|
|
11
22
|
*
|
|
12
23
|
* **Gotchas**
|
|
13
24
|
*
|
|
14
|
-
* - Each
|
|
15
|
-
* transform for the
|
|
16
|
-
* behaviors should apply
|
|
25
|
+
* - Each {@link withClientTransform} call replaces the current scoped
|
|
26
|
+
* transform for the supplied effect; compose transforms manually when both
|
|
27
|
+
* behaviors should apply
|
|
17
28
|
* - The transform receives and returns an `HttpClient`, so it should preserve
|
|
18
|
-
* the OpenRouter
|
|
29
|
+
* the OpenRouter request contract while adding behavior around it
|
|
30
|
+
* - Streaming chat completion requests are sent directly by `OpenRouterClient`
|
|
31
|
+
* and do not read this scoped transform
|
|
19
32
|
*
|
|
20
33
|
* @since 4.0.0
|
|
21
34
|
*/
|
|
@@ -23,9 +36,16 @@ import * as Context from "effect/Context";
|
|
|
23
36
|
import * as Effect from "effect/Effect";
|
|
24
37
|
import { dual } from "effect/Function";
|
|
25
38
|
/**
|
|
26
|
-
* Context service
|
|
39
|
+
* Context service for scoped OpenRouter provider configuration used by client
|
|
27
40
|
* operations.
|
|
28
41
|
*
|
|
42
|
+
* **When to use**
|
|
43
|
+
*
|
|
44
|
+
* Use as the context service tag when manually providing or reading scoped
|
|
45
|
+
* OpenRouter provider configuration in an Effect context.
|
|
46
|
+
*
|
|
47
|
+
* @see {@link withClientTransform} for scoping an HTTP client transformation
|
|
48
|
+
*
|
|
29
49
|
* @category services
|
|
30
50
|
* @since 4.0.0
|
|
31
51
|
*/
|
|
@@ -41,6 +61,24 @@ export class OpenRouterConfig extends /*#__PURE__*/Context.Service()("@effect/ai
|
|
|
41
61
|
* Provides a scoped transform for the OpenRouter HTTP client used by provider
|
|
42
62
|
* operations.
|
|
43
63
|
*
|
|
64
|
+
* **When to use**
|
|
65
|
+
*
|
|
66
|
+
* Use when a single effect or workflow needs temporary OpenRouter HTTP client
|
|
67
|
+
* customization without rebuilding the client layer.
|
|
68
|
+
*
|
|
69
|
+
* **Details**
|
|
70
|
+
*
|
|
71
|
+
* Supports both data-first and data-last forms. The transform is stored in the
|
|
72
|
+
* scoped `OpenRouterConfig` service and read by generated OpenRouter request
|
|
73
|
+
* operations while running the supplied effect.
|
|
74
|
+
*
|
|
75
|
+
* **Gotchas**
|
|
76
|
+
*
|
|
77
|
+
* If a transform is already present in the scoped config, this helper replaces
|
|
78
|
+
* it. Compose transforms manually when both should apply. Streaming chat
|
|
79
|
+
* completion requests are sent directly by `OpenRouterClient.make` and do not
|
|
80
|
+
* read this scoped transform.
|
|
81
|
+
*
|
|
44
82
|
* @category configuration
|
|
45
83
|
* @since 4.0.0
|
|
46
84
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenRouterConfig.js","names":["Context","Effect","dual","OpenRouterConfig","Service","getOrUndefined","map","context","services","mapUnsafe","get","key","withClientTransform","self","transformClient","flatMap","config","provideService"],"sources":["../src/OpenRouterConfig.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"OpenRouterConfig.js","names":["Context","Effect","dual","OpenRouterConfig","Service","getOrUndefined","map","context","services","mapUnsafe","get","key","withClientTransform","self","transformClient","flatMap","config","provideService"],"sources":["../src/OpenRouterConfig.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,SAASC,IAAI,QAAQ,iBAAiB;AAGtC;;;;;;;;;;;;;;AAcA,OAAM,MAAOC,gBAAiB,sBAAQH,OAAO,CAACI,OAAO,EAGlD,CAAC,wCAAwC,CAAC;EAC3C;;;;;EAKA,OAAgBC,cAAc,gBAA+DJ,MAAM,CAACK,GAAG,cACrGL,MAAM,CAACM,OAAO,EAAS,EACtBC,QAAQ,IAAKA,QAAQ,CAACC,SAAS,CAACC,GAAG,CAACP,gBAAgB,CAACQ,GAAG,CAAC,CAC3D;;AAqBH;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,OAAO,MAAMC,mBAAmB,gBAwD5BV,IAAI,CAyDN,CAAC,EACD,CAACW,IAAI,EAAEC,eAAe,KACpBb,MAAM,CAACc,OAAO,CACZZ,gBAAgB,CAACE,cAAc,EAC9BW,MAAM,IAAKf,MAAM,CAACgB,cAAc,CAACJ,IAAI,EAAEV,gBAAgB,EAAE;EAAE,GAAGa,MAAM;EAAEF;AAAe,CAAE,CAAC,CAC1F,CACJ","ignoreList":[]}
|
|
@@ -99,7 +99,14 @@ declare const Config_base: Context.ServiceClass<Config, "@effect/ai-openrouter/O
|
|
|
99
99
|
readonly strictJsonSchema?: boolean | undefined | undefined;
|
|
100
100
|
}>;
|
|
101
101
|
/**
|
|
102
|
-
*
|
|
102
|
+
* Context service for OpenRouter language model configuration.
|
|
103
|
+
*
|
|
104
|
+
* **When to use**
|
|
105
|
+
*
|
|
106
|
+
* Use to provide scoped OpenRouter chat completion defaults or per-operation
|
|
107
|
+
* overrides for an OpenRouter language model service.
|
|
108
|
+
*
|
|
109
|
+
* @see {@link withConfigOverride} for scoping language model request overrides
|
|
103
110
|
*
|
|
104
111
|
* @category services
|
|
105
112
|
* @since 4.0.0
|
|
@@ -222,7 +229,7 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
222
229
|
*
|
|
223
230
|
* **When to use**
|
|
224
231
|
*
|
|
225
|
-
* Use these options to control how text content is sent to OpenRouter.
|
|
232
|
+
* Use when you use these options to control how text content is sent to OpenRouter.
|
|
226
233
|
*
|
|
227
234
|
* @category request
|
|
228
235
|
* @since 4.0.0
|
|
@@ -486,14 +493,51 @@ declare module "effect/unstable/ai/Response" {
|
|
|
486
493
|
}
|
|
487
494
|
}
|
|
488
495
|
/**
|
|
489
|
-
* Creates an
|
|
496
|
+
* Creates an OpenRouter model descriptor that can be provided with
|
|
497
|
+
* `Effect.provide`.
|
|
498
|
+
*
|
|
499
|
+
* **When to use**
|
|
500
|
+
*
|
|
501
|
+
* Use when you want an OpenRouter language model value that carries provider
|
|
502
|
+
* and model metadata and can be supplied directly to an Effect program.
|
|
503
|
+
*
|
|
504
|
+
* **Details**
|
|
505
|
+
*
|
|
506
|
+
* The returned model requires `OpenRouterClient` and provides
|
|
507
|
+
* `LanguageModel.LanguageModel`.
|
|
508
|
+
*
|
|
509
|
+
* @see {@link layer} for creating a `LanguageModel.LanguageModel` layer directly
|
|
510
|
+
* @see {@link make} for constructing the language model service effectfully
|
|
511
|
+
* @see {@link withConfigOverride} for scoping OpenRouter request overrides
|
|
490
512
|
*
|
|
491
513
|
* @category constructors
|
|
492
514
|
* @since 4.0.0
|
|
493
515
|
*/
|
|
494
516
|
export declare const model: (model: string, config?: Omit<typeof Config.Service, "model">) => AiModel.Model<"openai", LanguageModel.LanguageModel, OpenRouterClient>;
|
|
495
517
|
/**
|
|
496
|
-
* Creates an OpenRouter
|
|
518
|
+
* Creates an OpenRouter `LanguageModel` service from a model identifier and
|
|
519
|
+
* optional request defaults.
|
|
520
|
+
*
|
|
521
|
+
* **When to use**
|
|
522
|
+
*
|
|
523
|
+
* Use when an Effect needs to construct a `LanguageModel.Service` value backed
|
|
524
|
+
* by `OpenRouterClient`.
|
|
525
|
+
*
|
|
526
|
+
* **Details**
|
|
527
|
+
*
|
|
528
|
+
* The returned effect requires `OpenRouterClient`. Request defaults from the
|
|
529
|
+
* `config` option are merged with any `Config` service in the context, with
|
|
530
|
+
* context values taking precedence. The service supports both `generateText`
|
|
531
|
+
* and `streamText`.
|
|
532
|
+
*
|
|
533
|
+
* **Gotchas**
|
|
534
|
+
*
|
|
535
|
+
* Provider-defined tools are not supported by this provider integration;
|
|
536
|
+
* requests that include them fail with an `InvalidUserInputError`.
|
|
537
|
+
*
|
|
538
|
+
* @see {@link layer} for providing the service as a `Layer`
|
|
539
|
+
* @see {@link model} for creating a model descriptor for `Effect.provide`
|
|
540
|
+
* @see {@link withConfigOverride} for scoping request defaults around operations
|
|
497
541
|
*
|
|
498
542
|
* @category constructors
|
|
499
543
|
* @since 4.0.0
|
|
@@ -505,6 +549,15 @@ export declare const make: (args_0: {
|
|
|
505
549
|
/**
|
|
506
550
|
* Creates a layer for the OpenRouter language model.
|
|
507
551
|
*
|
|
552
|
+
* **When to use**
|
|
553
|
+
*
|
|
554
|
+
* Use when composing application layers and you want OpenRouter to satisfy
|
|
555
|
+
* `LanguageModel.LanguageModel` while supplying `OpenRouterClient` from another
|
|
556
|
+
* layer.
|
|
557
|
+
*
|
|
558
|
+
* @see {@link make} for constructing the language model service effectfully
|
|
559
|
+
* @see {@link model} for creating a model descriptor for `Effect.provide`
|
|
560
|
+
*
|
|
508
561
|
* @category layers
|
|
509
562
|
* @since 4.0.0
|
|
510
563
|
*/
|
|
@@ -515,6 +568,20 @@ export declare const layer: (options: {
|
|
|
515
568
|
/**
|
|
516
569
|
* Provides config overrides for OpenRouter language model operations.
|
|
517
570
|
*
|
|
571
|
+
* **When to use**
|
|
572
|
+
*
|
|
573
|
+
* Use to apply OpenRouter request configuration to one effect without changing
|
|
574
|
+
* the model's default configuration.
|
|
575
|
+
*
|
|
576
|
+
* **Details**
|
|
577
|
+
*
|
|
578
|
+
* The overrides are merged with any existing `Config` service for the duration
|
|
579
|
+
* of the supplied effect. Fields in `overrides` take precedence over existing
|
|
580
|
+
* config, and the helper supports both pipe form and
|
|
581
|
+
* `withConfigOverride(effect, overrides)`.
|
|
582
|
+
*
|
|
583
|
+
* @see {@link Config} for available OpenRouter request configuration fields
|
|
584
|
+
*
|
|
518
585
|
* @category configuration
|
|
519
586
|
* @since 4.0.0
|
|
520
587
|
*/
|
|
@@ -522,6 +589,20 @@ export declare const withConfigOverride: {
|
|
|
522
589
|
/**
|
|
523
590
|
* Provides config overrides for OpenRouter language model operations.
|
|
524
591
|
*
|
|
592
|
+
* **When to use**
|
|
593
|
+
*
|
|
594
|
+
* Use to apply OpenRouter request configuration to one effect without changing
|
|
595
|
+
* the model's default configuration.
|
|
596
|
+
*
|
|
597
|
+
* **Details**
|
|
598
|
+
*
|
|
599
|
+
* The overrides are merged with any existing `Config` service for the duration
|
|
600
|
+
* of the supplied effect. Fields in `overrides` take precedence over existing
|
|
601
|
+
* config, and the helper supports both pipe form and
|
|
602
|
+
* `withConfigOverride(effect, overrides)`.
|
|
603
|
+
*
|
|
604
|
+
* @see {@link Config} for available OpenRouter request configuration fields
|
|
605
|
+
*
|
|
525
606
|
* @category configuration
|
|
526
607
|
* @since 4.0.0
|
|
527
608
|
*/
|
|
@@ -529,6 +610,20 @@ export declare const withConfigOverride: {
|
|
|
529
610
|
/**
|
|
530
611
|
* Provides config overrides for OpenRouter language model operations.
|
|
531
612
|
*
|
|
613
|
+
* **When to use**
|
|
614
|
+
*
|
|
615
|
+
* Use to apply OpenRouter request configuration to one effect without changing
|
|
616
|
+
* the model's default configuration.
|
|
617
|
+
*
|
|
618
|
+
* **Details**
|
|
619
|
+
*
|
|
620
|
+
* The overrides are merged with any existing `Config` service for the duration
|
|
621
|
+
* of the supplied effect. Fields in `overrides` take precedence over existing
|
|
622
|
+
* config, and the helper supports both pipe form and
|
|
623
|
+
* `withConfigOverride(effect, overrides)`.
|
|
624
|
+
*
|
|
625
|
+
* @see {@link Config} for available OpenRouter request configuration fields
|
|
626
|
+
*
|
|
532
627
|
* @category configuration
|
|
533
628
|
* @since 4.0.0
|
|
534
629
|
*/
|