Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: statelyai/agent
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.7
Choose a base ref
...
head repository: statelyai/agent
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: next
Choose a head ref

Commits on Mar 15, 2024

  1. Copy the full SHA
    fd4214d View commit details
  2. Use only events

    davidkpiano committed Mar 15, 2024
    Copy the full SHA
    867c270 View commit details

Commits on Mar 16, 2024

  1. Use Zod

    davidkpiano committed Mar 16, 2024
    Copy the full SHA
    483fc46 View commit details
  2. Rename

    davidkpiano committed Mar 16, 2024
    Copy the full SHA
    044bfbc View commit details
  3. types makes more sense

    davidkpiano committed Mar 16, 2024
    Copy the full SHA
    dedadf1 View commit details
  4. Update examples

    davidkpiano committed Mar 16, 2024
    Copy the full SHA
    72e8cc6 View commit details
  5. Add changeset

    davidkpiano committed Mar 16, 2024
    Copy the full SHA
    8a2c34b View commit details
  6. Copy the full SHA
    1424f03 View commit details
  7. Version Packages

    github-actions[bot] committed Mar 16, 2024
    Copy the full SHA
    cf8a1b4 View commit details
  8. Merge pull request #23 from statelyai/changeset-release/main

    Version Packages
    davidkpiano authored Mar 16, 2024
    Copy the full SHA
    d851ad5 View commit details

Commits on Mar 18, 2024

  1. Add article example

    davidkpiano committed Mar 18, 2024
    Copy the full SHA
    7ef1941 View commit details
  2. Rename

    davidkpiano committed Mar 18, 2024
    Copy the full SHA
    d3e513b View commit details
  3. Add attribution

    davidkpiano committed Mar 18, 2024
    Copy the full SHA
    7c0f4f3 View commit details

Commits on Mar 19, 2024

  1. Merge pull request #25 from statelyai/davidkpiano/newspaper

    Add newspaper example
    davidkpiano authored Mar 19, 2024
    Copy the full SHA
    683952d View commit details

Commits on Mar 27, 2024

  1. WIP

    davidkpiano committed Mar 27, 2024
    Copy the full SHA
    2d5047a View commit details

Commits on Apr 2, 2024

  1. Agent architecture WIP

    davidkpiano committed Apr 2, 2024
    Copy the full SHA
    0b4cc06 View commit details
  2. Switch args

    davidkpiano committed Apr 2, 2024
    Copy the full SHA
    5133f85 View commit details

Commits on Apr 12, 2024

  1. WIP

    davidkpiano committed Apr 12, 2024
    Copy the full SHA
    958cb25 View commit details
  2. Update dependencies

    davidkpiano committed Apr 12, 2024
    Copy the full SHA
    8f3194e View commit details

Commits on Apr 13, 2024

  1. Update readme

    davidkpiano committed Apr 13, 2024
    Copy the full SHA
    c7135ed View commit details
  2. Copy the full SHA
    8622402 View commit details

Commits on Apr 15, 2024

  1. Improvements

    davidkpiano committed Apr 15, 2024
    Copy the full SHA
    21edb92 View commit details

Commits on Apr 23, 2024

  1. Remove unused imports

    davidkpiano committed Apr 23, 2024
    Copy the full SHA
    cf8f962 View commit details

Commits on Apr 24, 2024

  1. WIP: improved agent

    davidkpiano committed Apr 24, 2024
    Copy the full SHA
    1336f5a View commit details
  2. Add verify example

    davidkpiano committed Apr 24, 2024
    Copy the full SHA
    34e5c39 View commit details

Commits on Apr 25, 2024

  1. Update examples

    davidkpiano committed Apr 25, 2024
    Copy the full SHA
    ef5c9f2 View commit details

Commits on Apr 28, 2024

  1. Update examples

    davidkpiano committed Apr 28, 2024
    Copy the full SHA
    5da9fc1 View commit details

Commits on May 2, 2024

  1. Update examples

    davidkpiano committed May 2, 2024
    Copy the full SHA
    c4e5188 View commit details
  2. Remove defineEvents

    davidkpiano committed May 2, 2024
    Copy the full SHA
    3f00f5e View commit details
  3. createAgent changeset

    davidkpiano committed May 2, 2024
    Copy the full SHA
    2d63f30 View commit details
  4. Update

    davidkpiano committed May 2, 2024
    Copy the full SHA
    b229cb3 View commit details
  5. Merge pull request #26 from statelyai/davidkpiano/rl

    RL framework experimentation
    davidkpiano authored May 2, 2024
    Copy the full SHA
    3d99514 View commit details

