react-agent-ts
v0.0.6
Published
A TypeScript implementation of the ReAct agent logic from the paper ๐ [ReAct: Synergizing Reasoning and Acting in Language Models](https://arxiv.org/abs/2210.03629).
Downloads
3
Readme
๐ 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:
๐ฎ 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!
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.
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 ๐!
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!
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.
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.
The World Is Our Playground ๐: Envision and identify new platforms (mobile, web apps, browser plugins, etc.) to bring our creation to more users.
Docs & Tutorials: Knowledge Unleashed ๐: Develop comprehensive documentation and tutorials to guide users and developers on their path to AI mastery.
Building Together: The Dev Community ๐๏ธ: Establish a thriving developer communityโhost events, workshops, contests and collaborate on open-source projects.
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.
Next Level Automations: Rise of the Machines ๐ค: Continuously innovate to unveil sophisticated features and automations, turning our AI assistant into a personal powerhouse.
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.
Zoom, Zoom: SuperchargeAI ๐๏ธ: Regularly optimize our AI system's performance to keep it running smoothly and efficiently.
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:
git clone https://github.com/Intuitive-Systems/react-agent-ts.git
cd react-agent-ts
- 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.
- 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.