Skip to content

statelyai/agent

Repository files navigation

Stately Agent (alpha)

Installation

Install openai, and @statelyai/agent:

pnpm install openai @statelyai/agent

Usage

Read the documentation

  • Joke generator
    • Demonstrates agent.fromChatCompletion(...) to generate a joke and provide a joke rating
    • Demonstrates agent.fromEvent(...) to choose whether to keep generating jokes or stop
  • Tic-tac-toe
    • Demonstrates agent.fromEvent(...) to have an agent play itself in a game of tic-tac-toe with precise events
    • Demonstrates agent.fromChatCompletionStream(...) to produce a game report at the end of the game
  • Weather
    • Demonstrates using Tavily as an external API
    • Demonstrates agent.fromEvent(...) to only use Tavily to get the weather if the user provides a valid location

Examples

First, clone this repo locally. To run the examples in this repo, create a .env file at the root of the repo with the following contents:

OPENAI_API_KEY="your-openai-api-key"

Then, install the dependencies (npm install) and run the examples:

pnpm run example joke
# or:
# pnpm run example ticTacToe