liminal 0.12.2 → 0.14.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/CHANGELOG.md +12 -0
- package/L.ts +1 -1
- package/Strand.ts +1 -1
- package/assistant.ts +5 -1
- package/assistantSchema.ts +60 -0
- package/disable.ts +5 -1
- package/dist/L.d.ts +1 -1
- package/dist/L.js +1 -1
- package/dist/Strand.d.ts +1 -1
- package/dist/assistant.js +5 -1
- package/dist/assistant.js.map +1 -1
- package/dist/{assistantStruct.d.ts → assistantSchema.d.ts} +3 -2
- package/dist/assistantSchema.js +44 -0
- package/dist/assistantSchema.js.map +1 -0
- package/dist/disable.d.ts +2 -1
- package/dist/disable.js +4 -0
- package/dist/disable.js.map +1 -1
- package/dist/enable.d.ts +2 -2
- package/dist/enable.js +4 -0
- package/dist/enable.js.map +1 -1
- package/dist/handle.d.ts +1 -1
- package/dist/handle.js +1 -1
- package/dist/patterns/index.d.ts +1 -0
- package/dist/patterns/index.js +2 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/patterns/matchGist.d.ts +3 -0
- package/dist/patterns/matchGist.js +16 -0
- package/dist/patterns/matchGist.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/userJson.js +4 -1
- package/dist/userJson.js.map +1 -1
- package/dist/util/JsonValue.d.ts +2 -1
- package/dist/util/JsonValue.js +73 -46
- package/dist/util/JsonValue.js.map +1 -1
- package/dist/util/Sequence.d.ts +2 -2
- package/dist/util/Taggable.d.ts +3 -3
- package/dist/util/Taggable.js +13 -16
- package/dist/util/Taggable.js.map +1 -1
- package/dist/util/fixRaw.d.ts +4 -0
- package/dist/util/fixRaw.js +75 -0
- package/dist/util/fixRaw.js.map +1 -0
- package/enable.ts +6 -3
- package/handle.ts +1 -1
- package/package.json +18 -17
- package/patterns/index.ts +1 -0
- package/patterns/matchGist.ts +23 -0
- package/userJson.ts +4 -2
- package/util/JsonValue.ts +101 -54
- package/util/Sequence.ts +8 -6
- package/util/Taggable.ts +21 -28
- package/util/fixRaw.ts +93 -0
- package/assistantStruct.ts +0 -34
- package/dist/assistantStruct.js +0 -22
- package/dist/assistantStruct.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# liminal
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e7006b7: Implement tool enablement and disablement.
|
|
8
|
+
|
|
9
|
+
## 0.13.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 0e4954e: Rename `L.assistantStruct` to `L.assistantSchema`, is it now supports all schemas, not just struct schemas. Template tag calls are properly dedented and normalized. Additionally, `L.userJson` now uses the optional schema to JSONC-encode with description annotations as comments on corresponding fields.
|
|
14
|
+
|
|
3
15
|
## 0.12.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/L.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./append.ts"
|
|
2
2
|
export * from "./assistant.ts"
|
|
3
|
+
export * from "./assistantSchema.ts"
|
|
3
4
|
export * from "./assistantStream.ts"
|
|
4
|
-
export * from "./assistantStruct.ts"
|
|
5
5
|
export * from "./branch.ts"
|
|
6
6
|
export * from "./clear.ts"
|
|
7
7
|
export * from "./enable.ts"
|
package/Strand.ts
CHANGED
|
@@ -27,7 +27,7 @@ export class Strand extends Context.Tag("liminal/Strand")<Strand, Strand.Service
|
|
|
27
27
|
static layer: (init?: {
|
|
28
28
|
system?: string | undefined
|
|
29
29
|
messages?: Array<Message> | undefined
|
|
30
|
-
tools?: Set<AiToolkit.Any>
|
|
30
|
+
tools?: Set<AiToolkit.Any> | undefined
|
|
31
31
|
}) => Layer.Layer<Strand> = ({ system, messages, tools } = {}) =>
|
|
32
32
|
Layer.effect(
|
|
33
33
|
Strand,
|
package/assistant.ts
CHANGED
|
@@ -11,11 +11,15 @@ import { Strand } from "./Strand.ts"
|
|
|
11
11
|
export const assistant: Effect.Effect<string, AiError, AiLanguageModel | Strand> = Effect.gen(function*() {
|
|
12
12
|
const model = yield* AiLanguageModel
|
|
13
13
|
const { system, messages, tools } = yield* Strand
|
|
14
|
-
|
|
14
|
+
let { text, results } = yield* model.generateText({
|
|
15
15
|
system: Option.getOrUndefined(system),
|
|
16
16
|
prompt: messages,
|
|
17
17
|
toolkit: AiToolkit.merge(...tools) as never,
|
|
18
18
|
})
|
|
19
|
+
// TODO: this shouldn't be necessary. Bug in Effect AI?
|
|
20
|
+
if (!text.trim()) {
|
|
21
|
+
text = results.values().next().value?.result as never as string
|
|
22
|
+
}
|
|
19
23
|
yield* append(
|
|
20
24
|
new AssistantMessage({
|
|
21
25
|
parts: [new TextPart({ text })],
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { AiError } from "@effect/ai/AiError"
|
|
2
|
+
import { AssistantMessage, TextPart } from "@effect/ai/AiInput"
|
|
3
|
+
import { AiLanguageModel } from "@effect/ai/AiLanguageModel"
|
|
4
|
+
import * as Effect from "effect/Effect"
|
|
5
|
+
import * as Option from "effect/Option"
|
|
6
|
+
import * as Schema from "effect/Schema"
|
|
7
|
+
import * as SchemaAST from "effect/SchemaAST"
|
|
8
|
+
import { append } from "./append.ts"
|
|
9
|
+
import { Strand } from "./Strand.ts"
|
|
10
|
+
import { encodeJsonc, type JsonValue } from "./util/JsonValue.ts"
|
|
11
|
+
|
|
12
|
+
/** Infer a structured assistant message and append its JSON representation to the conversation. */
|
|
13
|
+
export const assistantSchema: {
|
|
14
|
+
<F extends Record<string, Schema.Schema.AnyNoContext>>(
|
|
15
|
+
fields: F,
|
|
16
|
+
): Effect.Effect<{ [K in keyof F]: Schema.Schema.Type<F[K]> }, AiError, AiLanguageModel | Strand>
|
|
17
|
+
<O, I extends JsonValue>(
|
|
18
|
+
schema: Schema.Schema<O, I, never>,
|
|
19
|
+
): Effect.Effect<O, AiError, AiLanguageModel | Strand>
|
|
20
|
+
} = Effect.fnUntraced(function*(schema) {
|
|
21
|
+
const model = yield* AiLanguageModel
|
|
22
|
+
const { system, messages } = yield* Strand
|
|
23
|
+
|
|
24
|
+
const isSchema = Schema.isSchema(schema)
|
|
25
|
+
const schema_ = isSchema ? schema : Schema.Struct(schema) as Schema.Schema.AnyNoContext
|
|
26
|
+
const isObject = !isSchema || isObjectSchema(SchemaAST.encodedAST(schema.ast))
|
|
27
|
+
const wrapped = isObject ? schema_ : Schema.Struct({ inner: schema_ })
|
|
28
|
+
|
|
29
|
+
const value = yield* model.generateObject({
|
|
30
|
+
system: Option.getOrUndefined(system),
|
|
31
|
+
schema: wrapped,
|
|
32
|
+
prompt: messages,
|
|
33
|
+
}).pipe(
|
|
34
|
+
Effect.map(({ value }) => isObject ? value : value["inner"]),
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
yield* append(
|
|
38
|
+
new AssistantMessage({
|
|
39
|
+
parts: [
|
|
40
|
+
new TextPart({
|
|
41
|
+
text: yield* encodeJsonc(schema_)(value),
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
}),
|
|
45
|
+
)
|
|
46
|
+
return value
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const isObjectSchema = (ast: SchemaAST.AST): boolean => {
|
|
50
|
+
switch (ast._tag) {
|
|
51
|
+
case "TypeLiteral": {
|
|
52
|
+
return true
|
|
53
|
+
}
|
|
54
|
+
case "Refinement":
|
|
55
|
+
case "Transformation": {
|
|
56
|
+
return isObjectSchema(ast.from)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false
|
|
60
|
+
}
|
package/disable.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as AiTool from "@effect/ai/AiTool"
|
|
2
2
|
import type { AiToolkit } from "@effect/ai/AiToolkit"
|
|
3
3
|
import * as Effect from "effect/Effect"
|
|
4
|
+
import { Strand } from "./Strand"
|
|
4
5
|
|
|
5
|
-
export
|
|
6
|
+
export const disable: (toolkit: AiToolkit<AiTool.Any>) => Effect.Effect<void, never, Strand> = (toolkit) =>
|
|
7
|
+
Effect.map(Strand, ({ tools }) => {
|
|
8
|
+
tools.delete(toolkit)
|
|
9
|
+
})
|
package/dist/L.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./append.ts";
|
|
2
2
|
export * from "./assistant.ts";
|
|
3
|
+
export * from "./assistantSchema.ts";
|
|
3
4
|
export * from "./assistantStream.ts";
|
|
4
|
-
export * from "./assistantStruct.ts";
|
|
5
5
|
export * from "./branch.ts";
|
|
6
6
|
export * from "./clear.ts";
|
|
7
7
|
export * from "./enable.ts";
|
package/dist/L.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./append.js";
|
|
2
2
|
export * from "./assistant.js";
|
|
3
|
+
export * from "./assistantSchema.js";
|
|
3
4
|
export * from "./assistantStream.js";
|
|
4
|
-
export * from "./assistantStruct.js";
|
|
5
5
|
export * from "./branch.js";
|
|
6
6
|
export * from "./clear.js";
|
|
7
7
|
export * from "./enable.js";
|
package/dist/Strand.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare class Strand extends Strand_base {
|
|
|
25
25
|
static layer: (init?: {
|
|
26
26
|
system?: string | undefined;
|
|
27
27
|
messages?: Array<Message> | undefined;
|
|
28
|
-
tools?: Set<AiToolkit.Any
|
|
28
|
+
tools?: Set<AiToolkit.Any> | undefined;
|
|
29
29
|
}) => Layer.Layer<Strand>;
|
|
30
30
|
}
|
|
31
31
|
export {};
|
package/dist/assistant.js
CHANGED
|
@@ -9,11 +9,15 @@ import { Strand } from "./Strand.js";
|
|
|
9
9
|
export const assistant = Effect.gen(function* () {
|
|
10
10
|
const model = yield* AiLanguageModel;
|
|
11
11
|
const { system, messages, tools } = yield* Strand;
|
|
12
|
-
|
|
12
|
+
let { text, results } = yield* model.generateText({
|
|
13
13
|
system: Option.getOrUndefined(system),
|
|
14
14
|
prompt: messages,
|
|
15
15
|
toolkit: AiToolkit.merge(...tools),
|
|
16
16
|
});
|
|
17
|
+
// TODO: this shouldn't be necessary. Bug in Effect AI?
|
|
18
|
+
if (!text.trim()) {
|
|
19
|
+
text = results.values().next().value?.result;
|
|
20
|
+
}
|
|
17
21
|
yield* append(new AssistantMessage({
|
|
18
22
|
parts: [new TextPart({ text })],
|
|
19
23
|
}));
|
package/dist/assistant.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant.js","sourceRoot":"","sources":["../assistant.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,oEAAoE;AACpE,MAAM,CAAC,MAAM,SAAS,GAA6D,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACrG,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,eAAe,CAAA;IACpC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,MAAM,CAAA;IACjD,
|
|
1
|
+
{"version":3,"file":"assistant.js","sourceRoot":"","sources":["../assistant.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,oEAAoE;AACpE,MAAM,CAAC,MAAM,SAAS,GAA6D,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACrG,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,eAAe,CAAA;IACpC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,MAAM,CAAA;IACjD,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;QAChD,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC;QACrC,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,CAAU;KAC5C,CAAC,CAAA;IACF,uDAAuD;IACvD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QACjB,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAyB,CAAA;IACjE,CAAC;IACD,KAAK,CAAC,CAAC,MAAM,CACX,IAAI,gBAAgB,CAAC;QACnB,KAAK,EAAE,CAAC,IAAI,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;KAChC,CAAC,CACH,CAAA;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAC,CAAA"}
|
|
@@ -3,10 +3,11 @@ import { AiLanguageModel } from "@effect/ai/AiLanguageModel";
|
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
import { Strand } from "./Strand.ts";
|
|
6
|
+
import { type JsonValue } from "./util/JsonValue.ts";
|
|
6
7
|
/** Infer a structured assistant message and append its JSON representation to the conversation. */
|
|
7
|
-
export declare const
|
|
8
|
+
export declare const assistantSchema: {
|
|
8
9
|
<F extends Record<string, Schema.Schema.AnyNoContext>>(fields: F): Effect.Effect<{
|
|
9
10
|
[K in keyof F]: Schema.Schema.Type<F[K]>;
|
|
10
11
|
}, AiError, AiLanguageModel | Strand>;
|
|
11
|
-
<O, I extends
|
|
12
|
+
<O, I extends JsonValue>(schema: Schema.Schema<O, I, never>): Effect.Effect<O, AiError, AiLanguageModel | Strand>;
|
|
12
13
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AssistantMessage, TextPart } from "@effect/ai/AiInput";
|
|
2
|
+
import { AiLanguageModel } from "@effect/ai/AiLanguageModel";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
7
|
+
import { append } from "./append.js";
|
|
8
|
+
import { Strand } from "./Strand.js";
|
|
9
|
+
import { encodeJsonc } from "./util/JsonValue.js";
|
|
10
|
+
/** Infer a structured assistant message and append its JSON representation to the conversation. */
|
|
11
|
+
export const assistantSchema = Effect.fnUntraced(function* (schema) {
|
|
12
|
+
const model = yield* AiLanguageModel;
|
|
13
|
+
const { system, messages } = yield* Strand;
|
|
14
|
+
const isSchema = Schema.isSchema(schema);
|
|
15
|
+
const schema_ = isSchema ? schema : Schema.Struct(schema);
|
|
16
|
+
const isObject = !isSchema || isObjectSchema(SchemaAST.encodedAST(schema.ast));
|
|
17
|
+
const wrapped = isObject ? schema_ : Schema.Struct({ inner: schema_ });
|
|
18
|
+
const value = yield* model.generateObject({
|
|
19
|
+
system: Option.getOrUndefined(system),
|
|
20
|
+
schema: wrapped,
|
|
21
|
+
prompt: messages,
|
|
22
|
+
}).pipe(Effect.map(({ value }) => isObject ? value : value["inner"]));
|
|
23
|
+
yield* append(new AssistantMessage({
|
|
24
|
+
parts: [
|
|
25
|
+
new TextPart({
|
|
26
|
+
text: yield* encodeJsonc(schema_)(value),
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
}));
|
|
30
|
+
return value;
|
|
31
|
+
});
|
|
32
|
+
const isObjectSchema = (ast) => {
|
|
33
|
+
switch (ast._tag) {
|
|
34
|
+
case "TypeLiteral": {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
case "Refinement":
|
|
38
|
+
case "Transformation": {
|
|
39
|
+
return isObjectSchema(ast.from);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=assistantSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistantSchema.js","sourceRoot":"","sources":["../assistantSchema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,WAAW,EAAkB,MAAM,qBAAqB,CAAA;AAEjE,mGAAmG;AACnG,MAAM,CAAC,MAAM,eAAe,GAOxB,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAC,MAAM;IACpC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,eAAe,CAAA;IACpC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC,MAAM,CAAA;IAE1C,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAA+B,CAAA;IACvF,MAAM,QAAQ,GAAG,CAAC,QAAQ,IAAI,cAAc,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IAC9E,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;IAEtE,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC;QACxC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC;QACrC,MAAM,EAAE,OAAO;QACf,MAAM,EAAE,QAAQ;KACjB,CAAC,CAAC,IAAI,CACL,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAC7D,CAAA;IAED,KAAK,CAAC,CAAC,MAAM,CACX,IAAI,gBAAgB,CAAC;QACnB,KAAK,EAAE;YACL,IAAI,QAAQ,CAAC;gBACX,IAAI,EAAE,KAAK,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;aACzC,CAAC;SACH;KACF,CAAC,CACH,CAAA;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAC,CAAA;AAEF,MAAM,cAAc,GAAG,CAAC,GAAkB,EAAW,EAAE;IACrD,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,KAAK,YAAY,CAAC;QAClB,KAAK,gBAAgB,CAAC,CAAC,CAAC;YACtB,OAAO,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACjC,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
|
package/dist/disable.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as AiTool from "@effect/ai/AiTool";
|
|
2
2
|
import type { AiToolkit } from "@effect/ai/AiToolkit";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
|
-
|
|
4
|
+
import { Strand } from "./Strand";
|
|
5
|
+
export declare const disable: (toolkit: AiToolkit<AiTool.Any>) => Effect.Effect<void, never, Strand>;
|
package/dist/disable.js
CHANGED
package/dist/disable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disable.js","sourceRoot":"","sources":["../disable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAE3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"disable.js","sourceRoot":"","sources":["../disable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAE3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,MAAM,CAAC,MAAM,OAAO,GAA2E,CAAC,OAAO,EAAE,EAAE,CACzG,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC/B,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;AACvB,CAAC,CAAC,CAAA"}
|
package/dist/enable.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as AiTool from "@effect/ai/AiTool";
|
|
2
2
|
import type { AiToolkit } from "@effect/ai/AiToolkit";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
|
-
import
|
|
5
|
-
export declare const enable: <Tools extends AiTool.Any>(toolkit: AiToolkit<Tools>) => Effect.Effect<
|
|
4
|
+
import { Strand } from "./Strand.ts";
|
|
5
|
+
export declare const enable: <Tools extends AiTool.Any>(toolkit: AiToolkit<Tools>) => Effect.Effect<void, never, AiTool.Handler<Tools["name"]> | Strand>;
|
package/dist/enable.js
CHANGED
package/dist/enable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enable.js","sourceRoot":"","sources":["../enable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAE3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"enable.js","sourceRoot":"","sources":["../enable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAE3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,MAAM,CAAC,MAAM,MAAM,GAEuD,CAAC,OAAO,EAAE,EAAE,CACpF,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC/B,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;AACpB,CAAC,CAAC,CAAA"}
|
package/dist/handle.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ import * as Scope from "effect/Scope";
|
|
|
4
4
|
import type { LEvent } from "./LEvent.ts";
|
|
5
5
|
import { Strand } from "./Strand.ts";
|
|
6
6
|
/** Attach an event handler to process the events of the current strand. */
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const listen: <A, E, R>(f: (event: LEvent) => Effect.Effect<A, E, R>) => Effect.Effect<RuntimeFiber<void, E>, never, Strand | R | Scope.Scope>;
|
package/dist/handle.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as Scope from "effect/Scope";
|
|
|
3
3
|
import * as Stream from "effect/Stream";
|
|
4
4
|
import { Strand } from "./Strand.js";
|
|
5
5
|
/** Attach an event handler to process the events of the current strand. */
|
|
6
|
-
export const
|
|
6
|
+
export const listen = Effect.fnUntraced(function* (f) {
|
|
7
7
|
const latch = yield* Effect.makeLatch(false);
|
|
8
8
|
const { events } = yield* Strand;
|
|
9
9
|
const dequeue = yield* events.subscribe;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./matchGist.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../patterns/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { Strand } from "../Strand.ts";
|
|
3
|
+
export declare const matchGist: <R extends Record<string, Effect.All.EffectAny>>(routes: R) => Effect.Effect<Effect.Effect.Success<R[keyof R]>, ([R[keyof R]] extends [never] ? never : Effect.Effect.Error<R[keyof R]>), ([R[keyof R]] extends [never] ? never : Effect.Effect.Context<R[keyof R]>) | Strand>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import { assistantSchema } from "../assistantSchema.js";
|
|
4
|
+
import { branch } from "../branch.js";
|
|
5
|
+
import { Strand } from "../Strand.js";
|
|
6
|
+
import { user } from "../user.js";
|
|
7
|
+
export const matchGist = Effect.fnUntraced(function* (routes) {
|
|
8
|
+
const descriptions = Object.keys(routes);
|
|
9
|
+
const description = yield* branch(user `
|
|
10
|
+
Which of the following descriptions best matches the current conversation?
|
|
11
|
+
|
|
12
|
+
- ${descriptions.join("\n -")}
|
|
13
|
+
`, assistantSchema(Schema.Literal(...descriptions)));
|
|
14
|
+
return yield* routes[description];
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=matchGist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|