0.0.6 โ€ข Published 1 year ago

react-agent-ts v0.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

๐Ÿš€ Welcome to React-Agent-TS ๐Ÿค–

A TypeScript implementation of the ReAct agent logic from the paper ๐Ÿ“„ ReAct: Synergizing Reasoning and Acting in Language Models.

React-Agent-TS allows you to build a powerful ๐Ÿ’ช Chat Assistant that can interact with users, make use of handy tools ๐Ÿ› ๏ธ (e.g. search, memory retrieval), and have internal dialogues ๐Ÿง  to generate meaningful responses.

๐Ÿ—๏ธ Architecture

This amazing tool utilizes the Microsoft PromptEngine abstraction to model interactions. The Agent class models its thoughts as two parallel interactions: one with the user directly ๐Ÿ‘ฅ, and another internal monologue with itself for problem-solving ๐Ÿงฉ. This separation proves useful as it cuts down on complexity in the mental model when building higher-order systems.

Here's an example of the React Agent thought process:

Swimlanes Diagram

๐Ÿ”ฎ The Vision

The vision for this project is to produce a completely local agent architecture that utilizes the growing library of bot plugins ๐Ÿค– in the Wellknown.ai plugin repository. These agents, expert at a particular task, will be able to call into one another and perform complex behavior and automations ๐Ÿ”„ dynamically based on need.

Using the principles of factored cognition, we can realize a future where not only do you own your data, but your personal bot ๐Ÿค– safely and carefully takes care of the minutiae so you can do more ๐ŸŒŸ!

๐Ÿ›ฃ๏ธ The Roadmap

Here's a rough outline of the journey ahead. We'd love to hear your thoughts and ideas, and we invite you to contribute to the project in any way you're comfortable!

  1. API Wrapper Fiesta! ๐ŸŽ‰: We'll begin by developing our own API wrapper, which will serve as a bridge between GPT4ALL and chatbot UIs built for the OpenAI ChatCompletions API.

  2. The Local Chatbot Revolution ๐ŸŒ: Empower users to create local chatbots with little-to-no setup. Got ideas for simplifying the process? We're all ears ๐Ÿ‘‚!

  3. Have Plugin, Will Expand ๐Ÿ”Œ: Let's build a rich ecosystem of plugins to extend the functionality of the local chatbot. Got a great idea? Share it, build it, or join forces with like-minded developers to make it happen!

  4. UI: A Portal to the AI Realm ๐Ÿ–ฅ๏ธ: Together, we'll create or fork an elegant, user-friendly UI that can be customized and shipped with model binaries.

  5. Feedback: The Spice of AI Life ๐ŸŒถ๏ธ: Gather and use user feedback to continuously iterate on the UI and app features, turning our AI assistant into a masterpiece.

  6. The World Is Our Playground ๐ŸŒ: Envision and identify new platforms (mobile, web apps, browser plugins, etc.) to bring our creation to more users.

  7. Docs & Tutorials: Knowledge Unleashed ๐Ÿ“š: Develop comprehensive documentation and tutorials to guide users and developers on their path to AI mastery.

  8. Building Together: The Dev Community ๐Ÿ—๏ธ: Establish a thriving developer communityโ€”host events, workshops, contests and collaborate on open-source projects.

  9. Tap into the Matrix: Data & Services Integration ๐Ÿ”—: Let's help our AI interact with external data sources and services, enabling powerful automations and enhanced capabilities.

  10. Next Level Automations: Rise of the Machines ๐Ÿค–: Continuously innovate to unveil sophisticated features and automations, turning our AI assistant into a personal powerhouse.

  11. Fort Knox: Secure the AI Sanctuary ๐Ÿ”’: Create a robust security model to protect user data by adding end-to-end encryption and maintaining data sovereignty.

  12. Zoom, Zoom: SuperchargeAI ๐ŸŽ๏ธ: Regularly optimize our AI system's performance to keep it running smoothly and efficiently.

  13. Expand the Horizons: Sky's the Limit ๐ŸŒŒ: Continue building out new features and push the boundaries of our AI assistant, inching ever closer to our grand vision.

๐ŸŽ™๏ธ Speak Up, Join In!

Join us on the Github Discussions Board and let us know what you want to see!

๐Ÿ› ๏ธ Setup

Follow these steps to set up the project:

  1. Install Node.js and Yarn.

  2. Clone the project:

git clone https://github.com/Intuitive-Systems/react-agent-ts.git
cd react-agent-ts
  1. Set up .env files

The agent relies on .env.agent and the local retrieval plugin relies on .env.retrieval. Examples of each are in .env.agent.example and .env.retrieval.example respectively.

  1. Compile and run:
docker-compose up

๐Ÿ“š Usage

The agent is designed to be run as a service, via a graphql API.

Sending this query to localhost:3000:

query {
  reactMessage(userInput: "When was Michael Jackson born?")
}

Will result in an answer being returned:

{
  "data": {
    "addMessage": "The result of the expression 5/4^13+4(3-1) is approximately 8.000000074."
  }
}

๐Ÿ•ต๏ธโ€โ™‚๏ธ Tracing

React-Agent-TS library is instrumented with OpenTelemetry, allowing agents to be easily traced and debugged during development. With OpenTelemetry, you can observe and monitor the application's performance, identify and diagnose any issues, and gain valuable insights into the inner workings of the agent.

We have included a docker-compose setup that simplifies the process of launching and debugging the agent locally. This setup allows you to effortlessly collect, process, and export trace data to visualize and investigate the agent's behavior.

To get started, make sure you have Docker Compose installed, and then simply use the following command to spin up the entire stack:

docker-compose up

After running the stack, you can navigate to the OpenTelemetry UI at http://localhost:16686 to view the collected data, inspect the trace spans, and analyze the performance metrics.

By leveraging OpenTelemetry and our docker-compose setup, you can debug your ReAct agents both quickly and easily, ensuring a seamless development experience.

๐Ÿ“ TODOs

  • : flesh out the PluginTool such that it more dynamically deals with arbitrary plugins -- should probably be lifted into its own Engine / Agent abstraction (ex. PluginEnging or APIAgent)
  • : Build tracing tool which allows agent to introspect into traces and self-diagnose

About the Author ๐Ÿง‘โ€๐Ÿ’ป

react-agent-ts was created by Conner Swann, founder of Intuitive Systems. Conner is a passionate developer and advocate for democratizing AI models and frameworks, believing that access to powerful machine learning tookits should be available to everyone ๐ŸŒ. In the words of the modern sage, "When the AI tide rises, all boats should float" ๐Ÿšฃ.

You can find Conner on Twitter, sharing insights and occasional shenanigans ๐ŸŽญ at @YourBuddyConner. While he definitely enjoys being on the bandwagon for advancing AI ๐Ÿค–, he remains humbly committed to exploring and delivering state-of-the-art technology for everyone's benefit.