Giter VIP home page Giter VIP logo

smartgpt's Introduction

SmartGPT


SmartGPT is an experimental program meant to provide LLMs (particularly GPT-3.5 and GPT-4) with the ability to complete complex tasks without user input by breaking them down into smaller problems, and collecting information using the internet and other external sources.

If you're interested in keeping up with the progress of SmartGPT, want to contribute to development, or have issues to discuss, join the SmartGPT Discord.

SmartGPT.Demonstration.with.Rust.Essay.mp4

Why?

There are many existing solutions to allowing LLMs to perform more complex tasks, such as Auto-GPT and BabyAGI. So, why SmartGPT?

  • Modularity: With first class plugin support and the ability to compose Autos for whatever your project requires, SmartGPT is incredibly modular.

  • Flexibility: SmartGPT has one config.yml file that is automatically generated where you can configure everything and anything.

  • Consistency: SmartGPT has a smart system of dynamically executing actions and static tool-chaining to provide incredible consistent results.

There are two main shortcomings, however.

  • Ecosystem: Due to its popularity, AutoGPT is a very polished and refined tool. It has many more tools and integrations with memory systems. To go with this, the codebase has been through large scrutiny, so it is generally less buggy and more tested than SmartGPT.

  • Memory Management: Due to the extreme youth of this project, there is only one simple but limited memory system. However, this will change with time.

Supporting Development

Currently, testing with SmartGPT is primarily being done with GPT3.5, and occasionally with GPT4, due to the costs of more-expensive models. As this project matures, we're aiming to experiment both with multiple agents at once and using GPT4 much more to unleash maximum capabilities out of LLMs. This is expensive though, and as the core maintainer of SmartGPT, I'm still a high school student, and funding a project like this is difficult for me. If you're interest in helping push the boundaries of LLMs, consider joining our Patreon.

Disclaimer

SmartGPT is an incredibly experimental application. The goal is to unlock maximum potential out of LLMs, and stability is sacrificed for this. Backwards compatibility is a fever dream here. However, SmartGPT is also housing some of the most innovative ideas and experiments in the AutoGPT space right now, and although most are unsuccessful, a few hit the dart-board and stick.

Quickstart

  1. Install cargo, preferably the latest stable version.

  2. Clone the repository with git clone https://github.com/Cormanz/smartgpt.git && cd smartgpt.

  3. Run it in release mode with cargo run --release. This will create a config.yml for you.

  4. Adjust the config to your liking, and execute it once again.

If you want more information, or would like to use SmartGPT as a crate in your own projects, read the documentation.

How SmartGPT Works

Autos

Autos are the building blocks of SmartGPT. There are two types of Autos.

  • Runner: A runner is given a single task, and is asked to complete it.
  • Assistants: An Assistant Auto can be conversed with, and will give you responses back, in context of the conversation.

Assistants are highly experimental, so we recommend Runners.

An Auto will under the hood, run agent. An agent has two parts: The Dynamic Agent and The Static Agent.

Dynamic Agent

The Dynamic Agent is the base agent. It runs a REACT-esque process, thinking, reasoning, and then making a decision. It can do one of three things:

  • Brainstorm.
  • Run an action.
  • Give the user a final response.

When it runs an action, the Static Agent is dispatched to run the action.

Static Agent

The Static Agent runs the subtasks given to it by the Dynamic Agent. Here's how it works:

  1. It plans out each tool that is needed in the precise order to complete the task.
  2. One by one, it'll run each step of the plan, filling in the arguments for the tool.

The Static Agent also saves assets that the Dynamic Agent can pass back to the Static Agent for future tasks.

Memory

Agents all have memory. After completing a task, the agent will save a list of all observations into long-term memory. Once it starts another task, it will pull all long-term memories related to the task (using a VectorDB for this.)

Plugin System

Autos can use a set of tools such as google_search, browse_url, etc. You define these using plugins. Plugins define their own set of tools, and can have their own data.

License

smartgpt is available under the MIT license. See LICENSE for the full license text.

smartgpt's People

Contributors

cormanz avatar dependabot[bot] avatar eltociear avatar godmoded avatar leeese avatar orvitpng avatar philip06 avatar raybytes avatar

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smartgpt's Issues

file_write error

Error: Os { code: 2, kind: NotFound, message: "No such file or directory" }
you need create the "files" folder before run smartgpt

Development of a SmartGPT Website

In the interest of continued SmartGPT development, I've purchased the smartgpt.dev domain. It would be a good idea to try to create a minimal website for organizing all of the project information in one space and perhaps launching some sort of blog.

Error: no plugin named newsapi

warning: `smartgpt` (lib) generated 20 warnings (run `cargo fix --lib -p smartgpt` to apply 15 suggestions)
    Finished release [optimized] target(s) in 0.14s
