Giter VIP home page Giter VIP logo

agentllm's Introduction

AgentLLM

Demo Medium Badge Twitter Follow


AgentLLM is the first proof of concept to utilize an open-source large language model (LLM) to develop autonomous agents that operate solely on the browser. Its main goal is to demonstrate that embedded LLMs have the ability to handle the complex goal-oriented tasks of autonomous agents with acceptable performance. Learn more on Medium and feel free to check out the demo.

Β 

AgentLLM.mp4

Β 

The implementation of the embedded LLM builds on the fantastic research of WebLLM, which takes advantage of Chromium's bleeding edge introduction of WebGPU to run inference utilizing the GPU. It offers significant performance gains over the previously available CPU-based implementations.

To create a sanitary and accessible sandbox, I chose to modify the popular AgentGPT project by replacing ChatGPT with WizardLM and changing the prompt mechanism. At its core, AgentGPT allows deploying autonomous agents to perform any arbitrary goal (from basic tasks to complex problem solving) by running a loop of task generation and execution. It's a perfect match for our requirements as its agents do not use tools, eliminating the complexity and unpredictability of external factors (which is present in full-blown implementations of other popular frameworks), and its GUI is friendly and feature-rich. The sandbox enables quick prototyping of the models' ability to break down tasks and plan ahead (feel free to try it!).

Consider supporting AgentGPT (the template for this project) by clicking here.

πŸš€ Motivation

Recent advancements in large language models (LLMs) like OpenAI's ChatGPT and GPT-4 have led to the rise of autonomous agents that can act independently, without human intervention, to achieve specified goals. However, most notable LLMs require massive computational resources, restricting their operation to powerful remote servers. Their remote operation leads to a variety of issues concerning privacy, cost, and availability. Enter browser-native LLMs come in, changing the way we think about autonomous agents and their potential applications.


Disclaimer

This project is a proof-of-concept utilizing experimental technologies. It is by no means a production-ready implementation, and it should not be used for anything other than research. It's provided "as-is" without any warranty, expressed or implied. By using this software, you agree to assume all risks associated with its use, including but not limited to data loss, system failure, or any other issues that may arise.

➑️ Getting Started

πŸƒ Running the demo

  1. Install Chrome or Edge. Make sure you're up-to-date (at least M113 Chromium version).
  2. Launch the browser (preferably with --enable-dawn-features=disable_robustness for performance). For example, in MacOS with Chrome, run the following command in the terminal: /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-dawn-features=disable_robustness
  3. Navigate to AgentLLM

Since running the model locally is very taxing, lower-tier devices may not be able to run the demo. For the best experience, try AgentLLM on a powerful desktop device.

🐳 Docker Setup

The easiest way to run AgentLLM locally is by using docker. A convenient setup script is provided to help you get started.

./setup.sh --docker

Docker-compose

Using docker-compose deploy

./setup.sh --docker-compose

πŸ‘· Local Development Setup

If you wish to develop AgentLLM locally, the easiest way is to use the provided setup script.

./setup.sh --local

πŸ› οΈ Manual Setup

🚧 You will need Nodejs +18 (LTS recommended) installed.

  1. Fork this project:
  1. Clone the repository:
git clone [email protected]:YOU_USER/AgentLLM.git
  1. Install dependencies:
cd AgentLLM
npm install
  1. Create a .env file with the following content:

🚧 The environment variables must match the following schema.

# Deployment Environment:
NODE_ENV=development

# Next Auth config:
# Generate a secret with `openssl rand -base64 32`
NEXTAUTH_SECRET=changeme
NEXTAUTH_URL=http://localhost:3000
DATABASE_URL=file:./db.sqlite

# Your open api key
OPENAI_API_KEY=changeme
  1. Modify prisma schema to use sqlite:
./prisma/useSqlite.sh

Note: This only needs to be done if you wish to use sqlite.

  1. Ready πŸ₯³, now run:
# Create database migrations
npx prisma db push
npm run dev

πŸš€ GitHub Codespaces

Set up AgentLLM in the cloud immediately by using GitHub Codespaces.

  1. From the GitHub repo, click the green "Code" button and select "Codespaces".
  2. Create a new Codespace or select a previous one you've already created.
  3. Codespaces opens in a separate tab in your browser.
  4. In terminal, run bash ./setup.sh --local
  5. When prompted in terminal, add your OpenAI API key.
  6. Click "Open in browser" when the build process completes.
  • To shut AgentLLM down, enter Ctrl+C in Terminal.
  • To restart AgentLLM, run npm run dev in Terminal.

Run the project πŸ₯³

npm run dev

agentllm's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

agentllm's Issues

GPU adapter cannot be found

What is the browser requirement and hardware/driver requirement to run agent LLM?
I found this error when running the latest commit, the sandbox you hosted also spit out the same error, I guess probably my mistake somewhere.

❌ Error retrieving initial tasks array. Refresh and retry, clarify your goal, or revise your goal such that it is allowed by our model's policies. Error message: Cannot find adapter that matches the request
If you are facing any issues, please check out the Help page or Github

Ubuntu 22.04
Edge Dev version 115.0.1843.0 dev (64 bit)
Edge://GPU WebGPU: Hardware accelerated
GPI 3090 driver 530

Offline use not possible - request to huggingface...ndarray-cache.json

