liminal 0.14.0 → 0.15.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/enable.ts CHANGED
@@ -1,11 +1,15 @@
1
- import * as AiTool from "@effect/ai/AiTool"
2
- import type { AiToolkit } from "@effect/ai/AiToolkit"
1
+ import type { AiTool, AnyStructSchema, Handler } from "@effect/ai/AiTool"
3
2
  import * as Effect from "effect/Effect"
3
+ import type { Schema } from "effect/Schema"
4
4
  import { Strand } from "./Strand.ts"
5
5
 
6
- export const enable: <Tools extends AiTool.Any>(
7
- toolkit: AiToolkit<Tools>,
8
- ) => Effect.Effect<void, never, AiTool.Handler<Tools["name"]> | Strand> = (toolkit) =>
6
+ export const enable: <
7
+ K extends string,
8
+ E extends Schema.All,
9
+ R,
10
+ >(
11
+ toolkit: AiTool<K, AnyStructSchema, Schema.Any, E, R>,
12
+ ) => Effect.Effect<void, E, Handler<K> | Strand | R> = (toolkit) =>
9
13
  Effect.map(Strand, ({ tools }) => {
10
- tools.add(toolkit)
14
+ tools.add(toolkit as never)
11
15
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "liminal",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/harrysolovay/liminal.git",
@@ -13,7 +13,8 @@
13
13
  "exports": {
14
14
  ".": "./index.ts",
15
15
  "./package.json": "./package.json",
16
- "./patterns": "./patterns/index.ts"
16
+ "./patterns/coalesce_models": "./patterns/coalesce_models.ts",
17
+ "./patterns/match_gist": "./patterns/match_gist.ts"
17
18
  },
18
19
  "description": "An Effect AI toolkit for conversation state management.",
19
20
  "homepage": "https://liminal.land",
@@ -0,0 +1,30 @@
1
+ import type { AiError } from "@effect/ai/AiError"
2
+ import type { AiLanguageModel } from "@effect/ai/AiLanguageModel"
3
+ import type { AiModel } from "@effect/ai/AiModel"
4
+ import * as Effect from "effect/Effect"
5
+ import { assistant } from "../assistant.ts"
6
+ import type { Strand } from "../Strand.ts"
7
+ import { user } from "../user.ts"
8
+
9
+ export const coalesceModels: <E, R, M extends Array<AiModel<any, any>>>(
10
+ effect: Effect.Effect<any, E, R>,
11
+ models: M,
12
+ ) => Effect.Effect<
13
+ string,
14
+ AiError | E,
15
+ Strand | AiLanguageModel | ([M[number]] extends [AiModel<any, infer R>] ? R : never)
16
+ > = Effect.fn(
17
+ function*(effect, models) {
18
+ const all = yield* Effect.all(models.map((model) => effect.pipe(Effect.provide(model)))) as Effect.Effect<
19
+ Array<unknown>
20
+ >
21
+ yield* user`
22
+ Coalesce the following items into a single item:
23
+
24
+ ---
25
+
26
+ ${all.map((item) => JSON.stringify(item, null, 2)).join("\n\n---")}
27
+ `
28
+ return yield* assistant
29
+ },
30
+ )
@@ -1 +0,0 @@
1
- export * from "./matchGist.ts";
@@ -1,2 +0,0 @@
1
- export * from "./matchGist.js";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../patterns/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"matchGist.js","sourceRoot":"","sources":["../../patterns/matchGist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,MAAM,CAAC,MAAM,SAAS,GAIlB,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAC,MAAM;IACpC,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACxC,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,MAAM,CAC/B,IAAI,CAAA;;;UAGE,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;KAC9B,EACD,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,CAAC,CACjD,CAAA;IACD,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,WAAW,CAAE,CAAA;AACpC,CAAC,CAAC,CAAA"}
package/patterns/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./matchGist.ts"
File without changes