Commits on May 3, 2024

  1. Add ai and openai sdk

    davidkpiano committed May 3, 2024
    Copy the full SHA
    d691670 View commit details

Commits on May 4, 2024

  1. Cleanup

    davidkpiano committed May 4, 2024
    Copy the full SHA
    00e8bff View commit details
  2. Copy the full SHA
    d2444a9 View commit details
  3. Comment cleanup

    davidkpiano committed May 4, 2024
    Copy the full SHA
    7ea2667 View commit details
  4. Add support example

    davidkpiano committed May 4, 2024
    Copy the full SHA
    7d9563a View commit details

Commits on May 6, 2024

  1. Add example

    davidkpiano committed May 6, 2024
    Copy the full SHA
    e85800f View commit details
  2. Update goal example

    davidkpiano committed May 6, 2024
    Copy the full SHA
    762ea9b View commit details

Commits on May 7, 2024

  1. Add fromText

    davidkpiano committed May 7, 2024
    Copy the full SHA
    4101cb9 View commit details
  2. Changeset

    davidkpiano committed May 7, 2024
    Copy the full SHA
    dbdea98 View commit details
  3. Copy the full SHA
    40a7c10 View commit details

Commits on May 8, 2024

  1. History idea

    davidkpiano committed May 8, 2024
    Copy the full SHA
    cb0c483 View commit details

Commits on May 11, 2024

  1. Copy the full SHA
    39da7d5 View commit details
  2. Add decide function

    davidkpiano committed May 11, 2024
    Copy the full SHA
    6b0a0c4 View commit details

Commits on May 13, 2024

  1. Copy the full SHA
    e9f3ef9 View commit details
  2. Cleanup

    davidkpiano committed May 13, 2024
    Copy the full SHA
    8f0a25b View commit details
  3. Add simple template

    davidkpiano committed May 13, 2024
    Copy the full SHA
    5ce654f View commit details
  4. Chain of note

    davidkpiano committed May 13, 2024
    Copy the full SHA
    14ba32e View commit details
  5. Cleanup

    davidkpiano committed May 13, 2024
    Copy the full SHA
    ce99e2e View commit details
Showing with 9,828 additions and 3,189 deletions.
  1. +5 −0 .changeset/calm-beans-talk.md
  2. +5 −0 .changeset/cyan-carpets-perform.md
  3. +5 −0 .changeset/fast-donkeys-argue.md
  4. +17 −0 .changeset/grumpy-dolphins-think.md
  5. +9 −0 .changeset/light-hats-drive.md
  6. +10 −0 .changeset/nice-pants-rule.md
  7. +5 −0 .changeset/odd-kiwis-compare.md
  8. +5 −0 .changeset/old-jobs-check.md
  9. +5 −0 .changeset/old-teachers-tap.md
  10. +13 −0 .changeset/pink-eagles-deliver.md
  11. +22 −0 .changeset/pre.json
  12. +7 −0 .changeset/quiet-turtles-do.md
  13. +23 −0 .changeset/smart-yaks-pull.md
  14. +16 −0 .changeset/sweet-clouds-mix.md
  15. +5 −0 .changeset/swift-mangos-rush.md
  16. +5 −0 .changeset/tough-ways-rhyme.md
  17. +0 −3 .env.template
  18. +11 −11 .github/actions/ci-setup/action.yml
  19. +17 −6 .github/workflows/release.yml
  20. +1 −1 .gitignore
  21. +18 −1 .vscode/launch.json
  22. +269 −0 CHANGELOG.md
  23. +797 −0 architecture.tldr
  24. +57 −0 examples/chatbot-alt.ts
  25. +66 −0 examples/chatbot.ts
  26. +38 −0 examples/cot.ts
  27. +107 −0 examples/customer-service-sim.ts
  28. +112 −0 examples/email.ts
  29. +81 −0 examples/example.ts
  30. +66 −0 examples/executor.ts
  31. +94 −0 examples/goal.ts
  32. +26 −14 examples/helpers/helpers.ts
  33. +136 −128 examples/joke.ts
  34. +122 −0 examples/jugs.ts
  35. +123 −0 examples/learn-from-feedback.ts
  36. +103 −0 examples/multi.ts
  37. 0 examples/multiAgentCollaboration.ts
  38. +318 −0 examples/newspaper.ts
  39. +103 −0 examples/number.ts
  40. +0 −128 examples/numberGuesser.ts
  41. +104 −0 examples/raffle.ts
  42. +62 −0 examples/rewoo.ts
  43. +137 −0 examples/river-crossing.ts
  44. +28 −0 examples/sandbox.ts
  45. +71 −0 examples/serverless.ts
  46. +44 −0 examples/simple.ts
  47. +118 −0 examples/summary.ts
  48. +147 −0 examples/support.ts
  49. +179 −131 examples/ticTacToe.ts
  50. +137 −0 examples/todo.ts
  51. +100 −0 examples/tutor.ts
  52. +120 −0 examples/verify.ts
  53. +139 −0 examples/weather-agent.ts
  54. +73 −55 examples/weather.ts
  55. +49 −0 examples/wiki.ts
  56. +178 −0 examples/word.ts
  57. +0 −156 examples/wordGuesser.ts
  58. +38 −16 package.json
  59. +1,878 −1,852 pnpm-lock.yaml
  60. +55 −30 readme.md
  61. +0 −217 src/adapter.test.ts
  62. +0 −298 src/adapters/openai.ts
  63. +877 −0 src/agent.test.ts
  64. +635 −6 src/agent.ts
  65. +346 −0 src/decide.test.ts
  66. +129 −0 src/decide.ts
  67. +4 −2 src/index.ts
  68. +91 −0 src/middleware.ts
  69. +47 −0 src/mockModel.ts
  70. +48 −0 src/policies/chainOfThoughtPolicy.ts
  71. +3 −0 src/policies/index.ts
  72. +91 −0 src/policies/shortestPathPolicy.test.ts
  73. +178 −0 src/policies/shortestPathPolicy.ts
  74. +105 −0 src/policies/toolPolicy.ts
  75. +10 −39 src/schemas.ts
  76. +21 −0 src/templates/defaultText.ts
  77. +143 −0 src/text.ts
  78. +496 −45 src/types.ts
  79. +115 −46 src/utils.ts
  80. +1 −1 tsconfig.json
  81. +9 −3 vitest.config.ts
