Skip to content

Commit

Permalink
Merge pull request TransformerOptimus#600 from TransformerOptimus/main
Browse files Browse the repository at this point in the history
Main -> Dev merge
  • Loading branch information
I’m authored Jun 30, 2023
2 parents 074d5d1 + c6cff18 commit 875d128
Show file tree
Hide file tree
Showing 41 changed files with 127 additions and 110 deletions.
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 @@ -44,7 +44,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
"""
final_path = ResourceHelper.get_agent_resource_path(filename, self.agent_id)

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
2 changes: 1 addition & 1 deletion superagi/tools/file/write_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ def _execute(self, file_name: str, content: str):
content : The text to write to the file.
Returns:
file written to successfully. or error message.
success message if message is file written successfully or failure message if writing file fails.
"""
return self.resource_manager.write_file(file_name, content)
2 changes: 1 addition & 1 deletion superagi/tools/github/add_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _execute(self, repository_name: str, base_branch: str, body: str, commit_mes
folder_path : The path of the folder to add the file to.
Returns:
Pull request to add file/folder has been created. or error message.
Pull request success message if pull request is created successfully else error message.
"""
try:
github_access_token = self.get_tool_config("GITHUB_ACCESS_TOKEN")
Expand Down
2 changes: 1 addition & 1 deletion superagi/tools/github/delete_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _execute(self, repository_name: str, base_branch: str, file_name: str, commi
folder_path : The path of the folder to delete the file from.
Returns:
pull request deletion message. or error message
success message mentioning the pull request name for the delete file operation. or error message.
"""

try:
Expand Down
2 changes: 1 addition & 1 deletion superagi/tools/github/search_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _execute(self, repository_owner: str, repository_name: str, file_name: str,
folder_path : The path of the folder to search the file in.
Returns:
The content of the file.
The content of the github file.
"""
github_access_token = self.get_tool_config("GITHUB_ACCESS_TOKEN")
github_username = self.get_tool_config("GITHUB_USERNAME")
Expand Down
2 changes: 1 addition & 1 deletion superagi/tools/google_search/google_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _execute(self, query: str) -> tuple:
query : The query to search for.
Returns:
A tuple of (snippets, webpages, links)
Search result summary along with related links
"""
api_key = self.get_tool_config("GOOGLE_API_KEY")
search_engine_id = self.get_tool_config("SEARCH_ENGINE_ID")
Expand Down
2 changes: 1 addition & 1 deletion superagi/tools/google_serp_search/google_serp_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _execute(self, query: str) -> tuple:
query : The query to search for.
Returns:
A tuple of (snippets, webpages, links)
Search result summary along with related links
"""
api_key = self.get_tool_config("SERP_API_KEY")
serp_api = GoogleSerpApiWrap(api_key)
Expand Down
2 changes: 1 addition & 1 deletion superagi/tools/image_generation/dalle_image_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _execute(self, prompt: str, image_names: list, size: int = 512, num: int = 2
image_names (list): The name of the image to be generated.
Returns:
Image generated successfully. or error message.
Image generated successfully message if image is generated or error message.
"""
if size not in [256, 512, 1024]:
size = min([256, 512, 1024], key=lambda x: abs(x - size))
Expand Down
4 changes: 2 additions & 2 deletions superagi/tools/jira/create_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def _execute(self, fields: dict):
"name": "Low"}}
Returns:
The key of the created issue.
The success message mentioning the key of the created issue.
"""
jira = JiraTool.build_jira_instance()
jira = self.build_jira_instance()
new_issue = jira.create_issue(fields=fields)
return f"Issue '{new_issue.key}' created successfully!"
Loading

0 comments on commit 875d128

Please sign in to comment.