Skip to content

Commit

Permalink
Merge pull request #1 from Phoenix2809/contributing-md
Browse files Browse the repository at this point in the history
Contributing md
  • Loading branch information
Phoenix2809 authored Jun 30, 2023
2 parents 84c8226 + a0dcced commit d181921
Show file tree
Hide file tree
Showing 60 changed files with 302 additions and 110 deletions.
70 changes: 70 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# ⚡ Contributing to SuperAGI
<p align=center>
<a href=”https://superagi.co”><img src=https://superagi.co/wp-content/uploads/2023/05/SuperAGI_icon.png></a>
</p>

First of all, thank you for taking your time to to contribute to this project. We truly appreciate your contributions, whether it's bug reports, feature suggestions, or pull requests. Your time and effort are highly valued in this project. 🚀

This document provides guidelines and best practices to help you to contribute effectively. These are meant to serve as guidelines, not strict rules. We encourage you to use your best judgment and feel comfortable proposing changes to this document through a pull request.

**********************************Table of Content:**********************************
1. [Code of conduct](https://github.com/Phoenix2809/SuperAGI/blob/contributing-md/CONTRIBUTING.md#code-of-conduct)
2. [Getting Started](https://github.com/Phoenix2809/SuperAGI/blob/contributing-md/CONTRIBUTING.md#getting-started)
3. [How can I contribute](https://github.com/Phoenix2809/SuperAGI/blob/contributing-md/CONTRIBUTING.md#getting-started)
1. [Reporting Bugs](https://github.com/Phoenix2809/SuperAGI/blob/contributing-md/CONTRIBUTING.md#reporting-bugs)
2. [Suggesting Enhancements](https://github.com/Phoenix2809/SuperAGI/blob/contributing-md/CONTRIBUTING.md#suggesting-enhancements)
3. [Pull Requests](https://github.com/Phoenix2809/SuperAGI/blob/contributing-md/CONTRIBUTING.md#pull-requests)
4. Styleguides
5. Testing

## Code of Conduct:

Please read our [Code of Conduct](https://github.com/TransformerOptimus/SuperAGI/blob/main/CODE_OF_CONDUCT.md) to understand the expectations we have for all contributors participating in this project. By participating, you agree to abide by our Code of Conduct.

## Getting Started

1. Create a fork of this repository and clone your fork
2. Create a new branch for your changes (make sure you’re using a descriptive name, such as bug-fix-293
3. Make the respective changes in your new branch
4. Test your changes thoroughly
5. Commit and push your changes to your fork
6. Create a pull request. Please refer to the Submitting Pull Requests section for guidelines.

## How can I contribute

### Reporting Bugs

You can start contributing to SuperAGI by reporting bugs that you’ve encountered. Please create an issue on GitHub with the following information:

1. Title describing the issue in a clear and concise manner
2. Provide a detailed description of the problem, along with the necessary steps to reproduce the issue.
3. Make sure to include any relevant logs, screenshots, or other helpful information that supports the issue.

### Suggesting Enhancements

You can start adding ideas for new features or improvements to SuperAGI. Create an issue on Github with the following information:

1. Title describing the issue in a clear and concise manner
2. Please provide a clear description of the proposed enhancement, highlighting its benefits and potential drawbacks.
3. Provide example and supporting information.

### Pull Requests

When submitting your pull request, please ensure that your changes meet the following criteria:

1. The pull request is atomic and focuses on a single change.
2. You have read the contributing guide and your code conforms to the guidelines.
3. You have documented your changes clearly and comprehensively.
4. You have added the required tests.


## Styleguides

will need extensive Developer KT on this

## Code Formatting
Pre-commit Hooks

## Testing Changes

Will need Dev KT on filling this documentation
7 changes: 4 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ services:
- NEXT_PUBLIC_API_BASE_URL=/api
networks:
- super_network
volumes:
- ./gui:/app
- /app/.next
# volumes:
# - ./gui:/app
# - /app/node_modules/
# - /app/.next/
super__redis:
image: "docker.io/library/redis:latest"
networks:
Expand Down
3 changes: 3 additions & 0 deletions gui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ WORKDIR /app
COPY package*.json ./
RUN npm ci

FROM node:lts AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules

CMD ["npm", "run", "dev"]
13 changes: 6 additions & 7 deletions local-llm-gpu
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ services:

super__tgwui:
build:
context: .
context: ./tgwui/
target: llama-cublas
dockerfile: ./tgwui/DockerfileTGWUI
dockerfile: DockerfileTGWUI
# args:
# - LCL_SRC_DIR=text-generation-webui # Developers - see Dockerfile app_base
image: atinoda/text-generation-webui:llama-cublas # Specify variant as the :tag
container_name: super__tgwui
environment:
- EXTRA_LAUNCH_ARGS="--listen --no-mmap --verbose --extensions openai --auto-devices --n_ctx 1600 --gpu-memory 20 20 --n-gpu-layers 128 --threads 8 --model vicuna-13b-cot.ggmlv3.q8_0.bin"
- EXTRA_LAUNCH_ARGS="--no-mmap --verbose --extensions openai --auto-devices --n_ctx 2000 --gpu-memory 22 22 --n-gpu-layers 128 --threads 8"
# - BUILD_EXTENSIONS_LIVE="silero_tts whisper_stt" # Install named extensions during every container launch. THIS WILL SIGNIFICANLTLY SLOW LAUNCH TIME.
ports:
- 7860:7860 # Default web port
- 5000:5000 # Default API port
Expand All @@ -62,15 +64,14 @@ services:
- ./tgwui/config/prompts:/app/prompts
- ./tgwui/config/softprompts:/app/softprompts
- ./tgwui/config/training:/app/training
- ./tgwui/config/embeddings:/app/embeddings
# - ./config/extensions:/app/extensions
logging:
driver: json-file
options:
max-file: "3" # number of files or file count
max-size: '10m'
networks:
- super_network
### Uncomment the following lines to run the container using the host machine's GPU resources
deploy:
resources:
reservations:
Expand All @@ -79,8 +80,6 @@ services:
# count: "all"
device_ids: ['0', '1'] # must comment the above line if this line is uncommented.
capabilities: [gpu]


super__redis:
image: "docker.io/library/redis:latest"
networks:
Expand Down
21 changes: 10 additions & 11 deletions superagi/controllers/tool_config.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from fastapi import APIRouter, HTTPException, Depends, Path
from fastapi import APIRouter, HTTPException, Depends
from fastapi_jwt_auth import AuthJWT
from fastapi_sqlalchemy import db
from pydantic_sqlalchemy import sqlalchemy_to_pydantic

from superagi.helper.auth import check_auth
from superagi.helper.auth import get_user_organisation
from superagi.models.organisation import Organisation
from superagi.models.tool_config import ToolConfig
from superagi.models.toolkit import Toolkit
from fastapi_jwt_auth import AuthJWT
from superagi.helper.auth import check_auth
from superagi.helper.auth import get_user_organisation
from typing import List

router = APIRouter()


@router.post("/add/{toolkit_name}", status_code=201)
def update_tool_config(toolkit_name: str, configs: list):
def update_tool_config(toolkit_name: str, configs: list, organisation: Organisation = Depends(get_user_organisation)):
"""
Update tool configurations for a specific tool kit.
Expand All @@ -34,7 +34,7 @@ def update_tool_config(toolkit_name: str, configs: list):

try:
# Check if the tool kit exists
toolkit = Toolkit.get_toolkit_from_name(db.session, toolkit_name)
toolkit = Toolkit.get_toolkit_from_name(db.session, toolkit_name,organisation)
if toolkit is None:
raise HTTPException(status_code=404, detail="Tool kit not found")

Expand Down Expand Up @@ -114,12 +114,11 @@ def get_all_tool_configs(toolkit_name: str, organisation: Organisation = Depends
HTTPException (status_code=404): If the specified tool kit is not found.
HTTPException (status_code=403): If the user is not authorized to access the tool kit.
"""
user_toolkits = db.session.query(Toolkit).filter(Toolkit.organisation_id == organisation.id).all()
toolkit = db.session.query(Toolkit).filter_by(name=toolkit_name).first()

toolkit = db.session.query(Toolkit).filter(Toolkit.name == toolkit_name,
Toolkit.organisation_id == organisation.id).first()
if not toolkit:
raise HTTPException(status_code=404, detail='ToolKit not found')
if toolkit.name not in [user_toolkit.name for user_toolkit in user_toolkits]:
raise HTTPException(status_code=403, detail='Unauthorized')

tool_configs = db.session.query(ToolConfig).filter(ToolConfig.toolkit_id == toolkit.id).all()
return tool_configs
Expand Down
9 changes: 6 additions & 3 deletions superagi/jobs/agent_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, session=None, toolkit_id=None):

def get_tool_config(self, key: str):
tool_config = self.session.query(ToolConfig).filter_by(key=key, toolkit_id=self.toolkit_id).first()
if tool_config:
if tool_config and tool_config.value:
return tool_config.value
return super().get_tool_config(key=key)

Expand Down Expand Up @@ -77,8 +77,11 @@ def create_object(tool,session):
"""
file_name = AgentExecutor.validate_filename(filename=tool.file_name)

tools_dir = get_config("TOOLS_DIR").rstrip("/")
module_name = ".".join(tools_dir.split("/") + [tool.folder_name, file_name])
tools_dir = get_config("TOOLS_DIR")
if tools_dir is None:
tools_dir = "superagi/tools"
parsed_tools_dir = tools_dir.rstrip("/")
module_name = ".".join(parsed_tools_dir.split("/") + [tool.folder_name, file_name])

# module_name = f"superagi.tools.{folder_name}.{file_name}"

Expand Down
2 changes: 1 addition & 1 deletion superagi/models/agent_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class AgentConfiguration(DBBaseModel):
"""
Represents a configuration for an agent.
Agent related configurations like goals, instructions, constraints and tools are stored here
Attributes:
id (int): The unique identifier of the agent configuration.
Expand Down
2 changes: 1 addition & 1 deletion superagi/models/agent_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class AgentExecution(DBBaseModel):
"""
Represents an execution of an agent.
Represents single agent run
Attributes:
id (int): The unique identifier of the agent execution.
Expand Down
2 changes: 1 addition & 1 deletion superagi/models/agent_execution_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class AgentExecutionFeed(DBBaseModel):
"""
Represents a feed entry for an agent execution.
Feed of the agent execution.
Attributes:
id (int): The unique identifier of the agent execution feed.
Expand Down
2 changes: 1 addition & 1 deletion superagi/models/agent_execution_permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class AgentExecutionPermission(DBBaseModel):
"""
Represents an Agent Execution Permission record in the database.
Agent Execution Permissions at each step to be approved or rejected by the user.
Attributes:
id (Integer): The primary key of the agent execution permission record.
Expand Down
2 changes: 1 addition & 1 deletion superagi/models/agent_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class AgentTemplate(DBBaseModel):
"""
Represents a preconfigured agent template.
Preconfigured agent templates that can be used to create agents.
Attributes:
id (int): The unique identifier of the agent template.
Expand Down
2 changes: 1 addition & 1 deletion superagi/models/agent_template_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class AgentTemplateConfig(DBBaseModel):
"""
Represents the configuration settings for an agent template.
Agent template related configurations like goals, instructions, constraints and tools are stored here
Attributes:
id (int): The unique identifier of the agent template config.
Expand Down
2 changes: 1 addition & 1 deletion superagi/models/agent_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class AgentWorkflow(DBBaseModel):
"""
Represents an agent workflow.
Agent workflows which runs part of each agent execution step
Attributes:
id (int): The unique identifier of the agent workflow.
Expand Down
2 changes: 1 addition & 1 deletion superagi/models/agent_workflow_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class AgentWorkflowStep(DBBaseModel):
"""
Represents a step in an agent workflow.
Step of an agent workflow
Attributes:
id (int): The unique identifier of the agent workflow step.
Expand Down
2 changes: 1 addition & 1 deletion superagi/models/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Configuration(DBBaseModel):
"""
Model representing a configuration.
General org level configurations are stored here
Attributes:
id (Integer): The primary key of the configuration.
Expand Down
10 changes: 5 additions & 5 deletions superagi/models/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from superagi.models.base_model import DBBaseModel


# marketplace_url = "https://app.superagi.com/api"
marketplace_url = "http://localhost:8001"
marketplace_url = "https://app.superagi.com/api"
# marketplace_url = "http://localhost:8001"


class Toolkit(DBBaseModel):
"""
ToolKit - used to store tool kits
ToolKit - Used to group tools together
Attributes:
id(int) : id of the tool kit
name(str) : name of the tool kit
Expand Down Expand Up @@ -112,8 +112,8 @@ def fetch_marketplace_detail(cls, search_str, toolkit_name):
return None

@staticmethod
def get_toolkit_from_name(session, toolkit_name):
toolkit = session.query(Toolkit).filter_by(name=toolkit_name).first()
def get_toolkit_from_name(session, toolkit_name, organisation):
toolkit = session.query(Toolkit).filter_by(name=toolkit_name, organisation_id=organisation.id).first()
if toolkit:
return toolkit
return None
Expand Down
2 changes: 1 addition & 1 deletion superagi/tools/base_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def create_function_schema(

class BaseToolkitConfiguration:

def get_tool_config(key: str):
def get_tool_config(self, key: str):
# Default implementation of the tool configuration retrieval logic
with open("config.yaml") as file:
config = yaml.safe_load(file)
Expand Down
2 changes: 1 addition & 1 deletion superagi/tools/code/write_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _execute(self, code_description: str) -> str:
code_file_name: The name of the file where the generated codes will be saved.
Returns:
Generated codes files or error message.
Generated code with where the code is being saved or error message.
"""
prompt = PromptReader.read_tools_prompt(__file__, "write_code.txt") + "\nUseful to know:\n" + PromptReader.read_tools_prompt(__file__, "generate_logic.txt")
prompt = prompt.replace("{goals}", AgentPromptBuilder.add_list_items_to_string(self.goals))
Expand Down
2 changes: 1 addition & 1 deletion superagi/tools/email/read_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _execute(self, imap_folder: str = "INBOX", page: int = 0, limit: int = 5) ->
limit : Number of emails to fetch in one cycle. Defaults to 5.
Returns:
email content or error message
email contents or error message.
"""
email_sender = self.get_tool_config('EMAIL_ADDRESS')
email_password = self.get_tool_config('EMAIL_PASSWORD')
Expand Down
2 changes: 1 addition & 1 deletion superagi/tools/email/send_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _execute(self, to: str, subject: str, body: str) -> str:
body : The body of the email.
Returns:
success or error message.
"""
email_sender = self.get_tool_config('EMAIL_ADDRESS')
email_password = self.get_tool_config('EMAIL_PASSWORD')
Expand Down
2 changes: 1 addition & 1 deletion superagi/tools/email/send_email_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _execute(self, to: str, subject: str, body: str, filename: str) -> str:
filename : The name of the file to be sent as an attachment with the email.
Returns:
success or failure message
"""
input_root_dir = self.get_tool_config('RESOURCES_INPUT_ROOT_DIR')
output_root_dir = self.get_tool_config('RESOURCES_OUTPUT_ROOT_DIR')
Expand Down
2 changes: 1 addition & 1 deletion superagi/tools/file/append_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _execute(self, file_name: str, content: str):
content : The text to append to the file.
Returns:
file written to successfully. or error message.
success or error message.
"""
final_path = ResourceHelper.get_root_output_dir() + file_name
if "{agent_id}" in final_path:
Expand Down
2 changes: 1 addition & 1 deletion superagi/tools/file/delete_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _execute(self, file_name: str):
file_name : The name of the file to delete.
Returns:
file deleted successfully. or error message.
success or error message.
"""
final_path = ResourceHelper.get_root_output_dir()
if "{agent_id}" in final_path:
Expand Down
2 changes: 1 addition & 1 deletion superagi/tools/file/read_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _execute(self, file_name: str):
file_name : The name of the file to read.
Returns:
The file content
The file content and the file name
"""
output_root_dir = ResourceHelper.get_root_output_dir()

Expand Down
Loading

0 comments on commit d181921

Please sign in to comment.