@statelyai/agent 2.0.0-next.1 → 2.0.0-next.3
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/.changeset/grumpy-dolphins-think.md +17 -0
- package/.changeset/old-teachers-tap.md +5 -0
- package/.changeset/pink-eagles-deliver.md +13 -0
- package/.changeset/pre.json +9 -1
- package/.changeset/quiet-turtles-do.md +7 -0
- package/.changeset/smart-yaks-pull.md +23 -0
- package/.changeset/sweet-clouds-mix.md +16 -0
- package/.changeset/swift-mangos-rush.md +5 -0
- package/.changeset/tough-ways-rhyme.md +5 -0
- package/CHANGELOG.md +79 -0
- package/dist/index.d.mts +116 -100
- package/dist/index.d.ts +116 -100
- package/dist/index.js +102 -72
- package/dist/index.mjs +105 -75
- package/examples/chatbot.ts +2 -2
- package/examples/cot.ts +21 -73
- package/examples/customer-service-sim.ts +3 -3
- package/examples/email.ts +3 -5
- package/examples/example.ts +2 -2
- package/examples/goal.ts +2 -2
- package/examples/joke.ts +12 -12
- package/examples/jugs.ts +4 -7
- package/examples/learn-from-feedback.ts +123 -0
- package/examples/number.ts +2 -2
- package/examples/raffle.ts +2 -2
- package/examples/river-crossing.ts +4 -7
- package/examples/simple.ts +13 -10
- package/examples/summary.ts +2 -5
- package/examples/support.ts +38 -38
- package/examples/ticTacToe.ts +46 -4
- package/examples/todo.ts +3 -3
- package/examples/tutor.ts +2 -2
- package/examples/verify.ts +2 -2
- package/examples/weather-agent.ts +139 -0
- package/examples/weather.ts +26 -23
- package/examples/word.ts +8 -6
- package/package.json +2 -1
- package/src/agent.test.ts +37 -52
- package/src/agent.ts +93 -60
- package/src/decide.test.ts +56 -8
- package/src/decide.ts +42 -32
- package/src/strategies/chainOfThought.ts +50 -0
- package/src/{planners → strategies}/shortestPath.test.ts +4 -7
- package/src/strategies/shortestPath.ts +178 -0
- package/src/{planners → strategies}/simple.ts +25 -26
- package/src/templates/defaultText.ts +3 -0
- package/src/text.ts +13 -13
- package/src/types.ts +124 -83
- package/src/utils.ts +13 -1
- package/src/planners/shortestPath.ts +0 -177
- package/src/strategies/chain-of-note.ts +0 -106
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
'@statelyai/agent': minor
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
planner -> strategy
|
|
6
|
+
agent.addPlan -> agent.addDecision
|
|
7
|
+
agent.getPlans -> agent.getDecisions
|
|
8
|
+
|
|
9
|
+
The word "strategy" is now used instead of "planner" to make it more clear what the agent is doing: it uses a strategy to make decisions. The method `agent.addPlan(…)` has been renamed to `agent.addDecision(…)` and `agent.getPlans(…)` has been renamed to `agent.getDecisions(…)` to reflect this change. Additionally, you specify the `strategy` instead of the `planner` when creating an agent:
|
|
10
|
+
|
|
11
|
+
```diff
|
|
12
|
+
const agent = createAgent({
|
|
13
|
+
- planner: createSimplePlanner(),
|
|
14
|
+
+ strategy: createSimpleStrategy(),
|
|
15
|
+
...
|
|
16
|
+
});
|
|
17
|
+
```
|
package/.changeset/pre.json
CHANGED
|
@@ -7,7 +7,15 @@
|
|
|
7
7
|
"changesets": [
|
|
8
8
|
"cyan-carpets-perform",
|
|
9
9
|
"fast-donkeys-argue",
|
|
10
|
+
"grumpy-dolphins-think",
|
|
10
11
|
"light-hats-drive",
|
|
11
|
-
"old-jobs-check"
|
|
12
|
+
"old-jobs-check",
|
|
13
|
+
"old-teachers-tap",
|
|
14
|
+
"pink-eagles-deliver",
|
|
15
|
+
"quiet-turtles-do",
|
|
16
|
+
"smart-yaks-pull",
|
|
17
|
+
"sweet-clouds-mix",
|
|
18
|
+
"swift-mangos-rush",
|
|
19
|
+
"tough-ways-rhyme"
|
|
12
20
|
]
|
|
13
21
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
'@statelyai/agent': major
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The `state` can no longer be specified in `agent.interact(...)`, since the actual state value is already observed and passed to the `strategy` function.
|
|
6
|
+
|
|
7
|
+
The `context` provided to agent decision functions, like `agent.decide({ context })` and in `agent.interact(...)`, is now used solely to override the `state.context` provided to the prompt template.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
'@statelyai/agent': minor
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
You can specify `allowedEvents` in `agent.decide(...)` to allow from a list of specific events to be sent to the agent. This is useful when using `agent.decide(...)` without a state machine.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
const agent = createAgent({
|
|
9
|
+
// ...
|
|
10
|
+
events: {
|
|
11
|
+
PLAY: z.object({}).describe('Play a move'),
|
|
12
|
+
SKIP: z.object({}).describe('Skip a move'),
|
|
13
|
+
FORFEIT: z.object({}).describe('Forfeit the game'),
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// ...
|
|
18
|
+
const decision = await agent.decide({
|
|
19
|
+
// Don't allow the agent to send `FORFEIT` or other events
|
|
20
|
+
allowedEvents: ['PLAY', 'SKIP'],
|
|
21
|
+
// ...
|
|
22
|
+
});
|
|
23
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
'@statelyai/agent': patch
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The entire observed `state` must be provided, instead of only `context`, for any agent decision making functions:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
agent.interact(actor, (obs) => {
|
|
9
|
+
// ...
|
|
10
|
+
return {
|
|
11
|
+
goal: 'Some goal',
|
|
12
|
+
// instead of context
|
|
13
|
+
state: obs.state,
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
```
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,84 @@
|
|
|
1
1
|
# @statelyai/agent
|
|
2
2
|
|
|
3
|
+
## 2.0.0-next.3
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`bf6b468`](https://github.com/statelyai/agent/commit/bf6b468d66d58bf53629d70d1b2a273948c9ba1e) Thanks [@davidkpiano](https://github.com/davidkpiano)! - The `state` can no longer be specified in `agent.interact(...)`, since the actual state value is already observed and passed to the `strategy` function.
|
|
8
|
+
|
|
9
|
+
The `context` provided to agent decision functions, like `agent.decide({ context })` and in `agent.interact(...)`, is now used solely to override the `state.context` provided to the prompt template.
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`1287a6d`](https://github.com/statelyai/agent/commit/1287a6d405ed3bd6be37a61aaa9d54d963b5b1cd) Thanks [@davidkpiano](https://github.com/davidkpiano)! - Add `score` and `comment` fields for feedback
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`5b5a8e7`](https://github.com/statelyai/agent/commit/5b5a8e7012d550f5b05d0fefc9eade7731202577) Thanks [@davidkpiano](https://github.com/davidkpiano)! - The `score` is now required for feedback:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
agent.addFeedback({
|
|
21
|
+
score: 0.5,
|
|
22
|
+
goal: "Win the game",
|
|
23
|
+
observationId: "...",
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- [`5b5a8e7`](https://github.com/statelyai/agent/commit/5b5a8e7012d550f5b05d0fefc9eade7731202577) Thanks [@davidkpiano](https://github.com/davidkpiano)! - The entire observed `state` must be provided, instead of only `context`, for any agent decision making functions:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
agent.interact(actor, (obs) => {
|
|
31
|
+
// ...
|
|
32
|
+
return {
|
|
33
|
+
goal: "Some goal",
|
|
34
|
+
// instead of context
|
|
35
|
+
state: obs.state,
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- [`9d65d71`](https://github.com/statelyai/agent/commit/9d65d71e41f9f0f84f637ea7e0a0e22ccf67f264) Thanks [@davidkpiano](https://github.com/davidkpiano)! - Remove `goal` from feedback input
|
|
41
|
+
|
|
42
|
+
## 2.0.0-next.2
|
|
43
|
+
|
|
44
|
+
### Minor Changes
|
|
45
|
+
|
|
46
|
+
- [`4d870fe`](https://github.com/statelyai/agent/commit/4d870fe38ad0c906bafb2e0f6b2dabb745900ad3) Thanks [@davidkpiano](https://github.com/davidkpiano)! - planner -> strategy
|
|
47
|
+
agent.addPlan -> agent.addDecision
|
|
48
|
+
agent.getPlans -> agent.getDecisions
|
|
49
|
+
|
|
50
|
+
The word "strategy" is now used instead of "planner" to make it more clear what the agent is doing: it uses a strategy to make decisions. The method `agent.addPlan(…)` has been renamed to `agent.addDecision(…)` and `agent.getPlans(…)` has been renamed to `agent.getDecisions(…)` to reflect this change. Additionally, you specify the `strategy` instead of the `planner` when creating an agent:
|
|
51
|
+
|
|
52
|
+
```diff
|
|
53
|
+
const agent = createAgent({
|
|
54
|
+
- planner: createSimplePlanner(),
|
|
55
|
+
+ strategy: createSimpleStrategy(),
|
|
56
|
+
...
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- [`f1189cb`](https://github.com/statelyai/agent/commit/f1189cb980e52fa909888d27d3300dcd913ea47f) Thanks [@davidkpiano](https://github.com/davidkpiano)! - For feedback, the `goal`, `observationId`, and `attributes` are now required, and `feedback` and `reward` are removed since they are redundant.
|
|
61
|
+
|
|
62
|
+
- [`7b16326`](https://github.com/statelyai/agent/commit/7b163266c61bfc8125ed4d00924680d932001e27) Thanks [@davidkpiano](https://github.com/davidkpiano)! - You can specify `allowedEvents` in `agent.decide(...)` to allow from a list of specific events to be sent to the agent. This is useful when using `agent.decide(...)` without a state machine.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
const agent = createAgent({
|
|
66
|
+
// ...
|
|
67
|
+
events: {
|
|
68
|
+
PLAY: z.object({}).describe("Play a move"),
|
|
69
|
+
SKIP: z.object({}).describe("Skip a move"),
|
|
70
|
+
FORFEIT: z.object({}).describe("Forfeit the game"),
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// ...
|
|
75
|
+
const decision = await agent.decide({
|
|
76
|
+
// Don't allow the agent to send `FORFEIT` or other events
|
|
77
|
+
allowedEvents: ["PLAY", "SKIP"],
|
|
78
|
+
// ...
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
3
82
|
## 2.0.0-next.1
|
|
4
83
|
|
|
5
84
|
### Minor Changes
|