I installed fork to Win environment, and there were no erors, and the Process starts ok - althoug having also error [(https://github.com//issues/7)]
When I try to use the agent offline, there is error, since program tries to connect to hugginface:
Entering new llm_chain chain...
console.js:13 Starting (...) with name webLlm with prompts: You have the following objective: plan a trip to Havaji. Create a list of zero to three tasks to be completed by you such that your goal is more closely reached or completely reached. The response list MUST be a SINGLE ARRAY OF STRINGS where each string is a TASK NAME wrapped in quotes (EXAMPLE OF RESPONSE FORMAT: "["task name", "task name"]"). You MUST be able to parse the list with Javascript’s JSON.parse() function. You must respond with the array WITHOUT ANY OTHER TEXT.

tvmjs_runtime.wasi.js:2660 GET https://huggingface.co/mlc-ai/web-lm/resolve/main/vicuna-7b-v1/ndarray-cache.json net::ERR_INTERNET_DISCONNECTED

The json can be fetced easily if the connection is open. Does the json need to be fetced, could it be local? Or is my setup just broken?

Wizard 7B does not follow prompt correctly

Prompt:

export const analyzeTaskPrompt = new PromptTemplate({
  template: `You have the following higher level objective "{goal}". You currently are focusing on the following task: "{task}". Based on this information, evaluate what the best action to take is strictly from the list of actions: {actions}. You should use 'search' for searching the web about current events where "arg" is a simple clear search query based on the task only. Use "reason" for all other actions. Return the response as an object of the form {{ "action": "string", "arg": "string" }} that can be used in JSON.parse() and NOTHING ELSE.`,
  inputVariables: ["goal", "actions", "task"],
});

Actual Response:

'Understood. Based on the current task, the best action to take is to search the web about current events related to "Alexander Graham Bell". Therefore, the action to take is "search" and the argument is "arg". The response will be of the form { "action": "search", "arg": "arg" }.'

Expected response

'{ "action": "search", "arg": "Alexander Graham Bell" }'

It seems Wizard LM 7B is not able to follow the exact prompted instructions. Is anyone else have the same issue?

Running alternative models?

Inspired by an earlier issue, the pace of development in this space is overwhelming, and I'm sure this project will gain traction. It wouldn't be feasible for you to manually add support for everything users are requesting then.

Hence, would it be possible to support users choosing their own models, probably locally downloaded as GGML or GPTQ as is popular with Ooga Booga? This would also allow users flexibilty (i.e. scaling down to 1.3B models or up to 30+B models) according to their devices.

For less capable setups, process timeouts?

First of all, thanks for exellent update!
In previous version, and also after updating to commit 927c4ae, execution for me always ended with these errors (see pic). I couldn't figure the reason, but then, after increasing the AutonomousAgent.ts timeout values substantially:
const TIMEOUT_LONG = 100000;
const TIMOUT_SHORT = 80000;
I was able to get a succesful shutdown after all tasks completed.

My setup is not optimal for this kind of things:
arch: AMD64
cpu: Intel64 Family 6 Model 158 Stepping 9,
GPU device: Quadro P4000 (1) (compute_37) (6, 1)
cuda: 11.3
cudnn: 8302

So, maybe having a option to set the timeout in settings for non-coding users might be nice feature, or just have this thing mentioned in faq might be useful for others.
I'll run some more test, and if problem still persiss, I'll let you know.

Screenshot 2023-05-04 142454

AgentLLM stuck after adding tasks and now showing error on retry

Hi there,

I'm new to AgentLLM and I'm having some trouble getting it to work. I followed the instructions and ran the agent for the first time. It downloaded everything it needed and initialized correctly. The agent also added two tasks, but then it got stuck and didn't do anything else.

I tried canceling the agent and running it again, but now I'm constantly seeing the error message in the attached screenshot. I'm not sure what's causing this error or how to fix it.

image

request to huggingface...ndarray-cache.json returning a 401 message

A bug report (I think something has changed on Hugging Face):

Running from https://gentllm.vercel.app

Any attempt at running creating a new goal results in the message:

Error retrieving initial tasks array. Refresh and retry, clarify your goal, or revise your goal such that it is allowed by our model's policies. > Error message: Failed to execute 'add' on 'Cache': Request failed
If you are facing any issues, please check out the Help page or Github

In the Network tools, you can see the error is being cause by https://huggingface.co/spaces/idosal/web-llm/resolve/main/wizardlm-7b/ndarray-cache.json returning a 401 "Unauthorized" status code. If you go directly to that URL in your browser, body of the page is just: "Invalid username or password.".

Models - WizardLM-7b

In my testing, WizardLM-7b model is superior to vicuna-7b in terms of following complex instructions, especially langchain style prompting. Would it be possible to add a feature where one could select the model to be loaded?

Error retrieving initial tasks array.

After initialization 100%, I see the GPU loaded with 5-6Gb, working some seconds and always receive the error:

❌ Error retrieving initial tasks array. Refresh and retry, clarify your goal, or revise your goal such that it is allowed by our model's policies. Error message: The operation failed for an operation-specific reason
If you are facing any issues, please check out the Help page or Github

With previous commit (tested yesterday) from time to time I received the task list, and later same error, but with today commit always error at first.

I receive the error with local docker and with online https://agentllm.vercel.app/

Console log/info/warn/error disabled?

I am not why, while running AgentLLM, all console logs that I inserted are not shown in the terminal? I can hardly debug this project where the web search is never used (I have put env serp api key)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.