liminal 0.10.0 → 0.11.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 +6 -0
- package/L.ts +8 -2
- package/LEvent.ts +13 -7
- package/Sequence.ts +14 -0
- package/Strand.ts +18 -39
- package/assistant.ts +3 -4
- package/assistantStruct.ts +2 -1
- package/branch.ts +26 -0
- package/clear.ts +15 -0
- package/dist/L.d.ts +8 -2
- package/dist/L.js +8 -2
- package/dist/L.js.map +1 -1
- package/dist/LEvent.d.ts +12 -8
- package/dist/LEvent.js +8 -5
- package/dist/LEvent.js.map +1 -1
- package/dist/Sequence.d.ts +2 -0
- package/dist/Sequence.js +2 -0
- package/dist/Sequence.js.map +1 -0
- package/dist/Strand.d.ts +18 -13
- package/dist/Strand.js +2 -20
- package/dist/Strand.js.map +1 -1
- package/dist/assistant.js +3 -4
- package/dist/assistant.js.map +1 -1
- package/dist/assistantStruct.js +2 -1
- package/dist/assistantStruct.js.map +1 -1
- package/dist/branch.d.ts +4 -0
- package/dist/branch.js +18 -0
- package/dist/branch.js.map +1 -0
- package/dist/clear.d.ts +5 -0
- package/dist/clear.js +15 -0
- package/dist/clear.js.map +1 -0
- package/dist/events.d.ts +1 -1
- package/dist/events.js +1 -1
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/JsonValue.d.ts +5 -0
- package/dist/internal/JsonValue.js +2 -0
- package/dist/internal/JsonValue.js.map +1 -0
- package/dist/{Taggable.d.ts → internal/Taggable.d.ts} +1 -1
- package/dist/internal/Taggable.js.map +1 -0
- package/dist/messages.d.ts +5 -0
- package/dist/messages.js +5 -0
- package/dist/messages.js.map +1 -0
- package/dist/pretty.d.ts +2 -0
- package/dist/pretty.js +37 -0
- package/dist/pretty.js.map +1 -0
- package/dist/reduce.d.ts +2 -4
- package/dist/reduce.js +10 -29
- package/dist/reduce.js.map +1 -1
- package/dist/sequence_.d.ts +2 -0
- package/dist/sequence_.js +5 -0
- package/dist/sequence_.js.map +1 -0
- package/dist/strand_.d.ts +4 -0
- package/dist/strand_.js +18 -0
- package/dist/strand_.js.map +1 -0
- package/dist/system.d.ts +5 -0
- package/dist/system.js +11 -0
- package/dist/system.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/user.d.ts +1 -1
- package/dist/user.js +1 -1
- package/dist/user.js.map +1 -1
- package/dist/userJson.d.ts +6 -0
- package/dist/userJson.js +8 -0
- package/dist/userJson.js.map +1 -0
- package/events.ts +1 -1
- package/index.ts +1 -0
- package/internal/JsonValue.ts +5 -0
- package/{Taggable.ts → internal/Taggable.ts} +1 -1
- package/messages.ts +9 -0
- package/package.json +8 -6
- package/pretty.ts +41 -0
- package/reduce.ts +21 -45
- package/sequence_.ts +9 -0
- package/strand_.ts +25 -0
- package/system.ts +13 -0
- package/user.ts +1 -1
- package/userJson.ts +12 -0
- package/dist/Taggable.js.map +0 -1
- package/dist/turn.d.ts +0 -7
- package/dist/turn.js +0 -21
- package/dist/turn.js.map +0 -1
- package/dist/unsafeSet.d.ts +0 -5
- package/dist/unsafeSet.js +0 -13
- package/dist/unsafeSet.js.map +0 -1
- package/turn.ts +0 -25
- package/unsafeSet.ts +0 -15
- /package/dist/{Taggable.js → internal/Taggable.js} +0 -0
package/dist/user.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
|
+
import { type Taggable } from "./internal/Taggable.ts";
|
|
2
3
|
import * as Strand from "./Strand.ts";
|
|
3
|
-
import { type Taggable } from "./Taggable.ts";
|
|
4
4
|
/** Append a user message to the conversation. */
|
|
5
5
|
export declare const user: Taggable<Effect.Effect<void, never, Strand.Strand>>;
|
package/dist/user.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TextPart, UserMessage } from "@effect/ai/AiInput";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import { append } from "./append.js";
|
|
4
|
+
import { normalize } from "./internal/Taggable.js";
|
|
4
5
|
import * as Strand from "./Strand.js";
|
|
5
|
-
import { normalize } from "./Taggable.js";
|
|
6
6
|
/** Append a user message to the conversation. */
|
|
7
7
|
export const user = (a0, ...aRest) => append(UserMessage.make({
|
|
8
8
|
parts: [
|
package/dist/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,SAAS,EAAiB,MAAM,wBAAwB,CAAA;AACjE,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,iDAAiD;AACjD,MAAM,CAAC,MAAM,IAAI,GAAwD,CAAC,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,CACxF,MAAM,CACJ,WAAW,CAAC,IAAI,CAAC;IACf,KAAK,EAAE;QACL,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,CAAC;SAC3B,CAAC;KACH;CACF,CAAC,CACH,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import type { JsonValueObject } from "./internal/JsonValue.ts";
|
|
4
|
+
import * as Strand from "./Strand.ts";
|
|
5
|
+
/** Stringify and append some JSON as a user message to the conversation. */
|
|
6
|
+
export declare const userJson: <A, I extends JsonValueObject>(value: A, schema?: Schema.Schema<A, I, never>) => Effect.Effect<void, never, Strand.Strand>;
|
package/dist/userJson.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as Strand from "./Strand.js";
|
|
4
|
+
import { user } from "./user.js";
|
|
5
|
+
// TODO: serialize with comments from schema
|
|
6
|
+
/** Stringify and append some JSON as a user message to the conversation. */
|
|
7
|
+
export const userJson = (value) => user `\`\`\`jsonc\n${JSON.stringify(value, null, 2)}\n\`\`\``;
|
|
8
|
+
//# sourceMappingURL=userJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userJson.js","sourceRoot":"","sources":["../userJson.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,4CAA4C;AAC5C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,QAAQ,GAG4B,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAA,gBAAgB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,UAAU,CAAA"}
|
package/events.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as Stream from "effect/Stream"
|
|
|
3
3
|
import type { LEvent } from "./LEvent"
|
|
4
4
|
import { Strand } from "./Strand.ts"
|
|
5
5
|
|
|
6
|
-
/**
|
|
6
|
+
/** Get a new event stream of the events of the current strand. */
|
|
7
7
|
export const events: Stream.Stream<LEvent, never, Strand> = Stream.unwrap(
|
|
8
8
|
Effect.map(Strand, ({ events }) => Stream.fromPubSub(events)),
|
|
9
9
|
)
|
package/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type Taggable<T> = {
|
|
|
4
4
|
(template: string | TemplateStringsArray, ...substitutions: Array<unknown>): T
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export type
|
|
7
|
+
export type TaggableNullable<T> = {
|
|
8
8
|
(value?: string | undefined): T
|
|
9
9
|
(template: TemplateStringsArray, ...substitutions: Array<unknown>): T
|
|
10
10
|
(template?: string | TemplateStringsArray | undefined, ...substitutions: Array<unknown>): T
|
package/messages.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Message } from "@effect/ai/AiInput"
|
|
2
|
+
import * as Effect from "effect/Effect"
|
|
3
|
+
import { Strand } from "./Strand.ts"
|
|
4
|
+
|
|
5
|
+
/** Get a copy of the current list of messages. */
|
|
6
|
+
export const messages: Effect.Effect<Array<Message>, never, Strand> = Effect.map(
|
|
7
|
+
Strand,
|
|
8
|
+
({ messages: [...messages] }) => messages,
|
|
9
|
+
)
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "liminal",
|
|
3
3
|
"homepage": "https://liminal.land",
|
|
4
|
+
"llms": "https://liminal.land/llms.txt",
|
|
5
|
+
"llmsFull": "https://liminal.land/llmsFull.txt",
|
|
4
6
|
"publishConfig": {
|
|
5
|
-
"access": "public"
|
|
7
|
+
"access": "public",
|
|
8
|
+
"provenance": true
|
|
6
9
|
},
|
|
7
|
-
"version": "0.
|
|
10
|
+
"version": "0.11.0",
|
|
8
11
|
"license": "Apache-2.0",
|
|
9
12
|
"repository": {
|
|
10
13
|
"type": "git",
|
|
@@ -12,12 +15,11 @@
|
|
|
12
15
|
"directory": "liminal"
|
|
13
16
|
},
|
|
14
17
|
"type": "module",
|
|
18
|
+
"sideEffects": false,
|
|
15
19
|
"description": "Primitives for composing conversation trees with language models and TypeScript iterators.",
|
|
16
20
|
"exports": {
|
|
17
|
-
".":
|
|
18
|
-
|
|
19
|
-
"types": "./index.ts"
|
|
20
|
-
}
|
|
21
|
+
".": "./index.ts",
|
|
22
|
+
"./package.json": "./package.json"
|
|
21
23
|
},
|
|
22
24
|
"peerDependencies": {
|
|
23
25
|
"@effect/ai": "^0.18.16",
|
package/pretty.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Message } from "@effect/ai/AiInput"
|
|
2
|
+
import type { LEvent } from "./LEvent.ts"
|
|
3
|
+
|
|
4
|
+
const GRAY = "\x1b[90m"
|
|
5
|
+
const RESET = "\x1b[0m"
|
|
6
|
+
const BOLD = "\x1b[1m"
|
|
7
|
+
const GRAY_BG = "\x1b[47m"
|
|
8
|
+
|
|
9
|
+
export const pretty: (event: typeof LEvent["Type"]) => string = (event) => {
|
|
10
|
+
let text = `${GRAY}${event._tag}${RESET}`
|
|
11
|
+
switch (event._tag) {
|
|
12
|
+
case "MessagesAppended": {
|
|
13
|
+
text += event.messages.map(formatMessage).join("\n")
|
|
14
|
+
break
|
|
15
|
+
}
|
|
16
|
+
case "MessagesCleared": {
|
|
17
|
+
text += `\n${event.cleared.length} messages cleared.`
|
|
18
|
+
break
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return text
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const formatMessage = ({ _tag, parts }: Message): string => {
|
|
25
|
+
let value = ""
|
|
26
|
+
for (const part of parts) {
|
|
27
|
+
value += `\n${BOLD}${_tag}\n${GRAY_BG}`
|
|
28
|
+
switch (part._tag) {
|
|
29
|
+
case "TextPart": {
|
|
30
|
+
value += `${part.text}`
|
|
31
|
+
break
|
|
32
|
+
}
|
|
33
|
+
default: {
|
|
34
|
+
value += `${JSON.stringify(part, null, 2)}`
|
|
35
|
+
break
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
value += RESET
|
|
39
|
+
}
|
|
40
|
+
return value
|
|
41
|
+
}
|
package/reduce.ts
CHANGED
|
@@ -1,56 +1,32 @@
|
|
|
1
|
-
import { Message } from "@effect/ai/AiInput"
|
|
2
1
|
import * as Effect from "effect/Effect"
|
|
3
|
-
import * as Option from "effect/Option"
|
|
4
|
-
import * as PubSub from "effect/PubSub"
|
|
5
|
-
import type { YieldWrap } from "effect/Utils"
|
|
6
2
|
import { append } from "./append.ts"
|
|
7
|
-
import {
|
|
3
|
+
import { clear } from "./clear.ts"
|
|
8
4
|
import { Strand } from "./Strand.ts"
|
|
9
|
-
import {
|
|
5
|
+
import { strand } from "./strand_.ts"
|
|
10
6
|
|
|
11
|
-
/**
|
|
12
|
-
export const reduce: <
|
|
13
|
-
reducer:
|
|
7
|
+
/** Sequentially reduce the current strand's messages in chronological order. */
|
|
8
|
+
export const reduce: <E, R, E1, R1>(
|
|
9
|
+
reducer: Effect.Effect<Effect.Effect<void, E1, R1>, E, R>,
|
|
14
10
|
) => Effect.Effect<
|
|
15
11
|
void,
|
|
16
|
-
|
|
17
|
-
| Strand
|
|
18
|
-
| ([Y] extends [never] ? never : [Y] extends [YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never)
|
|
19
|
-
| R
|
|
12
|
+
E | E1,
|
|
13
|
+
R | R1 | Strand
|
|
20
14
|
> = Effect.fnUntraced(function*(reducer) {
|
|
21
|
-
const
|
|
22
|
-
if (!
|
|
23
|
-
const [m0, m1, ...mRest] =
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})
|
|
29
|
-
.pipe(
|
|
30
|
-
Effect.provide(Strand.new()),
|
|
31
|
-
)
|
|
15
|
+
const parent = yield* Strand
|
|
16
|
+
if (!parent.messages.length || parent.messages.length === 1) return
|
|
17
|
+
const [m0, m1, ...mRest] = parent.messages
|
|
18
|
+
let acc = yield* strand(
|
|
19
|
+
append(m0!, m1!),
|
|
20
|
+
reducer,
|
|
21
|
+
)
|
|
32
22
|
while (mRest.length) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
})
|
|
39
|
-
.pipe(
|
|
40
|
-
Effect.provide(Strand.new()),
|
|
41
|
-
)
|
|
23
|
+
acc = yield* strand(
|
|
24
|
+
acc,
|
|
25
|
+
append(mRest.pop()!),
|
|
26
|
+
reducer,
|
|
27
|
+
)
|
|
42
28
|
}
|
|
43
|
-
|
|
44
|
-
yield*
|
|
45
|
-
Strand,
|
|
46
|
-
Strand.of({
|
|
47
|
-
messages,
|
|
48
|
-
events: yield* PubSub.unbounded<LEvent>(),
|
|
49
|
-
}),
|
|
50
|
-
))
|
|
51
|
-
const previous = yield* unsafeSet(messages)
|
|
52
|
-
yield* strand.events.publish(
|
|
53
|
-
MessagesReduced.make({ previous, messages }),
|
|
54
|
-
)
|
|
29
|
+
yield* clear
|
|
30
|
+
yield* acc
|
|
55
31
|
return
|
|
56
32
|
})
|
package/sequence_.ts
ADDED
package/strand_.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect"
|
|
2
|
+
import { flow } from "effect/Function"
|
|
3
|
+
import * as Option from "effect/Option"
|
|
4
|
+
import * as PubSub from "effect/PubSub"
|
|
5
|
+
import type { LEvent } from "./LEvent.ts"
|
|
6
|
+
import { type Sequence } from "./Sequence.ts"
|
|
7
|
+
import { sequence } from "./sequence_.ts"
|
|
8
|
+
import { Strand } from "./Strand.ts"
|
|
9
|
+
|
|
10
|
+
/** Isolate the effect with a new strand in context. */
|
|
11
|
+
export const strand: Sequence<Strand> = flow(
|
|
12
|
+
sequence,
|
|
13
|
+
Effect.provideServiceEffect(
|
|
14
|
+
Strand,
|
|
15
|
+
Effect.gen(function*() {
|
|
16
|
+
return Strand.of({
|
|
17
|
+
parent: yield* Effect.serviceOption(Strand),
|
|
18
|
+
events: yield* PubSub.unbounded<LEvent>(),
|
|
19
|
+
system: Option.none(),
|
|
20
|
+
messages: [],
|
|
21
|
+
tools: [],
|
|
22
|
+
})
|
|
23
|
+
}),
|
|
24
|
+
),
|
|
25
|
+
)
|
package/system.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect"
|
|
2
|
+
import * as Option from "effect/Option"
|
|
3
|
+
import { normalize, type TaggableNullable } from "./internal/Taggable.ts"
|
|
4
|
+
import { Strand } from "./Strand.ts"
|
|
5
|
+
|
|
6
|
+
export const system: TaggableNullable<Effect.Effect<Option.Option<string>, never, Strand>> = Effect.fnUntraced(
|
|
7
|
+
function*(a0, ...aRest) {
|
|
8
|
+
const conversation = yield* Strand
|
|
9
|
+
const { system } = conversation
|
|
10
|
+
conversation.system = a0 ? Option.some(normalize(a0, aRest)) : Option.none()
|
|
11
|
+
return system
|
|
12
|
+
},
|
|
13
|
+
)
|
package/user.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TextPart, UserMessage } from "@effect/ai/AiInput"
|
|
2
2
|
import * as Effect from "effect/Effect"
|
|
3
3
|
import { append } from "./append.ts"
|
|
4
|
+
import { normalize, type Taggable } from "./internal/Taggable.ts"
|
|
4
5
|
import * as Strand from "./Strand.ts"
|
|
5
|
-
import { normalize, type Taggable } from "./Taggable.ts"
|
|
6
6
|
|
|
7
7
|
/** Append a user message to the conversation. */
|
|
8
8
|
export const user: Taggable<Effect.Effect<void, never, Strand.Strand>> = (a0, ...aRest) =>
|
package/userJson.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect"
|
|
2
|
+
import * as Schema from "effect/Schema"
|
|
3
|
+
import type { JsonValueObject } from "./internal/JsonValue.ts"
|
|
4
|
+
import * as Strand from "./Strand.ts"
|
|
5
|
+
import { user } from "./user.ts"
|
|
6
|
+
|
|
7
|
+
// TODO: serialize with comments from schema
|
|
8
|
+
/** Stringify and append some JSON as a user message to the conversation. */
|
|
9
|
+
export const userJson: <A, I extends JsonValueObject>(
|
|
10
|
+
value: A,
|
|
11
|
+
schema?: Schema.Schema<A, I, never>,
|
|
12
|
+
) => Effect.Effect<void, never, Strand.Strand> = (value) => user`\`\`\`jsonc\n${JSON.stringify(value, null, 2)}\n\`\`\``
|
package/dist/Taggable.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Taggable.js","sourceRoot":"","sources":["../Taggable.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,EAAM,EACN,QAAwB,EAAE,EAC2B,EAAE,CACvD,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,SAAkB,CAAA"}
|
package/dist/turn.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AiError } from "@effect/ai/AiError";
|
|
2
|
-
import { AiLanguageModel } from "@effect/ai/AiLanguageModel";
|
|
3
|
-
import * as Effect from "effect/Effect";
|
|
4
|
-
import { Strand } from "./Strand.ts";
|
|
5
|
-
import { type Taggable } from "./Taggable.ts";
|
|
6
|
-
/** Append a user message to the conversation, then infer and append an assistant message to the conversation. */
|
|
7
|
-
export declare const turn: Taggable<Effect.Effect<string, AiError, Strand | AiLanguageModel>>;
|
package/dist/turn.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { AiError } from "@effect/ai/AiError";
|
|
2
|
-
import { TextPart, UserMessage } from "@effect/ai/AiInput";
|
|
3
|
-
import { AiLanguageModel } from "@effect/ai/AiLanguageModel";
|
|
4
|
-
import * as Effect from "effect/Effect";
|
|
5
|
-
import { append } from "./append.js";
|
|
6
|
-
import { assistant } from "./assistant.js";
|
|
7
|
-
import { Strand } from "./Strand.js";
|
|
8
|
-
import { normalize } from "./Taggable.js";
|
|
9
|
-
/** Append a user message to the conversation, then infer and append an assistant message to the conversation. */
|
|
10
|
-
export const turn = Effect
|
|
11
|
-
.fnUntraced(function* (a0, ...aRest) {
|
|
12
|
-
yield* append(UserMessage.make({
|
|
13
|
-
parts: [
|
|
14
|
-
TextPart.make({
|
|
15
|
-
text: normalize(a0, aRest),
|
|
16
|
-
}),
|
|
17
|
-
],
|
|
18
|
-
}));
|
|
19
|
-
return yield* assistant;
|
|
20
|
-
});
|
|
21
|
-
//# sourceMappingURL=turn.js.map
|
package/dist/turn.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"turn.js","sourceRoot":"","sources":["../turn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,SAAS,EAAiB,MAAM,eAAe,CAAA;AAExD,iHAAiH;AACjH,MAAM,CAAC,MAAM,IAAI,GAAuE,MAAM;KAC3F,UAAU,CACT,QAAQ,CAAC,EAAC,EAAE,EAAE,GAAG,KAAK;IACpB,KAAK,CAAC,CAAC,MAAM,CACX,WAAW,CAAC,IAAI,CAAC;QACf,KAAK,EAAE;YACL,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,CAAC;aAC3B,CAAC;SACH;KACF,CAAC,CACH,CAAA;IACD,OAAO,KAAK,CAAC,CAAC,SAAS,CAAA;AACzB,CAAC,CACF,CAAA"}
|
package/dist/unsafeSet.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Message } from "@effect/ai/AiInput";
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import { Strand } from "./Strand.ts";
|
|
4
|
-
/** Set the list of messages. */
|
|
5
|
-
export declare const unsafeSet: (messages: Iterable<Message>) => Effect.Effect<Array<Message>, never, Strand>;
|
package/dist/unsafeSet.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Message } from "@effect/ai/AiInput";
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import { Strand } from "./Strand.js";
|
|
4
|
-
/** Set the list of messages. */
|
|
5
|
-
export const unsafeSet = Effect.fnUntraced(function* (messages) {
|
|
6
|
-
const strand = yield* Strand;
|
|
7
|
-
const previous = strand.messages;
|
|
8
|
-
Object.assign(strand, {
|
|
9
|
-
messages: [...messages],
|
|
10
|
-
});
|
|
11
|
-
return previous;
|
|
12
|
-
});
|
|
13
|
-
//# sourceMappingURL=unsafeSet.js.map
|
package/dist/unsafeSet.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unsafeSet.js","sourceRoot":"","sources":["../unsafeSet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,gCAAgC;AAChC,MAAM,CAAC,MAAM,SAAS,GAE8B,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAC,QAAQ;IACtF,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,CAAA;IAC5B,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAA;IAChC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QACpB,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC;KACxB,CAAC,CAAA;IACF,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/turn.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { AiError } from "@effect/ai/AiError"
|
|
2
|
-
import { TextPart, UserMessage } from "@effect/ai/AiInput"
|
|
3
|
-
import { AiLanguageModel } from "@effect/ai/AiLanguageModel"
|
|
4
|
-
import * as Effect from "effect/Effect"
|
|
5
|
-
import { append } from "./append.ts"
|
|
6
|
-
import { assistant } from "./assistant.ts"
|
|
7
|
-
import { Strand } from "./Strand.ts"
|
|
8
|
-
import { normalize, type Taggable } from "./Taggable.ts"
|
|
9
|
-
|
|
10
|
-
/** Append a user message to the conversation, then infer and append an assistant message to the conversation. */
|
|
11
|
-
export const turn: Taggable<Effect.Effect<string, AiError, Strand | AiLanguageModel>> = Effect
|
|
12
|
-
.fnUntraced(
|
|
13
|
-
function*(a0, ...aRest) {
|
|
14
|
-
yield* append(
|
|
15
|
-
UserMessage.make({
|
|
16
|
-
parts: [
|
|
17
|
-
TextPart.make({
|
|
18
|
-
text: normalize(a0, aRest),
|
|
19
|
-
}),
|
|
20
|
-
],
|
|
21
|
-
}),
|
|
22
|
-
)
|
|
23
|
-
return yield* assistant
|
|
24
|
-
},
|
|
25
|
-
)
|
package/unsafeSet.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Message } from "@effect/ai/AiInput"
|
|
2
|
-
import * as Effect from "effect/Effect"
|
|
3
|
-
import { Strand } from "./Strand.ts"
|
|
4
|
-
|
|
5
|
-
/** Set the list of messages. */
|
|
6
|
-
export const unsafeSet: (
|
|
7
|
-
messages: Iterable<Message>,
|
|
8
|
-
) => Effect.Effect<Array<Message>, never, Strand> = Effect.fnUntraced(function*(messages) {
|
|
9
|
-
const strand = yield* Strand
|
|
10
|
-
const previous = strand.messages
|
|
11
|
-
Object.assign(strand, {
|
|
12
|
-
messages: [...messages],
|
|
13
|
-
})
|
|
14
|
-
return previous
|
|
15
|
-
})
|
|
File without changes
|