5 changes: 5 additions & 0 deletions .changeset/calm-beans-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@statelyai/agent': major
---

"Strategy" has been renamed to "policy", and "score" has been renamed to "reward".
5 changes: 5 additions & 0 deletions .changeset/cyan-carpets-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@statelyai/agent': patch
---

The `name` field in `createAgent({ name: '...' })` has been renamed to `id`.
5 changes: 5 additions & 0 deletions .changeset/fast-donkeys-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@statelyai/agent": patch
---

The `description` field in `createAgent({ description: '...' })` is now used for the `system` prompt in agent decision making when a `system` prompt is not provided.
17 changes: 17 additions & 0 deletions .changeset/grumpy-dolphins-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@statelyai/agent': minor
---

planner -> strategy
agent.addPlan -> agent.addDecision
agent.getPlans -> agent.getDecisions

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:

```diff
const agent = createAgent({
- planner: createSimplePlanner(),
+ strategy: createSimpleStrategy(),
...
});
```
9 changes: 9 additions & 0 deletions .changeset/light-hats-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@statelyai/agent': major
---

- `agent.generateText(…)` is removed in favor of using the AI SDK's `generateText(…)` function with a wrapped model.
- `agent.streamText(…)` is removed in favor of using the AI SDK's `streamText(…)` function with a wrapped model.
- Custom adapters are removed for now, but may be re-added in future releases. Using the AI SDK is recommended for now.
- Correlation IDs are removed in favor of using [OpenTelemetry with the AI SDK](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry#telemetry).
- The `createAgentMiddleware(…)` function was introduced to facilitate agent message history. You can also use `agent.wrap(model)` to wrap a model with Stately Agent middleware.
10 changes: 10 additions & 0 deletions .changeset/nice-pants-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@statelyai/agent': major
---

- The `machine` and `machineHash` properties were removed from `AgentObservation` and `AgentObservationInput`
- The `defaultOptions` property was removed from `Agent`
- `AgentDecideOptions` was renamed to `AgentDecideInput`
- The `execute` property was removed from `AgentDecideInput`
- The `episodeId` optional property was added to `AgentDecideInput`, `AgentObservationInput`, and `AgentFeedbackInput`
- `decisionId` was added to `AgentObservationInput` and `AgentFeedbackInput`
5 changes: 5 additions & 0 deletions .changeset/odd-kiwis-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@statelyai/agent': minor
---

You can now add **insights** for observations made. Insights are additional context about the observations made, which can be useful for agent decision making.
5 changes: 5 additions & 0 deletions .changeset/old-jobs-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@statelyai/agent': minor
---

You can specify `maxAttempts` in `agent.decide({ maxAttempts: 5 })`. This will allow the agent to attempt to make a decision up to the specified number of `maxAttempts` before giving up. The default value is `2`.
5 changes: 5 additions & 0 deletions .changeset/old-teachers-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@statelyai/agent': minor
---

For feedback, the `goal`, `observationId`, and `attributes` are now required, and `feedback` and `reward` are removed since they are redundant.
13 changes: 13 additions & 0 deletions .changeset/pink-eagles-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@statelyai/agent': patch
---

The `score` is now required for feedback:

```ts
agent.addFeedback({
score: 0.5,
goal: 'Win the game',
observationId: '...',
});
```
22 changes: 22 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"mode": "pre",
"tag": "next",
"initialVersions": {
"@statelyai/agent": "1.1.6"
},
"changesets": [
"cyan-carpets-perform",
"fast-donkeys-argue",
"grumpy-dolphins-think",
"light-hats-drive",
"nice-pants-rule",
"old-jobs-check",
"old-teachers-tap",
"pink-eagles-deliver",
"quiet-turtles-do",
"smart-yaks-pull",
"sweet-clouds-mix",
"swift-mangos-rush",
"tough-ways-rhyme"
]
}
7 changes: 7 additions & 0 deletions .changeset/quiet-turtles-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@statelyai/agent': major
---

