superagi 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b1109bc83d866891b9a49c0f029536824dd65895a64941e24a3b6c00e2e15f1d
4
+ data.tar.gz: 815b50f3d3c237354c64b46da34f61fafec6252bcdae843d5989ba1198f10040
5
+ SHA512:
6
+ metadata.gz: e9a06e3bb7db1570373e08767485484b4052df9f0731a8b8f44e6bbf67528a8d217d1c0f96e6be158167f0aad9255a3c004ca3b8db405a4ca725910d4cd28a04
7
+ data.tar.gz: c84e0b997d14bbe4466a8a71431d0ff400e415f6d110a88143c0f1fe64e611fa80922f95a89c8494c12f43e016435c4d2505eb3f92f3f0d9c8156b995911a02e
@@ -0,0 +1,45 @@
1
+ version: 2.1 # Use 2.1 to enable using orbs and other features.
2
+
3
+ # Declare the orbs that we'll use in our config.
4
+ orbs:
5
+ ruby: circleci/ruby@1.0
6
+
7
+ jobs:
8
+ rubocop:
9
+ parallelism: 1
10
+ docker:
11
+ - image: cimg/ruby:3.1-node
12
+ steps:
13
+ - checkout
14
+ - ruby/install-deps
15
+ - run:
16
+ name: Run Rubocop
17
+ command: bundle exec rubocop
18
+ test:
19
+ parameters:
20
+ ruby-image:
21
+ type: string
22
+ parallelism: 1
23
+ docker:
24
+ - image: << parameters.ruby-image >>
25
+ steps:
26
+ - checkout
27
+ - ruby/install-deps
28
+ - run:
29
+ name: Run tests
30
+ command: bundle exec rspec -fd
31
+
32
+ workflows:
33
+ version: 2
34
+ checks:
35
+ jobs:
36
+ - rubocop
37
+ - test:
38
+ matrix:
39
+ parameters:
40
+ ruby-image:
41
+ - cimg/ruby:2.6-node
42
+ - cimg/ruby:2.7-node
43
+ - cimg/ruby:3.0-node
44
+ - cimg/ruby:3.1-node
45
+ - cimg/ruby:3.2-node
@@ -0,0 +1,16 @@
1
+ FROM ruby:3.2.2-slim-bullseye
2
+
3
+ ENV TZ="Europe/London"
4
+
5
+ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
6
+ && apt-get -y install --no-install-recommends \
7
+ apt-utils \
8
+ build-essential \
9
+ curl \
10
+ git \
11
+ vim \
12
+ zsh
13
+
14
+ RUN gem install bundler
15
+
16
+ WORKDIR /workspace
@@ -0,0 +1,36 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2
+ // https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/ruby-rails-postgres
3
+ // Update the VARIANT arg in docker-compose.yml to pick a Ruby version
4
+ {
5
+ "name": "superagi",
6
+ "dockerComposeFile": "docker-compose.yml",
7
+ "service": "app",
8
+ "workspaceFolder": "/workspace",
9
+ "containerEnv": {
10
+ "GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}",
11
+ "GITHUB_USER": "${localEnv:GITHUB_USER}"
12
+ },
13
+ // Configure tool-specific properties.
14
+ "customizations": {
15
+ // Configure properties specific to VS Code.
16
+ "vscode": {
17
+ // Add the IDs of extensions you want installed when the container is created.
18
+ "extensions": [
19
+ "rebornix.Ruby",
20
+ "sleistner.vscode-fileutils",
21
+ "ms-azuretools.vscode-docker",
22
+ "samverschueren.final-newline",
23
+ "GitHub.copilot",
24
+ "usernamehw.remove-empty-lines",
25
+ "wingrunr21.vscode-ruby",
26
+ ]
27
+ }
28
+ },
29
+ // Use 'postCreateCommand' to run commands after the container is created.
30
+ "postCreateCommand": "bundle install",
31
+ // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
32
+ "features": {
33
+ "git": "os-provided",
34
+ "github-cli": "latest"
35
+ }
36
+ }
@@ -0,0 +1,19 @@
1
+ version: "3"
2
+
3
+ services:
4
+ app:
5
+ build:
6
+ context: ..
7
+ dockerfile: .devcontainer/Dockerfile
8
+
9
+ volumes:
10
+ - ..:/workspace:cached
11
+ - bundle_cache:/bundle
12
+
13
+ command: sleep infinity
14
+
15
+ environment:
16
+ TZ: Europe/London
17
+
18
+ volumes:
19
+ bundle_cache:
@@ -0,0 +1,13 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: alexrudall
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+ - OS: [e.g. iOS]
28
+ - Browser [e.g. chrome, safari]
29
+ - Version [e.g. 22]
30
+
31
+ **Smartphone (please complete the following information):**
32
+ - Device: [e.g. iPhone6]
33
+ - OS: [e.g. iOS8.1]
34
+ - Browser [e.g. stock browser, safari]
35
+ - Version [e.g. 22]
36
+
37
+ **Additional context**
38
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,15 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
8
+ ignore:
9
+ - dependency-name: webmock
10
+ versions:
11
+ - 3.11.1
12
+ - 3.11.3
13
+ - dependency-name: rspec
14
+ versions:
15
+ - 3.10.0
data/.gitignore ADDED
@@ -0,0 +1,74 @@
1
+ ### Ruby ###
2
+ *.gem
3
+ *.rbc
4
+ /.config
5
+ /coverage/
6
+ /InstalledFiles
7
+ /pkg/
8
+ /spec/reports/
9
+ /spec/examples.txt
10
+ /test/tmp/
11
+ /test/version_tmp/
12
+ /tmp/
13
+ /.bundle/
14
+ /.yardoc
15
+ /_yardoc/
16
+ /doc/
17
+
18
+
19
+ # Used by dotenv library to load environment variables.
20
+ .env
21
+
22
+ # Ignore Byebug command history file.
23
+ .byebug_history
24
+
25
+ ## Specific to RubyMotion:
26
+ .dat*
27
+ .repl_history
28
+ build/
29
+ *.bridgesupport
30
+ build-iPhoneOS/
31
+ build-iPhoneSimulator/
32
+
33
+ ## Specific to RubyMotion (use of CocoaPods):
34
+ #
35
+ # We recommend against adding the Pods directory to your .gitignore. However
36
+ # you should judge for yourself, the pros and cons are mentioned at:
37
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
38
+ # vendor/Pods/
39
+
40
+ ## Documentation cache and generated files:
41
+ /.yardoc/
42
+ /_yardoc/
43
+ /doc/
44
+ /rdoc/
45
+
46
+ ## Environment normalization:
47
+ /.bundle/
48
+ /vendor/bundle
49
+ /lib/bundler/man/
50
+
51
+ # for a library or gem, you might want to ignore these files since the code is
52
+ # intended to run in multiple environments; otherwise, check them in:
53
+ # Gemfile.lock
54
+ # .ruby-version
55
+ # .ruby-gemset
56
+
57
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
58
+ .rvmrc
59
+
60
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
61
+ # .rubocop-https?--*
62
+
63
+ # rspec failure tracking
64
+ .rspec_status
65
+
66
+ # IDE
67
+ .idea
68
+ .idea/
69
+ .idea/*
70
+ .vscode
71
+ .vs/
72
+
73
+ # Mac
74
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,31 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+ NewCops: enable
4
+ SuggestExtensions: false
5
+
6
+ Style/Documentation:
7
+ # Skips checking to make sure top level modules / classes have a comment.
8
+ Enabled: false
9
+
10
+ Layout/LineLength:
11
+ Max: 100
12
+ Exclude:
13
+ - "**/*.gemspec"
14
+
15
+ Lint/AmbiguousOperator:
16
+ # https://github.com/rubocop/rubocop/issues/4294
17
+ Exclude:
18
+ - "lib/superagi/client.rb"
19
+
20
+ Metrics/AbcSize:
21
+ Max: 20
22
+
23
+ Metrics/BlockLength:
24
+ Exclude:
25
+ - "spec/**/*"
26
+
27
+ Style/StringLiterals:
28
+ EnforcedStyle: double_quotes
29
+
30
+ Style/FrozenStringLiteralComment:
31
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2023-10-25
9
+
10
+ ### Added
11
+
12
+ - Initialise repository.
13
+ - Add SuperAGI::Client to connect to SuperAGI API using user credentials.
14
+ - Add SuperAGI::Agent#create to create a new agent.
15
+ - Add spec for Client with a cached response using VCR.
16
+ - Add CircleCI to run the specs on pull requests.
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at alexrudall@users.noreply.github.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,3 @@
1
+ ## Contributing
2
+
3
+ Bug reports and pull requests are welcome on GitHub at https://github.com/alexrudall/superagi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/alexrudall/superagi/blob/main/CODE_OF_CONDUCT.md).
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Include gem dependencies from superagi.gemspec
4
+ gemspec
5
+
6
+ gem "byebug", "~> 11.1.3"
7
+ gem "dotenv", "~> 2.8.1"
8
+ gem "rake", "~> 13.0"
9
+ gem "rspec", "~> 3.12"
10
+ gem "rubocop", "~> 1.50.2"
11
+ gem "vcr", "~> 6.1.0"
12
+ gem "webmock", "~> 3.19.1"
data/Gemfile.lock ADDED
@@ -0,0 +1,86 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ superagi (0.1.0)
5
+ faraday (>= 1)
6
+ faraday-multipart (>= 1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.8.5)
12
+ public_suffix (>= 2.0.2, < 6.0)
13
+ ast (2.4.2)
14
+ base64 (0.1.1)
15
+ byebug (11.1.3)
16
+ crack (0.4.5)
17
+ rexml
18
+ diff-lcs (1.5.0)
19
+ dotenv (2.8.1)
20
+ faraday (2.7.11)
21
+ base64
22
+ faraday-net_http (>= 2.0, < 3.1)
23
+ ruby2_keywords (>= 0.0.4)
24
+ faraday-multipart (1.0.4)
25
+ multipart-post (~> 2)
26
+ faraday-net_http (3.0.2)
27
+ hashdiff (1.0.1)
28
+ json (2.6.3)
29
+ multipart-post (2.3.0)
30
+ parallel (1.22.1)
31
+ parser (3.2.2.0)
32
+ ast (~> 2.4.1)
33
+ public_suffix (5.0.3)
34
+ rainbow (3.1.1)
35
+ rake (13.0.6)
36
+ regexp_parser (2.8.0)
37
+ rexml (3.2.6)
38
+ rspec (3.12.0)
39
+ rspec-core (~> 3.12.0)
40
+ rspec-expectations (~> 3.12.0)
41
+ rspec-mocks (~> 3.12.0)
42
+ rspec-core (3.12.0)
43
+ rspec-support (~> 3.12.0)
44
+ rspec-expectations (3.12.2)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.12.0)
47
+ rspec-mocks (3.12.3)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.12.0)
50
+ rspec-support (3.12.0)
51
+ rubocop (1.50.2)
52
+ json (~> 2.3)
53
+ parallel (~> 1.10)
54
+ parser (>= 3.2.0.0)
55
+ rainbow (>= 2.2.2, < 4.0)
56
+ regexp_parser (>= 1.8, < 3.0)
57
+ rexml (>= 3.2.5, < 4.0)
58
+ rubocop-ast (>= 1.28.0, < 2.0)
59
+ ruby-progressbar (~> 1.7)
60
+ unicode-display_width (>= 2.4.0, < 3.0)
61
+ rubocop-ast (1.28.0)
62
+ parser (>= 3.2.1.0)
63
+ ruby-progressbar (1.13.0)
64
+ ruby2_keywords (0.0.5)
65
+ unicode-display_width (2.4.2)
66
+ vcr (6.1.0)
67
+ webmock (3.19.1)
68
+ addressable (>= 2.8.0)
69
+ crack (>= 0.3.2)
70
+ hashdiff (>= 0.4.0, < 2.0.0)
71
+
72
+ PLATFORMS
73
+ ruby
74
+
75
+ DEPENDENCIES
76
+ byebug (~> 11.1.3)
77
+ dotenv (~> 2.8.1)
78
+ rake (~> 13.0)
79
+ rspec (~> 3.12)
80
+ rubocop (~> 1.50.2)
81
+ superagi!
82
+ vcr (~> 6.1.0)
83
+ webmock (~> 3.19.1)
84
+
85
+ BUNDLED WITH
86
+ 2.4.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Alex Rudall
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # SuperAGI
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/superagi.svg)](https://badge.fury.io/rb/superagi)
4
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/alexrudall/superagi/blob/main/LICENSE.txt)
5
+ [![CircleCI Build Status](https://circleci.com/gh/alexrudall/superagi.svg?style=shield)](https://circleci.com/gh/alexrudall/superagi)
6
+
7
+ Use the [SuperAGI API](https://superagi.com/blog/superagi-api/) with Ruby! 🦄❤️
8
+
9
+ Create and Manage Agents in your Ruby app...
10
+
11
+ 🚢 Hire me: [peaceterms.com](https://railsai.com?utm_source=superagi&utm_medium=readme&utm_id=26072023)
12
+
13
+ [🎮 Ruby AI Builders Discord](https://discord.gg/k4Uc224xVD) | [🐦 Twitter](https://twitter.com/alexrudall) | [🤖 OpenAI Gem](https://github.com/alexrudall/ruby-openai) | [🧠 Anthropic Gem](https://github.com/alexrudall/anthropic) | [🚂 Midjourney Gem](https://github.com/alexrudall/midjourney)
14
+
15
+ ### Bundler
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem "superagi"
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ ```bash
26
+ $ bundle install
27
+ ```
28
+
29
+ ### Gem install
30
+
31
+ Or install with:
32
+
33
+ ```bash
34
+ $ gem install superagi
35
+ ```
36
+
37
+ and require with:
38
+
39
+ ```ruby
40
+ require "superagi"
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ - Get your API key from [https://app.superagi.com/](https://app.superagi.com/)
46
+ - Click Go to settings, API Keys, Create Key
47
+
48
+ ### Quickstart
49
+
50
+ For a quick test you can pass your token directly to a new client:
51
+
52
+ ```ruby
53
+ client = SuperAGI::Client.new(secret_key: "secret_key_goes_here")
54
+ ```
55
+
56
+ ### With Config
57
+
58
+ For a more robust setup, you can configure the gem with your API keys, for example in an `superagi.rb` initializer file. Never hardcode secrets into your codebase - instead use something like [dotenv](https://github.com/motdotla/dotenv) to pass the keys safely into your environments.
59
+
60
+ ```ruby
61
+ SuperAGI.configure do |config|
62
+ config.secret_key = ENV.fetch("SUPERAGI_SECRET_KEY")
63
+ end
64
+ ```
65
+
66
+ Then you can create a client like this:
67
+
68
+ ```ruby
69
+ client = SuperAGI::Client.new
70
+ ```
71
+
72
+ You can still override the config defaults when making new clients; any options not included will fall back to any global config set with SuperAGI.configure. e.g. in this example the request_timeout, etc. will fallback to any set globally using SuperAGI.configure, with only the secret_key overridden:
73
+
74
+ ```ruby
75
+ client = SuperAGI::Client.new(secret_key: "secret_key_goes_here")
76
+ ```
77
+
78
+ #### Custom timeout or base URI
79
+
80
+ The default timeout for any request using this library is 120 seconds. You can change that by passing a number of seconds to the `request_timeout` when initializing the client. You can also change the base URI used for all requests.
81
+
82
+ ```ruby
83
+ client = SuperAGI::Client.new(
84
+ secret_key: "secret_key_goes_here",
85
+ uri_base: "https://app.alternativeapi.com/",
86
+ request_timeout: 240,
87
+ extra_headers: {
88
+ "X-Proxy-TTL" => "43200", # For https://github.com/6/superagi-caching-proxy-worker#specifying-a-cache-ttl
89
+ "X-Proxy-Refresh": "true", # For https://github.com/6/superagi-caching-proxy-worker#refreshing-the-cache
90
+ "Helicone-Auth": "Bearer HELICONE_API_KEY", # For https://docs.helicone.ai/getting-started/integration-method/superagi-proxy
91
+ "helicone-stream-force-format" => "true", # Use this with Helicone otherwise streaming drops chunks # https://github.com/alexrudall/superagi/issues/251
92
+ }
93
+ )
94
+ ```
95
+
96
+ or when configuring the gem:
97
+
98
+ ```ruby
99
+ SuperAGI.configure do |config|
100
+ config.secret_key = ENV.fetch("SUPERAGI_SECRET_KEY")
101
+ config.uri_base = "https://app.alternativeapi.com/" # Optional
102
+ config.request_timeout = 240 # Optional
103
+ config.extra_headers = {
104
+ "abc" => "123",
105
+ "def": "456",
106
+ } # Optional
107
+ end
108
+ ```
109
+
110
+ ## Development
111
+
112
+ After checking out the repo, run `bin/setup` to install dependencies. You can run `bin/console` for an interactive prompt that will allow you to experiment.
113
+
114
+ To install this gem onto your local machine, run `bundle exec rake install`.
115
+
116
+ ### Warning
117
+
118
+ If you have an `SUPERAGI_SECRET_KEY` in your `ENV`, running the specs will use this to run the specs against the actual API, which will be slow and cost you money - 2 cents or more! Remove it from your environment with `unset` or similar if you just want to run the specs against the stored VCR responses.
119
+
120
+ ## Release
121
+
122
+ First run the specs without VCR so they actually hit the API. This will cost 2 cents or more. Set SUPERAGI_SECRET_KEY in your environment or pass it in like this:
123
+
124
+ ```
125
+ SUPERAGI_SECRET_KEY=123abc bundle exec rspec
126
+ ```
127
+
128
+ Then update the version number in `version.rb`, update `CHANGELOG.md`, run `bundle install` to update Gemfile.lock, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
129
+
130
+ ## Contributing
131
+
132
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/alexrudall/superagi>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/alexrudall/superagi/blob/main/CODE_OF_CONDUCT.md).
133
+
134
+ ## License
135
+
136
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
137
+
138
+ ## Code of Conduct
139
+
140
+ Everyone interacting in the Ruby SuperAGI project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/alexrudall/superagi/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "superagi"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,2 @@
1
+ require_relative "../superagi"
2
+ require_relative "../superagi/compatibility"
@@ -0,0 +1,74 @@
1
+ module SuperAGI
2
+ class Agent
3
+ # '{"loc":["body","constraints"],"msg":"field
4
+ # required","type":"value_error.missing"},{"loc":["body","tools"],"msg":"field
5
+ # required","type":"value_error.missing"},{"loc":["body","iteration_interval"],"msg":"field
6
+ # required","type":"value_error.missing"},{"loc":["body","max_iterations"],"msg":"field
7
+ # required","type":"value_error.missing"}]}'
8
+
9
+ def initialize(client:)
10
+ @client = client
11
+ end
12
+
13
+ def create(parameters:)
14
+ parameters = valid_parameters(parameters: parameters)
15
+ @client.json_post(path: "/agent", parameters: parameters)
16
+ end
17
+
18
+ # def update(id:, parameters: {})
19
+ # end
20
+
21
+ # def pause(id:)
22
+ # end
23
+
24
+ # def resume(id:)
25
+ # end
26
+
27
+ # def delete(id:)
28
+ # end
29
+
30
+ # def status(id:)
31
+ # end
32
+
33
+ # def resources(id:)
34
+ # end
35
+
36
+ private
37
+
38
+ DEFAULT_PARAMETERS = {
39
+ agent_workflow: "Goal Based Workflow",
40
+ model: "gpt-4"
41
+ }.freeze
42
+ ARRAY_PARAMETERS = %w[
43
+ constraints
44
+ goal
45
+ tools
46
+ ].freeze
47
+ REQUIRED_PARAMETERS = (%w[
48
+ description
49
+ instruction
50
+ iteration_interval
51
+ max_iterations
52
+ name
53
+ ] + ARRAY_PARAMETERS + DEFAULT_PARAMETERS.keys).freeze
54
+
55
+ def valid_parameters(parameters:)
56
+ parameters = DEFAULT_PARAMETERS.merge(parameters)
57
+ validate_presence(parameters: parameters)
58
+ validate_arrays(parameters: parameters)
59
+ parameters
60
+ end
61
+
62
+ def validate_presence(parameters:)
63
+ REQUIRED_PARAMETERS.each do |key|
64
+ raise ArgumentError, "#{key} is required" unless parameters[key.to_sym]
65
+ end
66
+ end
67
+
68
+ def validate_arrays(parameters:)
69
+ ARRAY_PARAMETERS.each do |key|
70
+ raise ArgumentError, "#{key} must be an array" unless parameters[key.to_sym].is_a?(Array)
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,27 @@
1
+ module SuperAGI
2
+ class Client
3
+ include SuperAGI::HTTP
4
+
5
+ CONFIG_KEYS = %i[
6
+ api_type
7
+ api_version
8
+ secret_key
9
+ uri_base
10
+ request_timeout
11
+ extra_headers
12
+ ].freeze
13
+ attr_reader *CONFIG_KEYS
14
+
15
+ def initialize(config = {})
16
+ CONFIG_KEYS.each do |key|
17
+ # Set instance variables like api_type & secret_key. Fall back to global config
18
+ # if not present.
19
+ instance_variable_set("@#{key}", config[key] || SuperAGI.configuration.send(key))
20
+ end
21
+ end
22
+
23
+ def agent
24
+ @agent ||= SuperAGI::Agent.new(client: self)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,9 @@
1
+ module Ruby
2
+ module SuperAGI
3
+ VERSION = ::SuperAGI::VERSION
4
+
5
+ Error = ::SuperAGI::Error
6
+ ConfigurationError = ::SuperAGI::ConfigurationError
7
+ Configuration = ::SuperAGI::Configuration
8
+ end
9
+ end
@@ -0,0 +1,55 @@
1
+ module SuperAGI
2
+ module HTTP
3
+ def get(path:)
4
+ to_json(conn.get(uri(path: path)) do |req|
5
+ req.headers = headers
6
+ end&.body)
7
+ end
8
+
9
+ def json_post(path:, parameters:)
10
+ to_json(conn.post(uri(path: path)) do |req|
11
+ req.headers = headers
12
+ req.body = parameters.to_json
13
+ end&.body)
14
+ end
15
+
16
+ def delete(path:)
17
+ to_json(conn.delete(uri(path: path)) do |req|
18
+ req.headers = headers
19
+ end&.body)
20
+ end
21
+
22
+ private
23
+
24
+ def to_json(string)
25
+ return unless string
26
+
27
+ JSON.parse(string)
28
+ rescue JSON::ParserError
29
+ # Convert a multiline string of JSON objects to a JSON array.
30
+ JSON.parse(string.gsub("}\n{", "},{").prepend("[").concat("]"))
31
+ end
32
+
33
+ def conn(multipart: false)
34
+ Faraday.new do |f|
35
+ f.options[:timeout] = @request_timeout
36
+ f.request(:multipart) if multipart
37
+ end
38
+ end
39
+
40
+ def uri(path:)
41
+ File.join(@uri_base, @api_version, path)
42
+ end
43
+
44
+ def headers
45
+ superagi_headers.merge(@extra_headers || {})
46
+ end
47
+
48
+ def superagi_headers
49
+ {
50
+ "Content-Type" => "application/json",
51
+ "X-api-key" => @secret_key
52
+ }
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module SuperAGI
2
+ VERSION = "0.1.0".freeze
3
+ end
data/lib/superagi.rb ADDED
@@ -0,0 +1,49 @@
1
+ require "faraday"
2
+ require "faraday/multipart"
3
+
4
+ require_relative "superagi/http"
5
+ require_relative "superagi/client"
6
+ require_relative "superagi/agent"
7
+
8
+ module SuperAGI
9
+ class Error < StandardError; end
10
+ class ConfigurationError < Error; end
11
+
12
+ class Configuration
13
+ attr_writer :secret_key
14
+ attr_accessor :api_type, :api_version, :uri_base, :request_timeout,
15
+ :extra_headers
16
+
17
+ DEFAULT_API_VERSION = "v1".freeze
18
+ DEFAULT_URI_BASE = "https://app.superagi.com/api/".freeze
19
+ DEFAULT_REQUEST_TIMEOUT = 120
20
+
21
+ def initialize
22
+ @secret_key = nil
23
+ @api_type = nil
24
+ @api_version = DEFAULT_API_VERSION
25
+ @uri_base = DEFAULT_URI_BASE
26
+ @request_timeout = DEFAULT_REQUEST_TIMEOUT
27
+ @extra_headers = nil
28
+ end
29
+
30
+ def secret_key
31
+ return @secret_key if @secret_key
32
+
33
+ error_text = "SuperAGI secret key missing! See https://github.com/alexrudall/superagi#usage"
34
+ raise ConfigurationError, error_text
35
+ end
36
+ end
37
+
38
+ class << self
39
+ attr_writer :configuration
40
+ end
41
+
42
+ def self.configuration
43
+ @configuration ||= SuperAGI::Configuration.new
44
+ end
45
+
46
+ def self.configure
47
+ yield(configuration)
48
+ end
49
+ end
@@ -0,0 +1,5 @@
1
+ ## All Submissions:
2
+
3
+ * [ ] Have you followed the guidelines in our [Contributing document](../blob/main/CONTRIBUTING.md)?
4
+ * [ ] Have you checked to ensure there aren't other open [Pull Requests](../pulls) for the same update/change?
5
+ * [ ] Have you added an explanation of what your changes do and why you'd like us to include them?
data/superagi.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ require_relative "lib/superagi/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "superagi"
5
+ spec.version = SuperAGI::VERSION
6
+ spec.authors = ["Alex"]
7
+ spec.email = ["alexrudall@users.noreply.github.com"]
8
+
9
+ spec.summary = "SuperAGI API + Ruby! 🦄❤️"
10
+ spec.homepage = "https://github.com/alexrudall/superagi"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = "https://github.com/alexrudall/superagi"
16
+ spec.metadata["changelog_uri"] = "https://github.com/alexrudall/superagi/blob/main/CHANGELOG.md"
17
+ spec.metadata["rubygems_mfa_required"] = "true"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_dependency "faraday", ">= 1"
29
+ spec.add_dependency "faraday-multipart", ">= 1"
30
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: superagi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alex
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-10-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday-multipart
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
41
+ description:
42
+ email:
43
+ - alexrudall@users.noreply.github.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".circleci/config.yml"
49
+ - ".devcontainer/Dockerfile"
50
+ - ".devcontainer/devcontainer.json"
51
+ - ".devcontainer/docker-compose.yml"
52
+ - ".github/FUNDING.yml"
53
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
54
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
55
+ - ".github/dependabot.yml"
56
+ - ".gitignore"
57
+ - ".rspec"
58
+ - ".rubocop.yml"
59
+ - CHANGELOG.md
60
+ - CODE_OF_CONDUCT.md
61
+ - CONTRIBUTING.md
62
+ - Gemfile
63
+ - Gemfile.lock
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - lib/ruby/superagi.rb
70
+ - lib/superagi.rb
71
+ - lib/superagi/agent.rb
72
+ - lib/superagi/client.rb
73
+ - lib/superagi/compatibility.rb
74
+ - lib/superagi/http.rb
75
+ - lib/superagi/version.rb
76
+ - pull_request_template.md
77
+ - superagi.gemspec
78
+ homepage: https://github.com/alexrudall/superagi
79
+ licenses:
80
+ - MIT
81
+ metadata:
82
+ homepage_uri: https://github.com/alexrudall/superagi
83
+ source_code_uri: https://github.com/alexrudall/superagi
84
+ changelog_uri: https://github.com/alexrudall/superagi/blob/main/CHANGELOG.md
85
+ rubygems_mfa_required: 'true'
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 2.6.0
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubygems_version: 3.4.10
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: "SuperAGI API + Ruby! \U0001F984❤️"
105
+ test_files: []