warning: the following packages contain code that will be rejected by a future version of Rust: xml5ever v0.16.2
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
     Running `target/release/smartgpt`
Error: No plugin named "newsapi".

GPT3.5 Resilience & JSON Prompting Techniques

When doing testing, gpt-3.5-turbo tends to struggle a lot with formatting JSON queries. It sometimes responds with plaintext and then gives the JSON query, or messes up the format.

This issue proposes two suggested changes.

  1. Search for any valid JSON match inside of the response. If one is found, use it (modify the message to remove anything else except the JSON response)
  2. Try to get an LLM to fix the JSON response if it's invalid.

Alongside this, it also might be a good idea to use YML for prompt token reduction and for making it easier for LLMs to understand the prompt. However, whether this is better than JSON is uncertain (it hasn't proven reliable in my light testing.)

Provide a Python version

It's a great project, but since most GPT programmers know Python, if you implement a Python version, it will attract more attention.

errors aren't specific

The errors provided, like a missing config, are not good or provided, #6 highlights this problem.

Also, sidenote, the config should be checked at runtime, not compilation.

Plugin Loading System via LLVM integration

It is possible to create a cross-platform dynamic library using LLVM that can be imported by Rust on various systems. LLVM, a collection of modular and reusable compiler and toolchain technologies, generates an intermediate representation (IR) code that provides a certain level of abstraction from the platform. Rust has the capability to link against these dynamically generated libraries.

However, creating such a library involves dealing with some complexities:

  1. Cross-platform development requires handling specific aspects tailored to different platforms in your codebase while maintaining general compatibility across all target platforms.

  2. Addressing ABI (Application Binary Interface) compatibility issues between languages when linking together compiled components may require extra consideration during implementation stages.

  3. Configuring build scripts are essential for ensuring correct compilation results, and it'd be frustrating with a lot of boilerplate for every plugin made.

Integration with PALM2

Recently, Google's PALM2 model has proven to be a ready competitor to OpenAI's GPT4. For further testing, we should try to integrate it with SmartGPT, but no Rust API for the model exists, which makes this more difficult.

We should try to see if we can integrate with PALM2 using the REST API if possible.

Windows Issues with finding SmartGPT.exe

here are the error messages:

warning: `smartgpt` (bin "smartgpt") generated 17 warnings
    Finished release [optimized] target(s) in 7.44s
     Running `target\release\smartgpt.exe`
Error: Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }
error: process didn't exit successfully: `target\release\smartgpt.exe` (exit code: 1)

beforehand there is a string of warnings:

(base) PS C:\Users\Zenchant\Documents\ALL-AGI\smartgpt> cargo run --release
   Compiling smartgpt v0.1.0 (C:\Users\Zenchant\Documents\ALL-AGI\smartgpt)
warning: unnecessary trailing semicolon
  --> src\plugins\wikipedia\mod.rs:86:110
   |
86 |     let name: String = args.get(0).ok_or(CommandNoArgError("wikipedia-browse", "name"))?.clone().try_into()?;;
   |                                                                                                              ^ help: remove this semicolon
   |
   = note: `#[warn(redundant_semicolons)]` on by default

warning: use of deprecated trait `std::ascii::AsciiExt`: use inherent methods instead
 --> src\config.rs:1:68
  |
1 | use std::{collections::HashMap, error::Error, fmt::Display, ascii::AsciiExt, process, sync::{Mutex, Arc}};
  |                                                                    ^^^^^^^^
  |
  = note: `#[warn(deprecated)]` on by default

warning: use of deprecated trait `std::ascii::AsciiExt`: use inherent methods instead
 --> src\agents\minion\continuous.rs:1:32
  |
1 | use std::{error::Error, ascii::AsciiExt};
  |                                ^^^^^^^^

warning: unreachable expression
   --> src\agents\manager.rs:128:5
    |
48  | /     loop {
49  | |         let ProgramInfo { context,   .. } = program;
50  | |         let mut context = context.lock().unwrap();
51  | |
...   |
125 | |         }
126 | |     }
    | |_____- any code following this expression is unreachable
127 |
128 |       Ok(())
    |       ^^^^^^ unreachable expression
    |
    = note: `#[warn(unreachable_code)]` on by default

warning: unused import: `ascii::AsciiExt`
 --> src\config.rs:1:61
  |
1 | use std::{collections::HashMap, error::Error, fmt::Display, ascii::AsciiExt, process, sync::{Mutex, Arc}};
  |                                                             ^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `ascii::AsciiExt`
 --> src\agents\minion\continuous.rs:1:25
  |
1 | use std::{error::Error, ascii::AsciiExt};
  |                         ^^^^^^^^^^^^^^^

warning: variable `first_prompt` is assigned to, but never used
  --> src\agents\manager.rs:44:13
   |