The `state` can no longer be specified in `agent.interact(...)`, since the actual state value is already observed and passed to the `strategy` function.

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.
23 changes: 23 additions & 0 deletions .changeset/smart-yaks-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@statelyai/agent': minor
---

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.

```ts
const agent = createAgent({
// ...
events: {
PLAY: z.object({}).describe('Play a move'),
SKIP: z.object({}).describe('Skip a move'),
FORFEIT: z.object({}).describe('Forfeit the game'),
},
});

// ...
const decision = await agent.decide({
// Don't allow the agent to send `FORFEIT` or other events
allowedEvents: ['PLAY', 'SKIP'],
// ...
});
```
16 changes: 16 additions & 0 deletions .changeset/sweet-clouds-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@statelyai/agent': patch
---

The entire observed `state` must be provided, instead of only `context`, for any agent decision making functions:

```ts
agent.interact(actor, (obs) => {
// ...
return {
goal: 'Some goal',
// instead of context
state: obs.state,
};
});
```
5 changes: 5 additions & 0 deletions .changeset/swift-mangos-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@statelyai/agent": patch
---

Remove `goal` from feedback input
5 changes: 5 additions & 0 deletions .changeset/tough-ways-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@statelyai/agent": minor
---

Add `score` and `comment` fields for feedback
3 changes: 0 additions & 3 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

# Get your OpenAI API key from: https://platform.openai.com/signup/
OPENAI_API_KEY="sk-..."

# Get your Tavily API key from: https://app.tavily.com/
TAVILY_API_KEY="tvly-..."
22 changes: 11 additions & 11 deletions .github/actions/ci-setup/action.yml
Original file line number Diff line number Diff line change
@@ -7,18 +7,18 @@ runs:
- uses: actions/setup-node@v4
with:
node-version: 20.x

- name: install pnpm
run: npm i pnpm@latest -g
shell: bash

- name: Get pnpm store directory
- name: Setup npmrc
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
shell: bash
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: setup pnpm config
run: pnpm config set store-dir $PNPM_CACHE_FOLDER
shell: bash

- run: pnpm install
shell: bash
23 changes: 17 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@ permissions: {}
jobs:
release:
permissions:
contents: write # to create release (changesets/action)
contents: write # to create release (changesets/action)
issues: write # to post issue comments (changesets/action)
pull-requests: write # to create pull request (changesets/action)
pull-requests: write # to create pull request (changesets/action)

if: github.repository == 'statelyai/agent'

@@ -22,10 +22,21 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/ci-setup

- name: Create Release Pull Request or Publish to npm
- name: checkout code repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: setup node.js
uses: actions/setup-node@v3
with:
node-version: 20
- name: install pnpm
run: npm i pnpm@latest -g
- name: setup pnpm config
run: pnpm config set store-dir $PNPM_CACHE_FOLDER
- name: install dependencies
run: pnpm install
- name: create and publish versions
uses: changesets/action@v1
with:
publish: pnpm run release
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ out

# Nuxt.js build / generate output
.nuxt
dist
dist/

# Gatsby files
.cache/
19 changes: 18 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -7,11 +7,28 @@
"request": "launch",
"name": "Debug Current Test File",
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"skipFiles": ["<node_internals>/**", "**/node_modules/**", "examples/**"],
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"args": ["run", "${relativeFile}"],
"smartStep": true,
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Debug Current File",
"program": "${file}",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ts-node",
"runtimeArgs": ["--transpile-only", "-r", "dotenv/config"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"sourceMaps": true,
"smartStep": true,
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"!**/node_modules/**"
],
"console": "integratedTerminal"
}
]
}
Loading