44 |     let mut first_prompt = true;
   |             ^^^^^^^^^^^^
   |
   = note: consider using `_first_prompt` instead
   = note: `#[warn(unused_variables)]` on by default

warning: value assigned to `first_prompt` is never read
  --> src\agents\manager.rs:67:9
   |
67 |         first_prompt = false;
   |         ^^^^^^^^^^^^
   |
   = help: maybe it is overwritten before being read?
   = note: `#[warn(unused_assignments)]` on by default

warning: function `debug_yaml` is never used
  --> src\main.rs:37:4
   |
37 | fn debug_yaml(results: &str) -> Result<(), Box<dyn Error>> {
   |    ^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: function `generate_goals` is never used
  --> src\prompt.rs:84:4
   |
84 | fn generate_goals(goals: &[String]) -> String {
   |    ^^^^^^^^^^^^^^

warning: function `test` is never used
  --> src\agents\mod.rs:56:8
   |
56 | pub fn test() {
   |        ^^^^

warning: function `try_parse_yaml` is never used
  --> src\agents\mod.rs:61:8
   |
61 | pub fn try_parse_yaml<T : DeserializeOwned>(llm: &LLM, tries: usize, max_tokens: Option<u16>) -> Result<(String...
   |        ^^^^^^^^^^^^^^

warning: variants `Manager`, `Boss`, and `Employee` are never constructed
   --> src\agents\mod.rs:99:5
    |
98  | pub enum Agent {
    |          ----- variants in this enum
99  |     Manager,
    |     ^^^^^^^
100 |     Boss,
    |     ^^^^
101 |     Employee
    |     ^^^^^^^^
    |
    = note: `Agent` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis

warning: variant `Feedback` is never constructed
  --> src\agents\boss.rs:11:5
   |
9  | pub enum Task {
   |          ---- variant in this enum
10 |     Task(String),
11 |     Feedback(String, String)
   |     ^^^^^^^^
   |
   = note: `Task` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis

warning: function `run_lua_minion` is never used
  --> src\agents\minion\lua.rs:11:8
   |
11 | pub fn run_lua_minion(
   |        ^^^^^^^^^^^^^^

warning: unused `Result` that must be used
  --> src\runner\mod.rs:26:5
   |
26 | /     run_script(
27 | |         &mut program,
28 | |         r#"wikipedia_browse("Ronald Reagan")"#,
29 | |         &Lua::new()
30 | |     );
   | |_____^
   |
   = note: this `Result` may be an `Err` variant, which should be handled
   = note: `#[warn(unused_must_use)]` on by default

warning: unused `Result` that must be used
   --> src\agents\minion\continuous.rs:166:13
    |
166 |             context.agents.minion.llm.crop_to_tokens_remaining(1800);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this `Result` may be an `Err` variant, which should be handled

warning: `smartgpt` (bin "smartgpt") generated 17 warnings

more concrete example?

Would it be possible to provide a more concrete example of how to use it, in the README file?

Like an example where we ask it a specific question and save the result as a file (though STDOUT would be good enough, honestly!).

Alas, the README was just slightly over my head, but only slightly.

Smart Agents

Introduction

This is a major issue that will revamp how SmartGPT works.

Projects like SwarmGPT show the potential of large amounts of parallelized agents working together. Meanwhile, SmartGPT has still had great results with the hierarchical system. Alongside this, papers such as the Generative Agents: Interactive Simulacra of Human Behavior paper show the power of giving agents the ability to have memories and self-reflect.

This issue proposes a new major feature: Smart Agents.

Smart Agents

Smart Agents have three separate contexts that handle different parts of their processing.

Brainstormer: All agents have a Brainstormer context. This handles short-term memory: specifically, it handles brainstorming ideas and short-term thoughts and plans. This handles all of the current tasks, thoughts, etc.
Reflector: The Reflector context though, does equally important work in the background. It handles long-term memory: chunking short-term observations together via self-reflection, pruning old memories, long-term planning, and keeping track of the final end goals.

Then, depending on whether or not it is an employee or a manager, it has one additional context, called an Actor. There are two types of Actor contexts: Executors and Delegators.

Executor: For employees, the Executor context takes the ideas from the Brainstormer, and finds out how to turn them into commands. It'll also extract useful information so that the Brainstormer and Reflector can more easily process it.
Delegator: For managers, the Delegator context takes the ideas from the Brainstormer, and delegates them as tasks to its employees. Then, it collaborates with those employees to ensure the tasks are carried out successfully.

All three of these contexts come together to form the Agent. Here's how it works in Employees.

The Reflector analyzes the problem; then the Brainstormer begins brainstorming ideas. The Brainstormer and Executor work together frequently, the Brainstormer giving ideas, the Executor executing them. Meanwhile, the Reflector works in the background, sorting through these new memories, and reflecting them. It makes sure the Brainstormer and Executor are working towards this goal.

Finally, the contexts also have one additional type of memory that is shared: The Web. The Web is just a network of embeddings; the contexts store information there, and can search for it later.

Dynamic Agents

Smart Agents also have one other key feature: they're built to be dynamic.

Currently, SmartGPT uses a static system of layers for how your program is organized. You start from the top manager, then go down to the lowest employee. This doesn't scale well, though.

SmartGPT will still start from the top agent. However, each agent will decide whether it should be an employee or a manager, and it can change its role later on, too. A manager can also have multiple employees working in parallel.

Dynamic Agents are a future feature that Smart Agents is meant to built on top off.

Note

Whether we use the Brainstormer, Reflector, Actor architecture is uncertain. However, the idea of Smart Agents and having some sort of internal contexts helping keep it organized is likely key, so we aim to prioritize this.

Context Cutoff

Currently, the context gets cut off after 4,000 tokens if it thinks for too long.

Perhaps we could auto-cut the context down to say 3,000 tokens? Any lost context could be turned into observations.

Using Headless Browsers

It seems like a good idea to integrate headless browsers using a Rust crate such as thirtyfour to allow for fast, performant, and easy access to existing plugins that rely on websites without needing API keys for setting up tools such as google, which can be complicated for some users. It could also make it much easier to implement new tools and APIs.

error[E0583]: file not found for module `assets`

  Compiling smartgpt v0.1.0 (/home/x/dev/python/ai/smartgpt)
error[E0583]: file not found for module `assets`
 --> src/plugins/mod.rs:5:1
  |
5 | mod assets;
  | ^^^^^^^^^^^
  |
  = help: to create the module `assets`, create file "src/plugins/assets.rs" or "src/plugins/assets/mod.rs"

error[E0432]: unresolved import `crate::create_assets`
 --> src/api/config/mod.rs:7:298
  |
7 | ...y_qdrant, MemorySystem, create_memory_redis, create_assets, PluginStore, create_brainstorm, SmartGPT};
  |                                                 ^^^^^^^^^^^^^
  |                                                 |
  |                                                 no `create_assets` in the root
  |                                                 help: a similar name exists in the module: `create_news`

warning: unused import: `Deserialize`
 --> src/plugin.rs:4:46
  |
4 | use serde::{Serialize, de::DeserializeOwned, Deserialize};
  |                                              ^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `AutoType`
  --> src/plugin.rs:29:45
   |
29 | use crate::{LLM, ScriptValue, MemorySystem, AutoType};
   |                                             ^^^^^^^^

warning: unused import: `serde::Serialize`
 --> src/api/smartgpt.rs:3:5
  |
3 | use serde::Serialize;
  |     ^^^^^^^^^^^^^^^^

warning: unused imports: `LLMModel`, `LLMProvider`
 --> src/api/smartgpt.rs:6:61
  |
6 | use crate::{CommandContext, PluginStore, Agents, AgentInfo, LLMProvider, LLMModel, LLM, ChatGPTProvider, ChatGPTConfig, memory_from_provider, LocalProvider, auto::{...
  |                                                             ^^^^^^^^^^^  ^^^^^^^^

warning: unused import: `AgentInfo`
 --> src/auto/agents/worker/mod.rs:2:23
  |
2 | use crate::{SmartGPT, AgentInfo, auto::{run::Action, DisallowedAction}};
  |                       ^^^^^^^^^

warning: unused import: `colored::Colorize`
 --> src/auto/agents/worker/adept.rs:2:5
  |
2 | use colored::Colorize;
  |     ^^^^^^^^^^^^^^^^^

warning: unused import: `log_yaml`
 --> src/auto/agents/worker/adept.rs:5:90
  |
5 | use crate::{CommandContext, AgentInfo, Message, auto::{try_parse_json, agents::{worker::{log_yaml, run_method_agent}}, run::Action, DisallowedAction, DynamicUpdate}...
  |                                                                                          ^^^^^^^^

warning: unused import: `colored::Colorize`
 --> src/auto/agents/worker/methodical.rs:3:5
  |
3 | use colored::Colorize;
  |     ^^^^^^^^^^^^^^^^^

warning: unused import: `log_yaml`
 --> src/auto/agents/worker/methodical.rs:8:13
  |
8 | use super::{log_yaml, use_tool};
  |             ^^^^^^^^

Some errors have detailed explanations: E0432, E0583.
For more information about an error, try `rustc --explain E0432`.
warning: `smartgpt` (lib) generated 9 warnings
error: could not compile `smartgpt` due to 2 previous errors; 9 warnings emitted
warning: build failed, waiting for other jobs to finish...

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.