Repository: TransformerOptimus/SuperAGI Branch: main Commit: c3c1982e7bd6 Files: 630 Total size: 1.9 MB Directory structure: gitextract_6lrw3u4j/ ├── .do/ │ ├── app.yaml │ └── deploy.template.yaml ├── .dockerignore ├── .gitattributes ├── .github/ │ ├── ISSUE_TEMPLATE/ │ │ └── 1.BUG_REPORT.yml │ ├── PULL_REQUEST_TEMPLATE.md │ └── workflows/ │ ├── ci.yml │ └── codeql.yml ├── .gitignore ├── .pre-commit-config.yaml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── Dockerfile-gpu ├── DockerfileCelery ├── DockerfileRedis ├── LICENSE ├── README.MD ├── alembic.ini ├── cli2.py ├── config_template.yaml ├── docker-compose-dev.yaml ├── docker-compose-gpu.yml ├── docker-compose.image.example.yaml ├── docker-compose.yaml ├── entrypoint.sh ├── entrypoint_celery.sh ├── gui/ │ ├── .dockerignore │ ├── .eslintrc.json │ ├── Dockerfile │ ├── DockerfileProd │ ├── README.md │ ├── app/ │ │ ├── globals.css │ │ └── layout.js │ ├── jsconfig.json │ ├── next.config.js │ ├── package.json │ ├── pages/ │ │ ├── Content/ │ │ │ ├── APM/ │ │ │ │ ├── Apm.module.css │ │ │ │ ├── ApmDashboard.js │ │ │ │ └── BarGraph.js │ │ │ ├── Agents/ │ │ │ │ ├── ActionConsole.js │ │ │ │ ├── ActivityFeed.js │ │ │ │ ├── AgentCreate.js │ │ │ │ ├── AgentSchedule.js │ │ │ │ ├── AgentTemplatesList.js │ │ │ │ ├── AgentWorkspace.js │ │ │ │ ├── Agents.js │ │ │ │ ├── Agents.module.css │ │ │ │ ├── Details.js │ │ │ │ ├── ResourceList.js │ │ │ │ ├── ResourceManager.js │ │ │ │ ├── RunHistory.js │ │ │ │ ├── TaskQueue.js │ │ │ │ └── react-datetime.css │ │ │ ├── Knowledge/ │ │ │ │ ├── AddKnowledge.js │ │ │ │ ├── Knowledge.js │ │ │ │ ├── Knowledge.module.css │ │ │ │ ├── KnowledgeDetails.js │ │ │ │ └── KnowledgeForm.js │ │ │ ├── Marketplace/ │ │ │ │ ├── AgentTemplate.js │ │ │ │ ├── KnowledgeTemplate.js │ │ │ │ ├── Market.js │ │ │ │ ├── Market.module.css │ │ │ │ ├── MarketAgent.js │ │ │ │ ├── MarketKnowledge.js │ │ │ │ ├── MarketTools.js │ │ │ │ ├── MarketplacePublic.js │ │ │ │ └── ToolkitTemplate.js │ │ │ ├── Models/ │ │ │ │ ├── AddModel.js │ │ │ │ ├── AddModelMarketPlace.js │ │ │ │ ├── MarketModels.js │ │ │ │ ├── ModelDetails.js │ │ │ │ ├── ModelForm.js │ │ │ │ ├── ModelInfo.js │ │ │ │ ├── ModelMetrics.js │ │ │ │ ├── ModelTemplate.js │ │ │ │ └── Models.js │ │ │ └── Toolkits/ │ │ │ ├── AddTool.js │ │ │ ├── Metrics.js │ │ │ ├── Tool.module.css │ │ │ ├── ToolkitWorkspace.js │ │ │ └── Toolkits.js │ │ ├── Dashboard/ │ │ │ ├── Content.js │ │ │ ├── Dashboard.module.css │ │ │ ├── Settings/ │ │ │ │ ├── AddDatabase.js │ │ │ │ ├── ApiKeys.js │ │ │ │ ├── Database.js │ │ │ │ ├── DatabaseDetails.js │ │ │ │ ├── Model.js │ │ │ │ ├── Settings.js │ │ │ │ └── Webhooks.js │ │ │ ├── SideBar.js │ │ │ └── TopBar.js │ │ ├── _app.css │ │ ├── _app.js │ │ └── api/ │ │ ├── DashboardService.js │ │ └── apiConfig.js │ └── utils/ │ ├── eventBus.js │ └── utils.js ├── install_tool_dependencies.sh ├── local-llm ├── local-llm-gpu ├── main.py ├── migrations/ │ ├── README │ ├── env.py │ ├── script.py.mako │ └── versions/ │ ├── 1d54db311055_add_permissions.py │ ├── 2cc1179834b0_agent_executions_modified.py │ ├── 2f97c068fab9_resource_modified.py │ ├── 2fbd6472112c_add_feed_group_id_to_execution_and_feed.py │ ├── 3356a2f89a33_added_configurations_table.py │ ├── 35e47f20475b_renamed_tokens_calls.py │ ├── 3867bb00a495_added_first_login_source.py │ ├── 40affbf3022b_add_filter_colume_in_webhooks.py │ ├── 446884dcae58_add_api_key_and_web_hook.py │ ├── 44b0d6f2d1b3_init_models.py │ ├── 467e85d5e1cd_updated_resources_added_exec_id.py │ ├── 516ecc1c723d_adding_marketplace_template_id_to_agent_.py │ ├── 5184645e9f12_add_question_to_agent_execution_.py │ ├── 520aa6776347_create_models_config.py │ ├── 598cfb37292a_adding_agent_templates.py │ ├── 5d5f801f28e7_create_model_table.py │ ├── 661ec8a4c32e_open_ai_error_handling.py │ ├── 71e3980d55f5_knowledge_and_vector_dbs.py │ ├── 7a3e336c0fba_added_tools_related_models.py │ ├── 83424de1347e_added_agent_execution_config.py │ ├── 8962bed0d809_creating_agent_templates.py │ ├── 9270eb5a8475_local_llms.py │ ├── 9419b3340af7_create_agent_workflow.py │ ├── a91808a89623_added_resources.py │ ├── ba60b12ae109_create_agent_scheduler.py │ ├── be1d922bf2ad_create_call_logs_table.py │ ├── c02f3d759bf3_add_summary_to_resource.py │ ├── c4f2f6ba602a_agent_workflow_wait_step.py │ ├── c5c19944c90c_create_oauth_tokens.py │ ├── cac478732572_delete_agent_feature.py │ ├── d8315244ea43_updated_tool_configs.py │ ├── d9b3436197eb_renaming_templates.py │ ├── e39295ec089c_creating_events.py │ └── fe234ea6e9bc_modify_agent_workflow_tables.py ├── nginx/ │ └── default.conf ├── package.json ├── requirements.txt ├── run.bat ├── run.sh ├── run_gui.py ├── run_gui.sh ├── superagi/ │ ├── __init__.py │ ├── agent/ │ │ ├── __init__.py │ │ ├── agent_iteration_step_handler.py │ │ ├── agent_message_builder.py │ │ ├── agent_prompt_builder.py │ │ ├── agent_prompt_template.py │ │ ├── agent_tool_step_handler.py │ │ ├── agent_workflow_step_wait_handler.py │ │ ├── common_types.py │ │ ├── output_handler.py │ │ ├── output_parser.py │ │ ├── prompts/ │ │ │ ├── agent_queue_input.txt │ │ │ ├── agent_recursive_summary.txt │ │ │ ├── agent_summary.txt │ │ │ ├── agent_tool_input.txt │ │ │ ├── agent_tool_output.txt │ │ │ ├── analyse_task.txt │ │ │ ├── create_tasks.txt │ │ │ ├── initialize_tasks.txt │ │ │ ├── prioritize_tasks.txt │ │ │ └── superagi.txt │ │ ├── queue_step_handler.py │ │ ├── task_queue.py │ │ ├── tool_builder.py │ │ ├── tool_executor.py │ │ ├── types/ │ │ │ ├── __init__.py │ │ │ ├── agent_execution_status.py │ │ │ ├── agent_workflow_step_action_types.py │ │ │ └── wait_step_status.py │ │ └── workflow_seed.py │ ├── apm/ │ │ ├── __init__.py │ │ ├── analytics_helper.py │ │ ├── call_log_helper.py │ │ ├── event_handler.py │ │ ├── knowledge_handler.py │ │ └── tools_handler.py │ ├── config/ │ │ ├── __init__.py │ │ └── config.py │ ├── controllers/ │ │ ├── __init__.py │ │ ├── agent.py │ │ ├── agent_execution.py │ │ ├── agent_execution_config.py │ │ ├── agent_execution_feed.py │ │ ├── agent_execution_permission.py │ │ ├── agent_template.py │ │ ├── agent_workflow.py │ │ ├── analytics.py │ │ ├── api/ │ │ │ └── agent.py │ │ ├── api_key.py │ │ ├── budget.py │ │ ├── config.py │ │ ├── google_oauth.py │ │ ├── knowledge_configs.py │ │ ├── knowledges.py │ │ ├── marketplace_stats.py │ │ ├── models_controller.py │ │ ├── organisation.py │ │ ├── project.py │ │ ├── resources.py │ │ ├── tool.py │ │ ├── tool_config.py │ │ ├── toolkit.py │ │ ├── twitter_oauth.py │ │ ├── types/ │ │ │ ├── agent_execution_config.py │ │ │ ├── agent_publish_config.py │ │ │ ├── agent_schedule.py │ │ │ ├── agent_with_config.py │ │ │ ├── agent_with_config_schedule.py │ │ │ └── models_types.py │ │ ├── user.py │ │ ├── vector_db_indices.py │ │ ├── vector_dbs.py │ │ └── webhook.py │ ├── helper/ │ │ ├── agent_schedule_helper.py │ │ ├── auth.py │ │ ├── calendar_date.py │ │ ├── encyption_helper.py │ │ ├── error_handler.py │ │ ├── feed_parser.py │ │ ├── github_helper.py │ │ ├── google_calendar_creds.py │ │ ├── google_search.py │ │ ├── google_serp.py │ │ ├── imap_email.py │ │ ├── json_cleaner.py │ │ ├── llm_loader.py │ │ ├── models_helper.py │ │ ├── prompt_reader.py │ │ ├── read_email.py │ │ ├── resource_helper.py │ │ ├── s3_helper.py │ │ ├── time_helper.py │ │ ├── token_counter.py │ │ ├── tool_helper.py │ │ ├── twitter_helper.py │ │ ├── twitter_tokens.py │ │ ├── validate_csv.py │ │ ├── webhook_manager.py │ │ └── webpage_extractor.py │ ├── image_llms/ │ │ ├── __init__.py │ │ ├── base_image_llm.py │ │ └── openai_dalle.py │ ├── jobs/ │ │ ├── __init__.py │ │ ├── agent_executor.py │ │ └── scheduling_executor.py │ ├── lib/ │ │ └── logger.py │ ├── llms/ │ │ ├── __init__.py │ │ ├── base_llm.py │ │ ├── google_palm.py │ │ ├── grammar/ │ │ │ └── json.gbnf │ │ ├── hugging_face.py │ │ ├── llm_model_factory.py │ │ ├── local_llm.py │ │ ├── openai.py │ │ ├── replicate.py │ │ └── utils/ │ │ ├── __init__.py │ │ └── huggingface_utils/ │ │ ├── __init__.py │ │ ├── public_endpoints.py │ │ └── tasks.py │ ├── models/ │ │ ├── __init__.py │ │ ├── agent.py │ │ ├── agent_config.py │ │ ├── agent_execution.py │ │ ├── agent_execution_config.py │ │ ├── agent_execution_feed.py │ │ ├── agent_execution_permission.py │ │ ├── agent_schedule.py │ │ ├── agent_template.py │ │ ├── agent_template_config.py │ │ ├── api_key.py │ │ ├── base_model.py │ │ ├── budget.py │ │ ├── call_logs.py │ │ ├── configuration.py │ │ ├── db.py │ │ ├── events.py │ │ ├── knowledge_configs.py │ │ ├── knowledges.py │ │ ├── marketplace_stats.py │ │ ├── models.py │ │ ├── models_config.py │ │ ├── oauth_tokens.py │ │ ├── organisation.py │ │ ├── project.py │ │ ├── resource.py │ │ ├── tool.py │ │ ├── tool_config.py │ │ ├── toolkit.py │ │ ├── types/ │ │ │ ├── __init__.py │ │ │ ├── agent_config.py │ │ │ ├── login_request.py │ │ │ └── validate_llm_api_key_request.py │ │ ├── user.py │ │ ├── vector_db_configs.py │ │ ├── vector_db_indices.py │ │ ├── vector_dbs.py │ │ ├── webhook_events.py │ │ ├── webhooks.py │ │ └── workflows/ │ │ ├── __init__.py │ │ ├── agent_workflow.py │ │ ├── agent_workflow_step.py │ │ ├── agent_workflow_step_tool.py │ │ ├── agent_workflow_step_wait.py │ │ ├── iteration_workflow.py │ │ └── iteration_workflow_step.py │ ├── resource_manager/ │ │ ├── __init__.py │ │ ├── file_manager.py │ │ ├── llama_document_summary.py │ │ ├── llama_vector_store_factory.py │ │ ├── resource_manager.py │ │ └── resource_summary.py │ ├── tool_manager.py │ ├── tools/ │ │ ├── __init__.py │ │ ├── apollo/ │ │ │ ├── __init__.py │ │ │ ├── apollo_search.py │ │ │ └── apollo_toolkit.py │ │ ├── base_tool.py │ │ ├── code/ │ │ │ ├── README.MD │ │ │ ├── __init__.py │ │ │ ├── coding_toolkit.py │ │ │ ├── improve_code.py │ │ │ ├── prompts/ │ │ │ │ ├── generate_logic.txt │ │ │ │ ├── improve_code.txt │ │ │ │ ├── write_code.txt │ │ │ │ ├── write_spec.txt │ │ │ │ └── write_test.txt │ │ │ ├── write_code.py │ │ │ ├── write_spec.py │ │ │ └── write_test.py │ │ ├── duck_duck_go/ │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── duck_duck_go_search.py │ │ │ └── duck_duck_go_search_toolkit.py │ │ ├── email/ │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── email_toolkit.py │ │ │ ├── read_email.py │ │ │ ├── send_email.py │ │ │ └── send_email_attachment.py │ │ ├── file/ │ │ │ ├── __init__.py │ │ │ ├── append_file.py │ │ │ ├── delete_file.py │ │ │ ├── file_toolkit.py │ │ │ ├── list_files.py │ │ │ ├── read_file.py │ │ │ └── write_file.py │ │ ├── github/ │ │ │ ├── README.MD │ │ │ ├── __init__.py │ │ │ ├── add_file.py │ │ │ ├── delete_file.py │ │ │ ├── fetch_pull_request.py │ │ │ ├── github_toolkit.py │ │ │ ├── prompts/ │ │ │ │ └── code_review.txt │ │ │ ├── review_pull_request.py │ │ │ └── search_repo.py │ │ ├── google_calendar/ │ │ │ ├── README.md │ │ │ ├── create_calendar_event.py │ │ │ ├── delete_calendar_event.py │ │ │ ├── event_details_calendar.py │ │ │ ├── google_calendar_toolkit.py │ │ │ └── list_calendar_events.py │ │ ├── google_search/ │ │ │ ├── README.MD │ │ │ ├── __init__.py │ │ │ ├── google_search.py │ │ │ └── google_search_toolkit.py │ │ ├── google_serp_search/ │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── google_serp_search.py │ │ │ └── google_serp_search_toolkit.py │ │ ├── image_generation/ │ │ │ ├── README.MD │ │ │ ├── README.STABLE_DIFFUSION.md │ │ │ ├── __init__.py │ │ │ ├── dalle_image_gen.py │ │ │ ├── image_generation_toolkit.py │ │ │ └── stable_diffusion_image_gen.py │ │ ├── instagram_tool/ │ │ │ ├── README.MD │ │ │ ├── __init__.py │ │ │ ├── instagram.py │ │ │ └── instagram_toolkit.py │ │ ├── jira/ │ │ │ ├── README.MD │ │ │ ├── __init__.py │ │ │ ├── create_issue.py │ │ │ ├── edit_issue.py │ │ │ ├── get_projects.py │ │ │ ├── jira_toolkit.py │ │ │ ├── search_issues.py │ │ │ └── tool.py │ │ ├── knowledge_search/ │ │ │ ├── knowledge_search.py │ │ │ └── knowledge_search_toolkit.py │ │ ├── resource/ │ │ │ ├── __init__.py │ │ │ ├── query_resource.py │ │ │ └── resource_toolkit.py │ │ ├── searx/ │ │ │ ├── README.MD │ │ │ ├── __init__.py │ │ │ ├── search_scraper.py │ │ │ ├── searx.py │ │ │ └── searx_toolkit.py │ │ ├── slack/ │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── send_message.py │ │ │ └── slack_toolkit.py │ │ ├── thinking/ │ │ │ ├── __init__.py │ │ │ ├── prompts/ │ │ │ │ └── thinking.txt │ │ │ ├── thinking_toolkit.py │ │ │ └── tools.py │ │ ├── tool_response_query_manager.py │ │ ├── twitter/ │ │ │ ├── README.md │ │ │ ├── send_tweets.py │ │ │ └── twitter_toolkit.py │ │ └── webscaper/ │ │ ├── README.MD │ │ ├── __init__.py │ │ ├── tools.py │ │ └── web_scraper_toolkit.py │ ├── types/ │ │ ├── __init__.py │ │ ├── common.py │ │ ├── key_type.py │ │ ├── model_source_types.py │ │ ├── queue_status.py │ │ ├── storage_types.py │ │ └── vector_store_types.py │ ├── vector_embeddings/ │ │ ├── __init__.py │ │ ├── base.py │ │ ├── pinecone.py │ │ ├── qdrant.py │ │ ├── vector_embedding_factory.py │ │ └── weaviate.py │ ├── vector_store/ │ │ ├── __init__.py │ │ ├── base.py │ │ ├── chromadb.py │ │ ├── document.py │ │ ├── embedding/ │ │ │ ├── __init__.py │ │ │ ├── base.py │ │ │ ├── openai.py │ │ │ └── palm.py │ │ ├── pinecone.py │ │ ├── qdrant.py │ │ ├── redis.py │ │ ├── vector_factory.py │ │ └── weaviate.py │ └── worker.py ├── test.py ├── test_main.http ├── tests/ │ ├── __init__.py │ ├── integration_tests/ │ │ ├── __init__.py │ │ ├── vector_embeddings/ │ │ │ ├── __init__.py │ │ │ ├── test_pinecone.py │ │ │ ├── test_qdrant.py │ │ │ └── test_weaviate.py │ │ └── vector_store/ │ │ ├── __init__.py │ │ ├── test_qdrant.py │ │ └── test_weaviate.py │ ├── tools/ │ │ └── google_calendar/ │ │ ├── create_event_test.py │ │ ├── delete_event_test.py │ │ ├── event_details_test.py │ │ └── list_events_test.py │ └── unit_tests/ │ ├── __init__.py │ ├── agent/ │ │ ├── __init__.py │ │ ├── test_agent_iteration_step_handler.py │ │ ├── test_agent_message_builder.py │ │ ├── test_agent_prompt_builder.py │ │ ├── test_agent_prompt_template.py │ │ ├── test_agent_tool_step_handler.py │ │ ├── test_agent_workflow_step_wait_handler.py │ │ ├── test_output_handler.py │ │ ├── test_output_parser.py │ │ ├── test_queue_step_handler.py │ │ ├── test_task_queue.py │ │ ├── test_tool_builder.py │ │ └── test_tool_executor.py │ ├── apm/ │ │ ├── __init__.py │ │ ├── test_analytics_helper.py │ │ ├── test_call_log_helper.py │ │ ├── test_event_handler.py │ │ ├── test_knowledge_handler.py │ │ └── test_tools_handler.py │ ├── controllers/ │ │ ├── __init__.py │ │ ├── api/ │ │ │ ├── __init__.py │ │ │ └── test_agent.py │ │ ├── test_agent.py │ │ ├── test_agent_execution.py │ │ ├── test_agent_execution_config.py │ │ ├── test_agent_execution_feeds.py │ │ ├── test_agent_template.py │ │ ├── test_analytics.py │ │ ├── test_models_controller.py │ │ ├── test_publish_agent.py │ │ ├── test_tool.py │ │ ├── test_tool_config.py │ │ ├── test_toolkit.py │ │ ├── test_update_agent_config_table.py │ │ └── test_user.py │ ├── helper/ │ │ ├── __init__.py │ │ ├── test_agent_schedule_helper.py │ │ ├── test_calendar_date.py │ │ ├── test_error_handling.py │ │ ├── test_feed_parser.py │ │ ├── test_github_helper.py │ │ ├── test_json_cleaner.py │ │ ├── test_resource_helper.py │ │ ├── test_s3_helper.py │ │ ├── test_time_helper.py │ │ ├── test_token_counter.py │ │ ├── test_tool_helper.py │ │ ├── test_twitter_helper.py │ │ ├── test_twitter_tokens.py │ │ └── test_webhooks.py │ ├── jobs/ │ │ ├── __init__.py │ │ ├── conftest.py │ │ ├── test_resource_summary.py │ │ └── test_scheduling_executor.py │ ├── llms/ │ │ ├── __init__.py │ │ ├── test_google_palm.py │ │ ├── test_hugging_face.py │ │ ├── test_model_factory.py │ │ ├── test_open_ai.py │ │ └── test_replicate.py │ ├── models/ │ │ ├── __init__.py │ │ ├── test_agent.py │ │ ├── test_agent_execution.py │ │ ├── test_agent_execution_config.py │ │ ├── test_agent_execution_feed.py │ │ ├── test_agent_schedule.py │ │ ├── test_agent_template.py │ │ ├── test_agent_workflow.py │ │ ├── test_agent_workflow_step.py │ │ ├── test_agent_workflow_step_tool.py │ │ ├── test_api_key.py │ │ ├── test_call_logs.py │ │ ├── test_configuration.py │ │ ├── test_events.py │ │ ├── test_iteration_workflow.py │ │ ├── test_iteration_workflow_step.py │ │ ├── test_knowledge_configs.py │ │ ├── test_marketplace_stats.py │ │ ├── test_models.py │ │ ├── test_models_config.py │ │ ├── test_project.py │ │ ├── test_tool.py │ │ ├── test_tool_config.py │ │ ├── test_toolkit.py │ │ ├── test_vector_db_configs.py │ │ ├── test_vector_db_indices.py │ │ └── test_vector_dbs.py │ ├── resource_manager/ │ │ ├── __init__.py │ │ ├── test_file_manager.py │ │ ├── test_llama_document_creation.py │ │ ├── test_llama_vector_store_factory.py │ │ └── test_save_document_to_vector_store.py │ ├── test_migrations_multiheads.py │ ├── test_tool_manager.py │ ├── tools/ │ │ ├── __init__.py │ │ ├── code/ │ │ │ ├── __init__.py │ │ │ ├── test_improve_code.py │ │ │ ├── test_write_code.py │ │ │ ├── test_write_spec.py │ │ │ └── test_write_test.py │ │ ├── duck_duck_go/ │ │ │ ├── __init__.py │ │ │ ├── test_duckduckgo_results.py │ │ │ └── test_duckduckgo_toolkit.py │ │ ├── email/ │ │ │ ├── __init__.py │ │ │ ├── test_read_email.py │ │ │ ├── test_send_email.py │ │ │ └── test_send_email_attachment.py │ │ ├── file/ │ │ │ ├── __init__.py │ │ │ ├── test_list_files.py │ │ │ └── test_read_file.py │ │ ├── github/ │ │ │ ├── __init__.py │ │ │ ├── test_add_file.py │ │ │ ├── test_fetch_pull_request.py │ │ │ ├── test_github_delete.py │ │ │ └── test_review_pull_request.py │ │ ├── image_generation/ │ │ │ ├── __init__.py │ │ │ ├── test_dalle_image_gen.py │ │ │ └── test_stable_diffusion_image_gen.py │ │ ├── instagram_tool/ │ │ │ ├── __init__.py │ │ │ ├── test_instagram_tool.py │ │ │ └── test_instagram_toolkit.py │ │ ├── jira/ │ │ │ ├── __init__.py │ │ │ ├── test_create_issue.py │ │ │ ├── test_edit_issue.py │ │ │ ├── test_get_projects.py │ │ │ └── test_search_issues.py │ │ ├── knowledge_tool/ │ │ │ ├── __init__.py │ │ │ └── test_knowledge_search.py │ │ ├── searx/ │ │ │ ├── __init__.py │ │ │ └── test_searx_toolkit.py │ │ ├── test_search_repo.py │ │ └── twitter/ │ │ └── test_send_tweets.py │ ├── types/ │ │ ├── __init__.py │ │ └── test_model_source_types.py │ ├── vector_embeddings/ │ │ ├── __init__.py │ │ └── test_vector_embedding_factory.py │ └── vector_store/ │ ├── __init__.py │ ├── test_chromadb.py │ ├── test_redis.py │ └── test_vector_factory.py ├── tgwui/ │ ├── DockerfileTGWUI │ ├── config/ │ │ ├── loras/ │ │ │ └── place-your-loras-here.txt │ │ ├── presets/ │ │ │ ├── Debug-deterministic.yaml │ │ │ ├── Kobold-Godlike.yaml │ │ │ ├── Kobold-Liminal Drift.yaml │ │ │ ├── LLaMA-Precise.yaml │ │ │ ├── Naive.yaml │ │ │ ├── NovelAI-Best Guess.yaml │ │ │ ├── NovelAI-Decadence.yaml │ │ │ ├── NovelAI-Genesis.yaml │ │ │ ├── NovelAI-Lycaenidae.yaml │ │ │ ├── NovelAI-Ouroboros.yaml │ │ │ ├── NovelAI-Pleasing Results.yaml │ │ │ ├── NovelAI-Sphinx Moth.yaml │ │ │ ├── NovelAI-Storywriter.yaml │ │ │ ├── Special-Contrastive Search.yaml │ │ │ └── Special-Eta Sampling.yaml │ │ ├── prompts/ │ │ │ ├── Alpaca-with-Input.txt │ │ │ ├── GPT-4chan.txt │ │ │ └── QA.txt │ │ └── training/ │ │ ├── datasets/ │ │ │ └── put-trainer-datasets-here.txt │ │ └── formats/ │ │ ├── alpaca-chatbot-format.json │ │ └── alpaca-format.json │ └── scripts/ │ ├── build_extensions.sh │ └── docker-entrypoint.sh ├── ui.py └── wait-for-it.sh ================================================ FILE CONTENTS ================================================ ================================================ FILE: .do/app.yaml ================================================ alerts: - rule: DEPLOYMENT_FAILED - rule: DOMAIN_FAILED databases: - engine: PG name: super-agi-main num_nodes: 1 size: basic-xs version: "12" ingress: rules: - component: name: superagi-backend match: path: prefix: /api name: superagi services: - dockerfile_path: DockerfileRedis github: branch: main deploy_on_push: true repo: TransformerOptimus/SuperAGI internal_ports: - 6379 instance_count: 1 instance_size_slug: basic-xs source_dir: / name: superagi-redis - dockerfile_path: Dockerfile envs: - key: REDIS_URL scope: RUN_TIME value: superagi-redis:6379 - key: DB_URL scope: RUN_TIME value: ${super-agi-main.DATABASE_URL} github: branch: main deploy_on_push: true repo: TransformerOptimus/SuperAGI http_port: 8001 instance_count: 1 instance_size_slug: basic-xs run_command: /app/entrypoint.sh source_dir: / name: superagi-backend - dockerfile_path: ./gui/DockerfileProd github: branch: main deploy_on_push: true repo: TransformerOptimus/SuperAGI http_port: 3000 instance_count: 1 instance_size_slug: basic-xs source_dir: ./gui name: superagi-gui workers: - dockerfile_path: Dockerfile envs: - key: REDIS_URL scope: RUN_TIME value: superagi-redis:6379 - key: DB_URL scope: RUN_TIME value: ${super-agi-main.DATABASE_URL} github: branch: main deploy_on_push: true repo: TransformerOptimus/SuperAGI instance_count: 1 instance_size_slug: basic-xs run_command: celery -A superagi.worker worker --beat --loglevel=info source_dir: / name: superagi-celery ================================================ FILE: .do/deploy.template.yaml ================================================ spec: alerts: - rule: DEPLOYMENT_FAILED - rule: DOMAIN_FAILED databases: - engine: PG name: super-agi-main num_nodes: 1 size: basic-xs version: "12" ingress: rules: - component: name: superagi-backend match: path: prefix: /api name: superagi services: - dockerfile_path: DockerfileRedis git: branch: main repo_clone_url: https://github.com/TransformerOptimus/SuperAGI.git internal_ports: - 6379 instance_count: 1 instance_size_slug: basic-xs source_dir: / name: superagi-redis - dockerfile_path: Dockerfile envs: - key: REDIS_URL scope: RUN_TIME value: superagi-redis:6379 - key: DB_URL scope: RUN_TIME value: ${super-agi-main.DATABASE_URL} git: branch: main repo_clone_url: https://github.com/TransformerOptimus/SuperAGI.git http_port: 8001 instance_count: 1 instance_size_slug: basic-xs run_command: /app/entrypoint.sh source_dir: / name: superagi-backend - dockerfile_path: ./gui/DockerfileProd git: branch: main repo_clone_url: https://github.com/TransformerOptimus/SuperAGI.git http_port: 3000 instance_count: 1 instance_size_slug: basic-xs source_dir: ./gui name: superagi-gui workers: - dockerfile_path: Dockerfile envs: - key: REDIS_URL scope: RUN_TIME value: superagi-redis:6379 - key: DB_URL scope: RUN_TIME value: ${super-agi-main.DATABASE_URL} git: branch: main repo_clone_url: https://github.com/TransformerOptimus/SuperAGI.git instance_count: 1 instance_size_slug: basic-xs run_command: celery -A superagi.worker worker --beat --loglevel=info source_dir: / name: superagi-celery ================================================ FILE: .dockerignore ================================================ # Ignore everything ** # Allow files and directories !/migrations !/nginx !/superagi !/tgwui !/tools !/workspace !/main.py !/requirements.txt !/entrypoint.sh !/entrypoint_celery.sh !/wait-for-it.sh !/tools.json !/install_tool_dependencies.sh !/alembic.ini ================================================ FILE: .gitattributes ================================================ *.sh text eol=lf ================================================ FILE: .github/ISSUE_TEMPLATE/1.BUG_REPORT.yml ================================================ name: Bug report description: Create a bug report for SuperAGI. labels: ['status: needs triage'] body: - type: markdown attributes: value: | ### ⚠️ Issue Creation Guideline * Check out our [roadmap] and join our [discord] to discuss what's going on * If you need help, you can ask in the [#general] section or in [#support] * **Thoroughly search the [existing issues] before creating a new one** * Read through our docs: [roadmap]: https://github.com/users/TransformerOptimus/projects/5 [discord]: https://discord.gg/dXbRe5BHJC [#general]: https://discord.com/channels/1107593006032355359/1107642413993959505 [#support]: https://discord.com/channels/1107593006032355359/1107645922797703198 [existing issues]: https://github.com/TransformerOptimus/SuperAGI/issues - type: checkboxes attributes: label: ⚠️ Check for existing issues before proceeding. ⚠️ description: > Please [search the history](https://github.com/TransformerOptimus/SuperAGI/issues) to see if an issue already exists for the same problem. options: - label: I have searched the existing issues, and there is no existing issue for my problem required: true - type: markdown attributes: value: | Please confirm that the issue you have is described well and precise in the title above ⬆️. Think like this: What would you type if you were searching for the issue? For example: ❌ - my SuperAGI agent keeps looping ✅ - After performing Write Tool, SuperAGI goes into a loop where it keeps trying to write the file. Please help us help you by following these steps: - Search for existing issues, adding a comment when you have the same or similar issue is tidier than "new issue" and newer issues will not be reviewed earlier, this is dependent on the current priorities set by our wonderful team - Ask on our Discord if your issue is known when you are unsure (https://discord.gg/dXbRe5BHJC) - Provide relevant info: - Provide Docker Logs(docker compose logs) whenever possible. - If it's a pip/packages issue, mention this in the title and provide pip version, python version. - type: dropdown attributes: label: Where are you using SuperAGI? description: > Please select the operating system you were using to run SuperAGI when this problem occurred. options: - Windows - Linux - MacOS - Codespaces - Web Version - Other validations: required: true nested_fields: - type: text attributes: label: Specify the system description: Please specify the system you are working on. - type: dropdown attributes: label: Which branch of SuperAGI are you using? description: | Please select which version of SuperAGI you were using when this issue occurred. If installed with git you can run `git branch` to see which version of Auto-GPT you are running. options: - Main - Dev (branch) validations: required: true - type: dropdown attributes: label: Do you use OpenAI GPT-3.5 or GPT-4? description: > If you are using SuperAGI with GPT-3.5, your problems may be caused by the limitations of GPT-3.5 like incorrect Tool selection thus causing looping in the agent feed. options: - GPT-3.5 - GPT-3.5(16k) - GPT-4 - GPT-4(32k) validations: required: true - type: dropdown attributes: label: Which area covers your issue best? description: > Select the area related to the issue you are reporting. options: - Installation and setup - Resource Manager - Action Console - Performance - Marketplace - Prompt - Tools - Agents - Documentation - Logging - Other validations: required: true autolabels: true nested_fields: - type: text attributes: label: Specify the area description: Please specify the area you think is best related to the issue. - type: textarea attributes: label: Describe your issue. description: Describe the problem you are experiencing. Try to describe only the issue and phrase it short but clear. ⚠️ Provide NO other data in this field validations: required: true - type: textarea attributes: label: How to replicate your Issue? description: | Mention Agent Name, Agent Description and Agent Goals, along with Model selected. Provide any other data which might be relevant for us to replicate this issue. ⚠️ Provide NO other data in this field validations: required: false - type: markdown attributes: value: | ⚠️ Please keep in mind that the log files may contain personal information such as credentials. Make sure you hide them before copy/pasting it! ⚠️ - type: input attributes: label: Upload Error Log Content description: | Upload the error log content, this can help us understand the issue better. To do this, you can simply copy the logs from the terminal with which you did 'docker compose up' or in a new terminal, enter 'docker compose logs' and copy/paste the error contents to this field. ⚠️ The activity log may contain personal data given to SuperAGI by you in prompt or input as well as any personal information that SuperAGI collected out of files during last run. Please hide them before sharing. ⚠️ validations: required: True ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ ### Description ### Related Issues ### Solution and Design ### Test Plan ### Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Docs update ### Checklist - [ ] My pull request is atomic and focuses on a single change. - [ ] I have read the contributing guide and my code conforms to the guidelines. - [ ] I have documented my changes clearly and comprehensively. - [ ] I have added the required tests. ================================================ FILE: .github/workflows/ci.yml ================================================ # This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python name: Python CI on: push: branches: [ "main", "dev" ] pull_request: branches: [ "main", "dev" ] permissions: contents: read jobs: lint: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} - name: Set up Python 3.9 uses: actions/setup-python@v3 with: python-version: "3.9" - name: Cache Python dependencies uses: actions/cache@v2 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- - name: Install dependencies run: | python -m pip install --upgrade pip pip install flake8 pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics test: permissions: # Gives the action the necessary permissions for publishing new # comments in pull requests. pull-requests: write # Gives the action the necessary permissions for pushing data to the # python-coverage-comment-action branch, and for editing existing # comments (to avoid publishing multiple comments in the same PR) contents: write runs-on: ubuntu-latest timeout-minutes: 30 strategy: matrix: python-version: ["3.9"] steps: - name: Checkout repository uses: actions/checkout@v3 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} submodules: true - name: Configure git user SuperAGI-Bot run: | git config --global user.name "SuperAGI-Bot" git config --global user.email "github-bot@superagi.com" - name: Set up Python 3.9 uses: actions/setup-python@v3 with: python-version: "3.9" - name: Cache dependencies uses: actions/cache@v2 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- - name: Install dependencies run: | python -m pip install --upgrade pip pip install flake8 pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Test with pytest run: | pytest --cov=superagi --cov-branch --cov-report term-missing --cov-report xml \ tests/unit_tests -s env: CI: true ENV: DEV PLAIN_OUTPUT: True REDIS_URL: "localhost:6379" IS_TESTING: True ENCRYPTION_KEY: "abcdefghijklmnopqrstuvwxyz123456" - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 ================================================ FILE: .github/workflows/codeql.yml ================================================ name: "CodeQL" on: push: branches: [ 'main', 'dev' ] pull_request: # The branches below must be a subset of the branches above branches: [ 'main' ] schedule: - cron: '48 0 * * 2' jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read security-events: write strategy: fail-fast: false matrix: language: [ 'javascript', 'python' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Use only 'java' to analyze code written in Java, Kotlin or both # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - name: Checkout repository uses: actions/checkout@v3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs # queries: security-extended,security-and-quality # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v2 # ℹ️ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun # If the Autobuild fails above, remove it and uncomment the following three lines. # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. # - run: | # echo "Run, Build Application using script" # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 with: category: "/language:${{matrix.language}}" ================================================ FILE: .gitignore ================================================ .idea **/.env **/.venv config.yaml __pycache__ superagi/models/__pycache__ superagi/controllers/__pycache__ **agent_dictvenv **/__gitpycache__/ gui/node_modules node_modules gui/.next .DS_Store .DS_Store? venv workspace/output workspace/input celerybeat-schedule ../bfg-report* superagi/tools/marketplace_tools/ superagi/tools/external_tools/ tests/unit_tests/resource_manager/test_path /tools.json ================================================ FILE: .pre-commit-config.yaml ================================================ repos: - repo: local hooks: - id: pylint name: pylint entry: pylint language: system types: [python] ================================================ FILE: CODE_OF_CONDUCT.md ================================================ # Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at . All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. ================================================ FILE: CONTRIBUTING.md ================================================ # ⚡ Contributing to SuperAGI

SuperAGI logo SuperAGI logo

First of all, thank you for taking the time 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. For all contributions, a CLA (Contributor License Agreement) needs to be signed [here](https://cla-assistant.io/TransformerOptimus/SuperAGI) before (or after) the pull request has been submitted. **********************************Table of Content:********************************** 1. [Code of conduct](https://github.com/TransformerOptimus/SuperAGI/blob/CONTRIBUTING.md#code-of-conduct) 2. [Quick Start](https://github.com/TransformerOptimus/SuperAGI/blob/CONTRIBUTING.md#quick-start) 3. [Contributing Guidelines](https://github.com/TransformerOptimus/SuperAGI/blob/CONTRIBUTING.md#contributing-guidelines) 1. [Reporting Bugs](https://github.com/TransformerOptimus/SuperAGI/blob/CONTRIBUTING.md#reporting-bugs) 2. [New Feature or Suggesting Enhancements](https://github.com/TransformerOptimus/SuperAGI/blob/CONTRIBUTING.md#new-feature-or-suggesting-enhancements) 4. [Testing](https://github.com/TransformerOptimus/SuperAGI/blob/CONTRIBUTING.md#testing-changes) 5. [Pull Requests](https://github.com/TransformerOptimus/SuperAGI/blob/CONTRIBUTING.md#pull-requests) ## ✔️ 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. ## 🚀 Quick Start You can quickly get started with contributing by searching for issues with the labels **"Good First Issue"** or **"Help Needed"** in the [Issues Section](https://github.com/TransformerOptimus/SuperAGI/Issues). If you think you can contribute, comment on the issue and we will assign it to you. To set up your development environment, please follow the steps mentioned below : 1. Fork the repository and create a clone of the fork 2. Create a branch for a feature or a bug you are working on in your fork 3. Once you've created your branch, follow the instructions in the [README.MD](https://github.com/TransformerOptimus/SuperAGI/README.MD) ## Contributing Guidelines ### 🔍 Reporting Bugs You can start working on an existing bug that has been reported and labeled as **"Bug"** in the Issues Section, and you can report your bugs in the following manner : 1. Title describing the issue clearly and concisely with relevant labels 2. Provide a detailed description of the problem and the necessary steps to reproduce the issue. 3. Include any relevant logs, screenshots, or other helpful information supporting the issue. ### :bulb: New Feature or Suggesting Enhancements This section guides you through working on an enhancement **Including a completely New Feature** & **Enhancements to an existing functionality**. Before getting started, Perform a search on Issues to see if the enhancement or feature has already been suggested and picked up. If the feature or enhancement is suggested and not picked up, comment on the issue and assign yourself to it. If the feature or enhancement is not in the issues, find out whether your idea fits with the scope and aims of the project by looking at the [Roadmap](https://github.com/users/TransformerOptimus/projects/5/). If yes, raise an issue with the label **"Feature Request"** in the following manner: 1. Title describing the feature or enhancement in a clear and concise manner 2. Clearly describe the proposed enhancement, highlighting its benefits and potential drawbacks. 3. Provide examples and supporting information. Once you have raised the issue and have gotten yourself assigned, you can start working on the feature or enhancement. Please make sure the feature or enhancement you're working on is placed on the Roadmap. ## Testing your Changes Each method or the function of the code should have a unit test with the maximum coverage possible and on each Pull Request, we have GitHub Actions triggered, which runs all the unit tests where all the tests should pass for merging the Pull Request. ## Pull Request Now that you have worked on your code and tested it thoroughly, you can now go ahead and raise the pull request. Please make sure that the Pull Request adheres to the following guidelines: 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. ================================================ FILE: Dockerfile ================================================ # Stage 1: Compile image FROM python:3.10-slim-bullseye AS compile-image WORKDIR /app RUN apt-get update && \ apt-get install --no-install-recommends -y wget libpq-dev gcc g++ && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* RUN python -m venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" COPY requirements.txt . RUN pip install --upgrade pip && \ pip install --no-cache-dir -r requirements.txt RUN python3.10 -c "import nltk; nltk.download('punkt')" && \ python3.10 -c "import nltk; nltk.download('averaged_perceptron_tagger')" COPY . . RUN chmod +x ./entrypoint.sh ./wait-for-it.sh ./install_tool_dependencies.sh ./entrypoint_celery.sh # Stage 2: Build image FROM python:3.10-slim-bullseye AS build-image WORKDIR /app RUN apt-get update && \ apt-get install --no-install-recommends -y libpq-dev && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* COPY --from=compile-image /opt/venv /opt/venv COPY --from=compile-image /app /app COPY --from=compile-image /root/nltk_data /root/nltk_data ENV PATH="/opt/venv/bin:$PATH" EXPOSE 8001 ================================================ FILE: Dockerfile-gpu ================================================ # Define the CUDA SDK version you need ARG CUDA_IMAGE="12.1.1-devel-ubuntu22.04" FROM nvidia/cuda:${CUDA_IMAGE} ENV DEBIAN_FRONTEND=noninteractive WORKDIR /app RUN apt-get update && apt-get upgrade -y \ && apt-get install -y git build-essential \ python3 python3-pip python3.10-venv libpq-dev gcc wget \ ocl-icd-opencl-dev opencl-headers clinfo \ libclblast-dev libopenblas-dev \ && mkdir -p /etc/OpenCL/vendors && echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd # Create a virtual environment and activate it RUN python3 -m venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" # Install Python dependencies from requirements.txt COPY requirements.txt . RUN pip install --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Running nltk setup as you mentioned RUN python3.10 -c "import nltk; nltk.download('punkt')" && \ python3.10 -c "import nltk; nltk.download('averaged_perceptron_tagger')" # Copy the application code COPY . . ENV CUDA_DOCKER_ARCH=all ENV LLAMA_CUBLAS=1 RUN CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python==0.2.7 --force-reinstall --upgrade --no-cache-dir # Make necessary scripts executable RUN chmod +x ./entrypoint.sh ./wait-for-it.sh ./install_tool_dependencies.sh ./entrypoint_celery.sh # Set environment variable to point to the custom libllama.so # ENV LLAMA_CPP_LIB=/app/llama.cpp/libllama.so EXPOSE 8001 CMD ["./entrypoint.sh"] ================================================ FILE: DockerfileCelery ================================================ FROM python:3.9 WORKDIR /app #RUN apt-get update && apt-get install --no-install-recommends -y git wget libpq-dev gcc python3-dev && pip install psycopg2 RUN pip install --upgrade pip COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . # Downloads the tools RUN python superagi/tool_manager.py # Set executable permissions for install_tool_dependencies.sh RUN chmod +x install_tool_dependencies.sh # Install dependencies RUN ./install_tool_dependencies.sh # Downloads the tools RUN python superagi/tool_manager.py # Set executable permissions for install_tool_dependencies.sh RUN chmod +x install_tool_dependencies.sh # Install dependencies RUN ./install_tool_dependencies.sh CMD ["celery", "-A", "superagi.worker", "worker", "--beat","--loglevel=info"] ================================================ FILE: DockerfileRedis ================================================ FROM redis/redis-stack-server:latest ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2023 TransformerOptimus Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.MD ================================================

SuperAGI logo SuperAGI logo

Open-source framework to build, manage and run useful Autonomous AI Agents

SuperAGI forks SuperAGI stars SuperAGI Commits

Follow SuperAGI

Follow _superAGI Join SuperAGI Discord Community

Connect with the Creator

Follow ishaanbhola

Share SuperAGI Repository

Follow _superAGI Share on Telegram Share on Reddit Buy Me A Coffee


## What are we ? A dev-first open source autonomous AI agent framework enabling developers to build, manage & run useful autonomous agents. You can run concurrent agents seamlessly, extend agent capabilities with tools. The agents efficiently perform a variety of tasks and continually improve their performance with each subsequent run. ### 💡 Features - Provision, Spawn & Deploy Autonomous AI Agents - Create production-ready & scalable autonomous agents. - Extend Agent Capabilities with Toolkits - Add Toolkits from our marketplace to your agent workflows. - Graphical User Interface - Access your agents through a graphical user interface. - Action Console - Interact with agents by giving them input and permissions. - Multiple Vector DBs - Connect to multiple Vector DBs to enhance your agent’s performance. - Performance Telemetry - Get insights into your agent’s performance and optimize accordingly. - Optimized Token Usage - Control token usage to manage costs effectively. - Agent Memory Storage - Enable your agents to learn and adapt by storing their memory. - Models - Custom fine tuned models for business specific usecases. - Workflows - Automate tasks with ease using ReAct LLM's predefined steps. ### 🛠 Toolkits Toolkits allow SuperAGI Agents to interact with external systems and third-party plugins. Twitter Coding Tool Instagram Knowledge Search Email Jira File Manager Google Search Dall-E Github Web Interaction Duckduckgo Google Calendar Google Calendar Serp API Searx Web Scraper Notion Apollo ### ⚙️ Installation You can install superAGI using one of the following three approaches. #### ☁️ SuperAGI cloud To quickly start experimenting with agents without the hassle of setting up the system, try [Superagi Cloud](https://app.superagi.com/) 1. Visit [Superagi Cloud](https://app.superagi.com/) and log in using your github account. 2. In your account settings, go to "Model Providers" and add your API key. You're all set! Start running your agents effortlessly. #### 🖥️ Local 1. Open your terminal and clone the SuperAGI repository. ``` git clone https://github.com/TransformerOptimus/SuperAGI.git ``` 2. Navigate to the cloned repository directory using the command: ``` cd SuperAGI ``` 3. Create a copy of config_template.yaml, and name it config.yaml. 4. Ensure that Docker is installed on your system. You can download and install it from [here](https://docs.docker.com/get-docker/). 5. Once you have Docker Desktop running, run the following command in the SuperAGI directory: a. For regular usage: ``` docker compose -f docker-compose.yaml up --build ``` b. If you want to use SuperAGI with Local LLMs and have GPU, run the following command: ``` docker compose -f docker-compose-gpu.yml up --build ``` 6. Open your web browser and navigate to http://localhost:3000 to access SuperAGI. #### 🌀 Digital Ocean


Deploy SuperAGI to DigitalOcean with one click.

### 🌐 Architecture
SuperAGI Architecture ![SuperAGI Architecture](https://superagi.com/wp-content/uploads/2023/09/SuperAGI-Architecture.png)
Agent Architecture ![Agent Architecture](https://superagi.com/wp-content/uploads/2023/06/Agent-Architecture.png)
Agent Workflow Architecture ![Agent Workflow Architecture](https://superagi.com/wp-content/uploads/2023/09/Workflow-Architecture.png)
Tools Architecture ![Tools Architecture](https://superagi.com/wp-content/uploads/2023/09/Tools-Architecture.png)
ER Diagram ![ER Diagram](https://superagi.com/wp-content/uploads/2023/09/ER-Diagram.png)
### 📚 Resources * [Documentation](https://superagi.com/docs/) * [YouTube Channel](https://www.youtube.com/@_SuperAGI/videos) ### 📖 Need Help? Join our [Discord community](https://discord.gg/dXbRe5BHJC) for support and discussions. [![Join us on Discord](https://invidget.switchblade.xyz/uJ3XUGsY2R)](https://discord.gg/uJ3XUGsY2R) If you have questions or encounter issues, please don't hesitate to [create a new issue](https://github.com/TransformerOptimus/SuperAGI/issues/new/choose) to get support. ### 💻 Contribution We ❤️ our contributors. We’re committed to fostering an open, welcoming, and safe environment in the community. If you'd like to contribute, start by reading our [Contribution Guide](https://github.com/TransformerOptimus/SuperAGI/blob/main/CONTRIBUTING.md). We expect everyone participating in the community to abide by our [Code of Conduct](https://github.com/TransformerOptimus/SuperAGI/blob/main/CODE_OF_CONDUCT.md). To get more idea on where we are heading, checkout our roadmap [here](https://github.com/users/TransformerOptimus/projects/5/views/1). Explore some [good first issues](https://github.com/TransformerOptimus/SuperAGI/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) to start contributing. ### 👩‍💻 Contributors [![TransformerOptimus](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/133493246?v=4&w=50&h=50&mask=circle)](https://github.com/TransformerOptimus) [![Cptsnowcrasher](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/133322218?v=4&w=50&h=50&mask=circle)](https://github.com/Cptsnowcrasher) [![vectorcrow](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/133646556?v=4&w=50&h=50&mask=circle)](https://github.com/vectorcrow) [![Akki-jain](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/92881074?v=4&w=50&h=50&mask=circle)](https://github.com/Akki-jain) [![Autocop-Agent](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/129729746?v=4&w=50&h=50&mask=circle)](https://github.com/Autocop-Agent)[![COLONAYUSH](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/60507126?v=4&w=50&h=50&mask=circle)](https://github.com/COLONAYUSH)[![luciferlinx101](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/129729795?v=4&w=50&h=50&mask=circle)](https://github.com/luciferlinx101)[![mukundans89](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/101278493?v=4&w=50&h=50&mask=circle)](https://github.com/mukundans89)[![Fluder-Paradyne](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/121793617?v=4&w=50&h=50&mask=circle)](https://github.com/Fluder-Paradyne)[![nborthy](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/101320057?v=4&w=50&h=50&mask=circle)](https://github.com/nborthy)[![nihirr](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/122777244?v=4&w=50&h=50&mask=circle)](https://github.com/nihirr)[![Tarraann](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/97586318?v=4&w=50&h=50&mask=circle)](https://github.com/Tarraann)[![neelayan7](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/43145646?v=4&w=50&h=50&mask=circle)](https://github.com/neelayan7)[![Arkajit-Datta](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/61142632?v=4&w=50&h=50&mask=circle)](https://github.com/Arkajit-Datta)[![guangchen811](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/103159823?v=4&w=50&h=50&mask=circle)](https://github.com/guangchen811)[![juanfpo96](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/14787156?v=4&w=50&h=50&mask=circle)](https://github.com/juanfpo96)[![iskandarreza](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/32027019?v=4&w=50&h=50&mask=circle)](https://github.com/iskandarreza)[![jpenalbae](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/8380459?v=4&w=50&h=50&mask=circle)](https://github.com/jpenalbae)[![pallasite99](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/26508636?v=4&w=50&h=50&mask=circle)](https://github.com/pallasite99)[![xutpuu](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/11964505?v=4&w=50&h=50&mask=circle)](https://github.com/xutpuu)[![alexkreidler](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/11166947?v=4&w=50&h=50&mask=circle)](https://github.com/alexkreidler)[![hanhyalex123](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/100895608?v=4&w=50&h=50&mask=circle)](https://github.com/hanhyalex123)[![ps4vs](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/91535358?v=4&w=50&h=50&mask=circle)](https://github.com/ps4vs)[![eltociear](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/22633385?v=4&w=50&h=50&mask=circle)](https://github.com/eltociear) [![shaiss](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/113060?v=4&w=50&h=50&mask=circle)](https://github.com/shaiss) [![AdityaRajSingh1992](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/105219157?v=4&w=50&h=50&mask=circle)](https://github.com/AdityaRajSingh1992) [![namansleeps2](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/134390870?v=4&w=50&h=50&mask=circle)](https://github.com/namansleeps22) [![sirajperson](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/396941?v=4&w=50&h=50&mask=circle)](https://github.com/sirajperson) [![hsm207](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/2398765?v=4&w=50&h=50&mask=circle)](https://github.com/hsm207) [![unkn-wn](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/43097991?v=4&w=50&h=50&mask=circle)](https://github.com/unkn-wn) [![DMTarmey](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/590474?v=4&w=50&h=50&mask=circle)](https://github.com/DMTarmey) [![Parth2506](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/122429822?v=4&w=50&h=50&mask=circle)](https://github.com/Parth2506) [![platinaCoder](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/47349795?v=4&w=50&h=50&mask=circle)](https://github.com/platinaCoder) [![anisha1607](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/60440541?v=4&w=50&h=50&mask=circle)](https://github.com/anisha1607) [![jorgectf](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/46056498?v=4&w=50&h=50&mask=circle)](https://github.com/jorgectf) [![PaulRBerg](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/8782666?v=4&w=50&h=50&mask=circle)](https://github.com/PaulRBerg) [![boundless-asura](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/122777244?v=4&w=50&h=50&mask=circle)](https://github.com/boundless-asura) [![JPDucky](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/34105363?v=4&w=50&h=50&mask=circle)](https://github.com/JPDucky) [![Vibhusha22](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/128478691?v=4&w=50&h=50&mask=circle)](https://github.com/Vibhusha22) [![ai-akuma](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/7444521?v=4&w=50&h=50&mask=circle)](https://github.com/ai-akuma) [![rounak610](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/81288115?v=4&w=50&h=50&mask=circle)](https://github.com/rounak610) [![AdarshJha619](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/53672264?v=4&w=50&h=50&mask=circle)](https://github.com/AdarshJha619) [![ResoluteStoic](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/105219157?v=4&w=50&h=50&mask=circle)](https://github.com/ResoluteStoic) [![JohnHunt999](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/137149331?v=4&w=50&h=50&mask=circle)](https://github.com/JohnHunt999) [![Maverick-F35](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/138012351?v=4&w=50&h=50&mask=circle)](https://github.com/Maverick-F359) [![jorgectf](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/46056498?v=4&w=50&h=50&mask=circle)](https://github.com/jorgectf) [![AdityaSharma13064](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/138581531?v=4&w=50&h=50&mask=circle)](https://github.com/AdityaSharma13064) [![lalitlj](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/138583454?v=4&w=50&h=50&mask=circle)](https://github.com/lalitlj) [![andrew-kelly-neutralaiz](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/128111428?v=4&w=50&h=50&mask=circle)](https://github.com/andrew-kelly-neutralaiz) [![sayan1101](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/139119661?v=4&w=50&h=50&mask=circle)](https://github.com/sayan1101)

Back to top

### ⚠️ Under Development! This project is under active development and may still have issues. We appreciate your understanding and patience. If you encounter any problems, please check the open issues first. If your issue is not listed, kindly create a new issue detailing the error or problem you experienced. Thank you for your support! ================================================ FILE: alembic.ini ================================================ # A generic, single database configuration. [alembic] # path to migration scripts script_location = migrations # template used to generate migration file names; The default value is %%(rev)s_%%(slug)s # Uncomment the line below if you want the files to be prepended with date and time # see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file # for all available tokens # file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s # sys.path path, will be prepended to sys.path if present. # defaults to the current working directory. prepend_sys_path = . # timezone to use when rendering the date within the migration file # as well as the filename. # If specified, requires the python-dateutil library that can be # installed by adding `alembic[tz]` to the pip requirements # string value is passed to dateutil.tz.gettz() # leave blank for localtime # timezone = # max length of characters to apply to the # "slug" field # truncate_slug_length = 40 # set to 'true' to run the environment during # the 'revision' command, regardless of autogenerate # revision_environment = false # set to 'true' to allow .pyc and .pyo files without # a source .py file to be detected as revisions in the # versions/ directory # sourceless = false # version location specification; This defaults # to migrations/versions. When using multiple version # directories, initial revisions must be specified with --version-path. # The path separator used here should be the separator specified by "version_path_separator" below. # version_locations = %(here)s/bar:%(here)s/bat:migrations/versions # version path separator; As mentioned above, this is the character used to split # version_locations. The default within new alembic.ini files is "os", which uses os.pathsep. # If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas. # Valid values for version_path_separator are: # # version_path_separator = : # version_path_separator = ; # version_path_separator = space version_path_separator = os # Use os.pathsep. Default configuration used for new projects. # set to 'true' to search source files recursively # in each "version_locations" directory # new in Alembic version 1.10 # recursive_version_locations = false # the output encoding used when revision files # are written from script.py.mako # output_encoding = utf-8 sqlalchemy.url = postgresql://superagi:password@super__postgres:5432/super_agi_main [post_write_hooks] # post_write_hooks defines scripts or Python functions that are run # on newly generated revision scripts. See the documentation for further # detail and examples # format using "black" - use the console_scripts runner, against the "black" entrypoint # hooks = black # black.type = console_scripts # black.entrypoint = black # black.options = -l 79 REVISION_SCRIPT_FILENAME # Logging configuration [loggers] keys = root,sqlalchemy,alembic [handlers] keys = console [formatters] keys = generic [logger_root] level = WARN handlers = console qualname = [logger_sqlalchemy] level = WARN handlers = qualname = sqlalchemy.engine [logger_alembic] level = INFO handlers = qualname = alembic [handler_console] class = StreamHandler args = (sys.stderr,) level = NOTSET formatter = generic [formatter_generic] format = %(levelname)-5.5s [%(name)s] %(message)s datefmt = %H:%M:%S ================================================ FILE: cli2.py ================================================ import os import sys import subprocess from time import sleep import shutil from sys import platform from multiprocessing import Process from superagi.lib.logger import logger def check_command(command, message): if not shutil.which(command): logger.info(message) sys.exit(1) def run_npm_commands(shell=False): os.chdir("gui") try: subprocess.run(["npm", "install"], check=True, shell=shell) except subprocess.CalledProcessError: logger.error(f"Error during '{' '.join(sys.exc_info()[1].cmd)}'. Exiting.") sys.exit(1) os.chdir("..") def run_server(shell=False,a_name=None,a_description=None,goals=None): tgwui_process = Process(target=subprocess.run, args=(["python", "test.py","--name",a_name,"--description",a_description,"--goals"]+goals,), kwargs={"shell": shell}) api_process = Process(target=subprocess.run, args=(["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"],), kwargs={"shell": shell}) celery_process = Process(target=subprocess.run, args=(["celery", "-A", "celery_app", "worker", "--loglevel=info"],), kwargs={"shell": shell}) ui_process = Process(target=subprocess.run, args=(["python", "test.py","--name",a_name,"--description",a_description,"--goals"]+goals,), kwargs={"shell": shell}) api_process.start() celery_process.start() ui_process.start() return api_process, ui_process, celery_process def cleanup(api_process, ui_process, celery_process): logger.info("Shutting down processes...") api_process.terminate() ui_process.terminate() celery_process.terminate() logger.info("Processes terminated. Exiting.") sys.exit(1) if __name__ == "__main__": check_command("node", "Node.js is not installed. Please install it and try again.") check_command("npm", "npm is not installed. Please install npm to proceed.") check_command("uvicorn", "uvicorn is not installed. Please install uvicorn to proceed.") agent_name = input("Enter an agent name: ") agent_description = input("Enter an agent description: ") goals = [] while True: goal = input("Enter a goal (or 'q' to quit): ") if goal == 'q': break goals.append(goal) isWindows = False if platform == "win32" or platform == "cygwin": isWindows = True run_npm_commands(shell=isWindows) try: api_process, ui_process, celery_process = run_server(isWindows, agent_name, agent_description, goals) while True: try: sleep(30) except KeyboardInterrupt: cleanup(api_process, ui_process, celery_process) except Exception as e: cleanup(api_process, ui_process, celery_process) ================================================ FILE: config_template.yaml ================================================ #####################------------------SYSTEM KEYS-------------------------######################## PINECONE_API_KEY: YOUR_PINECONE_API_KEY PINECONE_ENVIRONMENT: YOUR_PINECONE_ENVIRONMENT OPENAI_API_KEY: YOUR_OPEN_API_KEY PALM_API_KEY: YOUR_PALM_API_KEY REPLICATE_API_TOKEN: YOUR_REPLICATE_API_TOKEN HUGGING_API_TOKEN: YOUR_HUGGING_FACE_API_TOKEN # For locally hosted LLMs comment out the next line and uncomment the one after # to configure a local llm point your browser to 127.0.0.1:7860 and click on the model tab in text generation web ui. OPENAI_API_BASE: https://api.openai.com/v1 #OPENAI_API_BASE: "http://super__tgwui:5001/v1" # "gpt-3.5-turbo-0301": 4032, "gpt-4-0314": 8092, "gpt-3.5-turbo": 4032, "gpt-4": 8092, "gpt-4-32k": 32768, "gpt-4-32k-0314": 32768, "llama":2048, "mpt-7b-storywriter":45000 MODEL_NAME: "gpt-3.5-turbo-0301" # "gpt-3.5-turbo", , "gpt-4", "models/chat-bison-001" RESOURCES_SUMMARY_MODEL_NAME: "gpt-3.5-turbo" MAX_TOOL_TOKEN_LIMIT: 800 MAX_MODEL_TOKEN_LIMIT: 4032 # set to 2048 for llama #DATABASE INFO # redis details DB_NAME: super_agi_main DB_HOST: super__postgres DB_USERNAME: superagi DB_PASSWORD: password DB_URL: postgresql://superagi:password@super__postgres:5432/super_agi_main REDIS_URL: "super__redis:6379" #STORAGE TYPE ("FILE" or "S3") STORAGE_TYPE: "FILE" #TOOLS TOOLS_DIR: "superagi/tools" #STORAGE INFO FOR FILES RESOURCES_INPUT_ROOT_DIR: workspace/input/{agent_id} RESOURCES_OUTPUT_ROOT_DIR: workspace/output/{agent_id}/{agent_execution_id} # For keeping resources at agent execution level #RESOURCES_OUTPUT_ROOT_DIR: workspace/output/{agent_id} # For keeping resources at agent level #S3 RELATED DETAILS ONLY WHEN STORAGE_TYPE IS "S3" BUCKET_NAME: INSTAGRAM_TOOL_BUCKET_NAME: #Public read bucket, Images generated by stable diffusion are put in this bucket and the public url of the same is generated. AWS_ACCESS_KEY_ID: AWS_SECRET_ACCESS_KEY: #AUTH ENV: 'DEV' #DEV,PROD, to use GITHUB OAUTH set to PROD JWT_SECRET_KEY: 'secret' expiry_time_hours: 1 #GITHUB OAUTH: GITHUB_CLIENT_ID: GITHUB_CLIENT_SECRET: FRONTEND_URL: "http://localhost:3000" #ENCRYPTION KEY, Replace this with your own key for production ENCRYPTION_KEY: abcdefghijklmnopqrstuvwxyz123456 #WEAVIATE # If you are using docker or web hosted uncomment the next two lines and comment the third one # WEAVIATE_URL: YOUR_WEAVIATE_URL # WEAVIATE_API_KEY: YOUR_WEAVIATE_API_KEY WEAVIATE_USE_EMBEDDED: true #####################------------------TOOLS KEY-------------------------######################## #If you have google api key and CSE key, use this GOOGLE_API_KEY: YOUR_GOOGLE_API_KEY SEARCH_ENGINE_ID: YOUR_SEARCH_ENIGNE_ID # IF YOU DONT HAVE GOOGLE SEARCH KEY, YOU CAN USE SERPER.DEV KEYS SERP_API_KEY: YOUR_SERPER_API_KEY #ENTER YOUR EMAIL CREDENTIALS TO ACCESS EMAIL TOOL EMAIL_ADDRESS: YOUR_EMAIL_ADDRESS EMAIL_PASSWORD: YOUR_EMAIL_APP_PASSWORD #get the app password from (https://myaccount.google.com/apppasswords) EMAIL_SMTP_HOST: smtp.gmail.com #Change the SMTP host if not using Gmail EMAIL_SMTP_PORT: 587 #Change the SMTP port if not using Gmail EMAIL_IMAP_SERVER: imap.gmail.com #Change the IMAP Host if not using Gmail EMAIL_SIGNATURE: Email sent by SuperAGI EMAIL_DRAFT_MODE_WITH_FOLDER: YOUR_DRAFTS_FOLDER EMAIL_ATTACHMENT_BASE_PATH: YOUR_DIRECTORY_FOR_EMAIL_ATTACHMENTS # GITHUB GITHUB_USERNAME: YOUR_GITHUB_USERNAME GITHUB_ACCESS_TOKEN: YOUR_GITHUB_ACCESS_TOKEN #JIRA JIRA_INSTANCE_URL: YOUR_JIRA_INSTANCE_URL JIRA_USERNAME: YOUR_JIRA_EMAIL JIRA_API_TOKEN: YOUR_JIRA_API_TOKEN #SLACK SLACK_BOT_TOKEN: YOUR_SLACK_BOT_TOKEN # For running stable diffusion STABILITY_API_KEY: YOUR_STABILITY_API_KEY #Engine IDs that can be used: 'stable-diffusion-v1', 'stable-diffusion-v1-5','stable-diffusion-512-v2-0', 'stable-diffusion-768-v2-0','stable-diffusion-512-v2-1','stable-diffusion-768-v2-1','stable-diffusion-xl-beta-v2-2-2' ENGINE_ID: "stable-diffusion-xl-beta-v2-2-2" ## To config a vector store for resources manager uncomment config below ## based on the vector store you want to use ## RESOURCE_VECTOR_STORE can be REDIS, PINECONE, CHROMA, QDRANT #RESOURCE_VECTOR_STORE: YOUR_RESOURCE_VECTOR_STORE #RESOURCE_VECTOR_STORE_INDEX_NAME: YOUR_RESOURCE_VECTOR_STORE_INDEX_NAME ## To use a custom redis #REDIS_VECTOR_STORE_URL: YOUR_REDIS_VECTOR_STORE_URL ## To use qdrant for vector store in resources manager #QDRANT_PORT: YOUR_QDRANT_PORT #QDRANT_HOST_NAME: YOUR_QDRANT_HOST_NAME ## To use chroma for vector store in resources manager #CHROMA_HOST_NAME: YOUR_CHROMA_HOST_NAME #CHROMA_PORT: YOUR_CHROMA_PORT ## To use Qdrant for vector store #QDRANT_HOST_NAME: YOUR_QDRANT_HOST_NAME #QDRANT_PORT: YOUR_QDRANT_PORT #GPU_LAYERS: GPU LAYERS THAT YOU WANT TO OFFLOAD TO THE GPU WHILE USING LOCAL LLMS ================================================ FILE: docker-compose-dev.yaml ================================================ version: '3.8' services: backend: volumes: - "./:/app" build: . depends_on: - super__redis - super__postgres networks: - super_network command: ["/app/wait-for-it.sh", "super__postgres:5432","-t","60","--","/app/entrypoint.sh"] celery: volumes: - "./:/app" - "${EXTERNAL_RESOURCE_DIR:-./workspace}:/app/ext" build: . depends_on: - super__redis - super__postgres networks: - super_network command: ["/app/entrypoint_celery.sh"] gui: build: context: ./gui args: NEXT_PUBLIC_API_BASE_URL: "/api" networks: - super_network # volumes: # - ./gui:/app # - /app/node_modules/ # - /app/.next/ super__redis: image: "redis/redis-stack-server:latest" networks: - super_network # uncomment to expose redis port to host # ports: # - "6379:6379" volumes: - redis_data:/data super__postgres: image: "docker.io/library/postgres:latest" environment: - POSTGRES_USER=superagi - POSTGRES_PASSWORD=password - POSTGRES_DB=super_agi_main volumes: - superagi_postgres_data:/var/lib/postgresql/data/ networks: - super_network # uncomment to expose postgres port to host # ports: # - "5432:5432" proxy: image: nginx:stable-alpine ports: - "3000:80" networks: - super_network depends_on: - backend - gui volumes: - ./nginx/default.conf:/etc/nginx/conf.d/default.conf networks: super_network: driver: bridge volumes: superagi_postgres_data: redis_data: ================================================ FILE: docker-compose-gpu.yml ================================================ version: '3.8' services: backend: volumes: - "./:/app" build: context: . dockerfile: Dockerfile-gpu depends_on: - super__redis - super__postgres networks: - super_network command: ["/app/wait-for-it.sh", "super__postgres:5432","-t","60","--","/app/entrypoint.sh"] deploy: resources: reservations: devices: - driver: nvidia count: all capabilities: [gpu] celery: volumes: - "./:/app" - "${EXTERNAL_RESOURCE_DIR:-./workspace}:/app/ext" build: context: . dockerfile: Dockerfile-gpu depends_on: - super__redis - super__postgres networks: - super_network command: ["/app/entrypoint_celery.sh"] deploy: resources: reservations: devices: - driver: nvidia count: all capabilities: [gpu] gui: build: context: ./gui args: NEXT_PUBLIC_API_BASE_URL: "/api" networks: - super_network # volumes: # - ./gui:/app # - /app/node_modules/ # - /app/.next/ super__redis: image: "redis/redis-stack-server:latest" networks: - super_network # uncomment to expose redis port to host # ports: # - "6379:6379" volumes: - redis_data:/data super__postgres: image: "docker.io/library/postgres:15" environment: - POSTGRES_USER=superagi - POSTGRES_PASSWORD=password - POSTGRES_DB=super_agi_main volumes: - superagi_postgres_data:/var/lib/postgresql/data/ networks: - super_network # uncomment to expose postgres port to host # ports: # - "5432:5432" proxy: image: nginx:stable-alpine ports: - "3000:80" networks: - super_network depends_on: - backend - gui volumes: - ./nginx/default.conf:/etc/nginx/conf.d/default.conf networks: super_network: driver: bridge volumes: superagi_postgres_data: redis_data: ================================================ FILE: docker-compose.image.example.yaml ================================================ version: '3.8' services: backend: image: "superagidev/superagi:main" depends_on: - super__redis - super__postgres networks: - super_network env_file: - config.yaml command: ["/app/wait-for-it.sh", "super__postgres:5432","-t","60","--","/app/entrypoint.sh"] celery: image: "superagidev/superagi:main" depends_on: - super__redis - super__postgres networks: - super_network env_file: - config.yaml command: ["/app/entrypoint_celery.sh"] volumes: - "./workspace:/app/workspace" gui: image: "superagidev/superagi-frontend:main" environment: - NEXT_PUBLIC_API_BASE_URL=/api networks: - super_network super__redis: image: "redis/redis-stack-server:latest" networks: - super_network # uncomment to expose redis port to host # ports: # - "6379:6379" volumes: - redis_data:/data super__postgres: image: "docker.io/library/postgres:latest" environment: - POSTGRES_USER=superagi - POSTGRES_PASSWORD=password - POSTGRES_DB=super_agi_main volumes: - superagi_postgres_data:/var/lib/postgresql/data/ networks: - super_network # uncomment to expose postgres port to host # ports: # - "5432:5432" proxy: image: nginx:stable-alpine ports: - "3000:80" networks: - super_network depends_on: - backend - gui volumes: - ./nginx/default.conf:/etc/nginx/conf.d/default.conf networks: super_network: driver: bridge volumes: superagi_postgres_data: redis_data: ================================================ FILE: docker-compose.yaml ================================================ version: '3.8' services: backend: volumes: - "./:/app" build: . depends_on: - super__redis - super__postgres networks: - super_network command: ["/app/wait-for-it.sh", "super__postgres:5432","-t","60","--","/app/entrypoint.sh"] celery: volumes: - "./:/app" - "${EXTERNAL_RESOURCE_DIR:-./workspace}:/app/ext" build: . depends_on: - super__redis - super__postgres networks: - super_network command: ["/app/entrypoint_celery.sh"] gui: build: context: ./gui args: NEXT_PUBLIC_API_BASE_URL: "/api" networks: - super_network # volumes: # - ./gui:/app # - /app/node_modules/ # - /app/.next/ super__redis: image: "redis/redis-stack-server:latest" networks: - super_network # uncomment to expose redis port to host # ports: # - "6379:6379" volumes: - redis_data:/data super__postgres: image: "docker.io/library/postgres:15" environment: - POSTGRES_USER=superagi - POSTGRES_PASSWORD=password - POSTGRES_DB=super_agi_main volumes: - superagi_postgres_data:/var/lib/postgresql/data/ networks: - super_network # uncomment to expose postgres port to host # ports: # - "5432:5432" proxy: image: nginx:stable-alpine ports: - "3000:80" networks: - super_network depends_on: - backend - gui volumes: - ./nginx/default.conf:/etc/nginx/conf.d/default.conf networks: super_network: driver: bridge volumes: superagi_postgres_data: redis_data: ================================================ FILE: entrypoint.sh ================================================ #!/bin/bash # Downloads the tools from marketplace and external tool repositories python superagi/tool_manager.py # Install dependencies ./install_tool_dependencies.sh # Run Alembic migrations alembic upgrade head # Start the app exec uvicorn main:app --host 0.0.0.0 --port 8001 --reload ================================================ FILE: entrypoint_celery.sh ================================================ #!/bin/bash # Downloads the tools python superagi/tool_manager.py # Install dependencies ./install_tool_dependencies.sh exec celery -A superagi.worker worker --beat --loglevel=info ================================================ FILE: gui/.dockerignore ================================================ # Ignore everything ** # Allow files and directories !app !pages !public !utils !package.json !next.config.js !package-lock.json !.eslintrc.json !jsconfig.json ================================================ FILE: gui/.eslintrc.json ================================================ { "extends": "next/core-web-vitals" } ================================================ FILE: gui/Dockerfile ================================================ FROM node:18-alpine AS deps RUN apk add --no-cache libc6-compat WORKDIR /app COPY package.json package-lock.json ./ RUN npm ci # Rebuild the source code only when needed FROM node:18-alpine AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . ARG NEXT_PUBLIC_API_BASE_URL=/api ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL ARG NEXT_PUBLIC_MIXPANEL_AUTH_ID ENV NEXT_PUBLIC_MIXPANEL_AUTH_ID=$NEXT_PUBLIC_MIXPANEL_AUTH_ID EXPOSE 3000 CMD ["npm", "run", "dev"] ================================================ FILE: gui/DockerfileProd ================================================ FROM node:18-alpine AS deps RUN apk add --no-cache libc6-compat WORKDIR /app COPY package.json package-lock.json ./ RUN npm ci --only=production # Rebuild the source code only when needed FROM node:18-alpine AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . ARG NEXT_PUBLIC_API_BASE_URL=/api ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL RUN npm run build # Production image, copy all the files and run next FROM node:18-alpine AS runner WORKDIR /app ENV NODE_ENV production RUN addgroup --system --gid 1001 supergroup RUN adduser --system --uid 1001 superuser COPY --from=builder /app/public ./public COPY --from=builder /app/package.json ./package.json # Automatically leverage output traces to reduce image size # https://nextjs.org/docs/advanced-features/output-file-tracing COPY --from=builder --chown=superuser:supergroup /app/.next/standalone ./ COPY --from=builder --chown=superuser:supergroup /app/.next/static ./.next/static USER superuser EXPOSE 3000 ENV PORT 3000 CMD ["node", "server.js"] ================================================ FILE: gui/README.md ================================================ This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). ## Getting Started First, run the development server: ```bash npm run dev # or yarn dev # or pnpm dev ``` Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file. This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. ## Learn More To learn more about Next.js, take a look at the following resources: - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! ## Deploy on Vercel The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. ================================================ FILE: gui/app/globals.css ================================================ :root { --max-width: 1100px; --border-radius: 12px; --font-mono: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace; --foreground-rgb: 0, 0, 0; --background-start-rgb: 214, 219, 220; --background-end-rgb: 255, 255, 255; --primary-glow: conic-gradient( from 180deg at 50% 50%, #16abff33 0deg, #0885ff33 55deg, #54d6ff33 120deg, #0071ff33 160deg, transparent 360deg ); --secondary-glow: radial-gradient( rgba(255, 255, 255, 1), rgba(255, 255, 255, 0) ); --tile-start-rgb: 239, 245, 249; --tile-end-rgb: 228, 232, 233; --tile-border: conic-gradient( #00000080, #00000040, #00000030, #00000020, #00000010, #00000010, #00000080 ); --callout-rgb: 238, 240, 241; --callout-border-rgb: 172, 175, 176; --card-rgb: 180, 185, 188; --card-border-rgb: 131, 134, 135; } @media (prefers-color-scheme: dark) { :root { --foreground-rgb: 255, 255, 255; --background-start-rgb: 0, 0, 0; --background-end-rgb: 0, 0, 0; --primary-glow: radial-gradient(rgba(1, 65, 255, 0.4), rgba(1, 65, 255, 0)); --secondary-glow: linear-gradient( to bottom right, rgba(1, 65, 255, 0), rgba(1, 65, 255, 0), rgba(1, 65, 255, 0.3) ); --tile-start-rgb: 2, 13, 46; --tile-end-rgb: 2, 5, 19; --tile-border: conic-gradient( #ffffff80, #ffffff40, #ffffff30, #ffffff20, #ffffff10, #ffffff10, #ffffff80 ); --callout-rgb: 20, 20, 20; --callout-border-rgb: 108, 108, 108; --card-rgb: 100, 100, 100; --card-border-rgb: 200, 200, 200; } } * { box-sizing: border-box; padding: 0; margin: 0; } html, body { max-width: 100vw; overflow-x: hidden; } body { color: rgb(var(--foreground-rgb)); background: linear-gradient( to bottom, transparent, rgb(var(--background-end-rgb)) ) rgb(var(--background-start-rgb)); } a { color: inherit; text-decoration: none; } @media (prefers-color-scheme: dark) { html { color-scheme: dark; } } ================================================ FILE: gui/app/layout.js ================================================ import './globals.css' export const metadata = { title: 'Super AGI', description: 'Generated by create next app', } export default function RootLayout({ children }) { return ( {children} ) } ================================================ FILE: gui/jsconfig.json ================================================ { "compilerOptions": { "paths": { "@/*": ["./*"] } } } ================================================ FILE: gui/next.config.js ================================================ /** @type {import('next').NextConfig} */ const nextConfig = { assetPrefix: process.env.NODE_ENV === "production" ? "/" : "./", output: 'standalone' }; module.exports = nextConfig; ================================================ FILE: gui/package.json ================================================ { "name": "super-agi", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint", "export": "next export" }, "dependencies": { "axios": "^1.4.0", "bootstrap": "^5.2.3", "date-fns": "^2.30.0", "date-fns-tz": "^2.0.0", "echarts": "^5.4.2", "echarts-for-react": "^3.0.2", "eslint": "8.40.0", "eslint-config-next": "13.4.2", "js-cookie": "^3.0.5", "jszip": "^3.10.1", "mitt": "^3.0.0", "mixpanel-browser": "^2.47.0", "moment": "^2.29.4", "moment-timezone": "^0.5.43", "next": "13.4.2", "react": "18.2.0", "react-datetime": "^3.2.0", "react-dom": "18.2.0", "react-draggable": "^4.4.5", "react-grid-layout": "^1.3.4", "react-markdown": "^8.0.7", "react-spinners": "^0.13.8", "react-tippy": "^1.4.0", "react-toastify": "^9.1.3" } } ================================================ FILE: gui/pages/Content/APM/Apm.module.css ================================================ .apm_dashboard_container { display: flex; flex-direction: column; } .apm_dashboard { margin-top: 16px; height: calc(100vh - 16vh); overflow-y: auto; } ================================================ FILE: gui/pages/Content/APM/ApmDashboard.js ================================================ import React, {useState, useEffect, useCallback, useRef} from 'react'; import Image from "next/image"; import style from "./Apm.module.css"; import 'react-toastify/dist/ReactToastify.css'; import {getActiveRuns, getAgentRuns, getAllAgents, getToolsUsage, getMetrics} from "@/pages/api/DashboardService"; import {formatNumber, formatTime, returnToolkitIcon} from "@/utils/utils"; import {BarGraph} from "./BarGraph.js"; import {WidthProvider, Responsive} from 'react-grid-layout'; import 'react-grid-layout/css/styles.css'; import 'react-resizable/css/styles.css'; import { Tooltip } from 'react-tippy'; const ResponsiveGridLayout = WidthProvider(Responsive); export default function ApmDashboard() { const [agentDetails, setAgentDetails] = useState([]); const [tokenDetails, setTokenDetails] = useState([]); const [runDetails, setRunDetails] = useState(0); const [allAgents, setAllAgents] = useState([]); const [dropdown1, setDropDown1] = useState(false); const [dropdown2, setDropDown2] = useState(false); const [dropdown3, setDropDown3] = useState(false); const [selectedAgent, setSelectedAgent] = useState('Select an Agent'); const [selectedAgentIndex, setSelectedAgentIndex] = useState(-1); const [selectedAgentRun, setSelectedAgentRun] = useState([]); const [activeRuns, setActiveRuns] = useState([]); const [selectedAgentDetails, setSelectedAgentDetails] = useState(null); const [toolsUsed, setToolsUsed] = useState([]); const [showToolTip, setShowToolTip] = useState(false); const [toolTipIndex, setToolTipIndex] = useState(-1); const initialLayout = [ {i: 'total_agents', x: 0, y: 0, w: 3, h: 1.5}, {i: 'total_tokens', x: 3, y: 0, w: 3, h: 1.5}, {i: 'total_runs', x: 6, y: 0, w: 3, h: 1.5}, {i: 'active_runs', x: 9, y: 0, w: 3, h: 2}, {i: 'most_used_tools', x: 9, y: 1, w: 3, h: 2}, {i: 'models_by_agents', x: 0, y: 1, w: 3, h: 2.5}, {i: 'runs_by_model', x: 3, y: 1, w: 3, h: 2.5}, {i: 'tokens_by_model', x: 6, y: 1, w: 3, h: 2.5}, {i: 'agent_details', x: 0, y: 2, w: 12, h: 2.5}, {i: 'total_tokens_consumed', x: 0, y: 3, w: 4, h: 2}, {i: 'total_calls_made', x: 4, y: 3, w: 4, h: 2}, {i: 'tokens_consumed_per_call', x: 8, y: 3, w: 4, h: 2}, ]; const storedLayout = localStorage.getItem('myLayoutKey'); const [layout, setLayout] = useState(storedLayout !== null ? JSON.parse(storedLayout) : initialLayout); const firstUpdate = useRef(true); const onLayoutChange = (currentLayout) => { setLayout(currentLayout); }; const onClickLayoutChange = () => { localStorage.setItem('myLayoutKey', JSON.stringify(initialLayout)); setLayout(initialLayout); } useEffect(() => { if (!firstUpdate.current) { localStorage.setItem('myLayoutKey', JSON.stringify(layout)); } else { firstUpdate.current = false; } }, [layout]); const assignDefaultDataPerModel = (data, modelList) => { const modelsInData = data.map(item => item.name); modelList.forEach((model) => { if (!modelsInData.includes(model)) { data.push({name: model, value: 0}); } }); }; useEffect(() => { const fetchData = async () => { try { const [metricsResponse, agentsResponse, activeRunsResponse, toolsUsageResponse] = await Promise.all([getMetrics(), getAllAgents(), getActiveRuns(), getToolsUsage()]); const models = ['gpt-4', 'gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-4-32k', 'google-palm-bison-001', 'replicate-llama13b-v2-chat']; assignDefaultDataPerModel(metricsResponse.data.agent_details.model_metrics, models); assignDefaultDataPerModel(metricsResponse.data.tokens_details.model_metrics, models); assignDefaultDataPerModel(metricsResponse.data.run_details.model_metrics, models); setAgentDetails(metricsResponse.data.agent_details); setTokenDetails(metricsResponse.data.tokens_details); setRunDetails(metricsResponse.data.run_details); setAllAgents(agentsResponse.data.agent_details); setActiveRuns(activeRunsResponse.data); setToolsUsed(toolsUsageResponse.data); } catch (error) { console.log(`Error in fetching data: ${error}`); } } fetchData(); const interval = setInterval(fetchData, 10000); return () => clearInterval(interval); }, []); useEffect(() => { console.log(toolsUsed) }, [toolsUsed]); const handleSelectedAgent = useCallback((index, name) => { setDropDown1(false) setDropDown2(false) setDropDown3(false) setSelectedAgent(name) setSelectedAgentIndex(index) const agentDetails = allAgents.find(agent => agent.agent_id === index); setSelectedAgentDetails(agentDetails); getAgentRuns(index).then((response) => { const data = response.data; setSelectedAgentRun(data); }).catch((error) => console.error(`Error in fetching agent runs: ${error}`)); }, [allAgents]); useEffect(() => handleSelectedAgent(selectedAgentIndex, selectedAgent), [allAgents]); useEffect(() => { if (allAgents.length > 0 && selectedAgent === 'Select an Agent') { const lastAgent = allAgents[allAgents.length - 1]; handleSelectedAgent(lastAgent.agent_id, lastAgent.name); } }, [allAgents, selectedAgent, handleSelectedAgent]); const setToolTipState = (state, index) => { setShowToolTip(state) setToolTipIndex(index) } return (
Agent Performance Monitoring {/**/}
Total Agents
{formatNumber(agentDetails.total_agents)}
Total tokens consumed
{formatNumber(tokenDetails.total_tokens)}
Total runs
{formatNumber(runDetails.total_runs)}
Number of Agents per model {agentDetails.model_metrics && agentDetails.model_metrics.length > 0 ? <>
Models
:
No Data No Agents Found
}
Number of Runs per Model {runDetails.model_metrics && runDetails.model_metrics.length > 0 ? <>
Models
:
No Data No Agents Found
}
Total Tokens consumed by models {tokenDetails.model_metrics && tokenDetails.model_metrics.length > 0 ? <>
Models
:
No Data No Agents Found
}
Most used tools {toolsUsed.length === 0 ?
No Data No Used Tools Found
:
Tool Agents Calls
{toolsUsed.map((tool, index) => ( ))}
tool-icon {tool.tool_name} {tool.unique_agents} {tool.total_usage}
}
Agent Overview {allAgents.length === 0 ?
No Data {selectedAgent === 'Select an Agent' ? 'Please Select an Agent' : No Runs found for {selectedAgent}}
:
Agent Name Model Tokens Consumed Runs Avg tokens per run Tools Calls Avg Run Time
{allAgents.map((run, i) => ( ))}
{run.name} {run.model_name} {formatNumber(run.total_tokens)} {run.runs_completed} {run.runs_completed ? formatNumber((run.total_tokens / run.runs_completed).toFixed(1)) : '-'} {run.tools_used && run.tools_used.slice(0, 3).map((tool, index) => (
{tool}
))} {run.tools_used && run.tools_used.length > 3 &&
{run.tools_used.slice(3).map((tool,index) =>
{tool}
)}
} >
+{run.tools_used.length - 3}
}
{run.total_calls} {run.avg_run_time === 0 ? '-' : `${parseFloat((run.avg_run_time / 60).toFixed(1))} mins`}
}
Active Runs
{activeRuns.length === 0 ?
No Data No active runs found
: activeRuns.map((run, index) => (
{run.name}
{run.agent_name} · schedule-icon {formatTime(run.created_at)}
))}
Tokens Consumed by Runs
{allAgents.length > 0 &&
setDropDown2(!dropdown2)}>{selectedAgent}
{dropdown2 &&
{allAgents.map((agent, index) => (
handleSelectedAgent(agent.agent_id, agent.name)}>{agent.name}
))}
}
}
{selectedAgentRun.length > 0 ? <>
Runs
:
No Data No Runs Found
}
Calls Made by Runs
{allAgents.length > 0 &&
setDropDown1(!dropdown1)}>{selectedAgent}
{dropdown1 &&
{allAgents.map((agent, index) => (
handleSelectedAgent(agent.agent_id, agent.name)}>{agent.name}
))}
}
}
{selectedAgentRun.length > 0 ? <>
Runs
:
No Data No Runs Found
}
Average Tokens consumed in all calls per run
{allAgents.length > 0 &&
setDropDown3(!dropdown3)}>{selectedAgent}
{dropdown3 &&
{allAgents.map((agent, index) => (
handleSelectedAgent(agent.agent_id, agent.name)}>{agent.name}
))}
}
}
{selectedAgentRun.length > 0 ? <>
Runs
:
No Data No Runs Found
}
); } ================================================ FILE: gui/pages/Content/APM/BarGraph.js ================================================ import React, {useEffect, useRef} from "react"; import * as echarts from 'echarts'; export const BarGraph = ({data, type, color}) => { const chartRef = useRef(null); const containerRef = useRef(null); useEffect(() => { const chartInstance = echarts.getInstanceByDom(chartRef.current); const chart = chartInstance ? chartInstance : echarts.init(chartRef.current); const option = { color: color, tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, xAxis: { type: 'category', data: data.map(item => item.name), axisLabel: { interval: 0, rotate: 45, color: '#888' } }, yAxis: { type: 'value', axisLabel: { formatter: function (value) { if (value >= 1000) { return `${value / 1000}k`; } else { return value; } } }, splitLine: { lineStyle: { color: 'rgba(255, 255, 255, 0.08)' } } }, series: [{ data: data.map(item => type === 'tokens_per_call' ? (item.tokens_consumed / item.calls) : item[type]), type: 'bar' }], responsive: true }; chart.setOption(option); const resizeObserver = new ResizeObserver(entries => { entries.forEach(entry => { chart.resize(); }); }); resizeObserver.observe(containerRef.current); return () => resizeObserver.disconnect(); }, [data, type]); return (
); } export default BarGraph; ================================================ FILE: gui/pages/Content/Agents/ActionConsole.js ================================================ import React, {useState, useEffect} from 'react'; import styles from './Agents.module.css'; import Image from 'next/image'; import {updatePermissions} from '@/pages/api/DashboardService'; import {formatTimeDifference} from '@/utils/utils'; function ActionBox({action, index, denied, reasons, handleDeny, handleSelection, setReasons}) { const isDenied = denied[index]; return (
{action.question && (
{action.question}
)} {!action.question && (
Tool {action.tool_name} is seeking for Permissions
)} {isDenied && (
Provide Feedback (Optional)
{ const newReasons = [...reasons]; newReasons[index] = e.target.value; setReasons(newReasons); }}/>
)} {isDenied ? (
) : (
)}
schedule-icon
{formatTimeDifference(action.time_difference)}
); } function HistoryBox({action}) { return (
Permissions for {action.tool_name} was::
{action.status && action.status === 'APPROVED' ? ( ) : ( )} {action.user_feedback != null &&
FeedBack
{action.user_feedback}
}
schedule-icon
{formatTimeDifference(action.time_difference)}
) } export default function ActionConsole({actions, pendingPermission, setPendingPermissions}) { const [hiddenActions, setHiddenActions] = useState([]); const [denied, setDenied] = useState([]); const [reasons, setReasons] = useState([]); const [localActionIds, setLocalActionIds] = useState([]); useEffect(() => { const updatedActions = actions?.filter((action) => !localActionIds.includes(action.id)); if (updatedActions && updatedActions.length > 0) { setLocalActionIds((prevIds) => [...prevIds, ...updatedActions.map(({id}) => id)]); setDenied((prevDenied) => prevDenied.map((value, index) => updatedActions[index] ? false : value)); setReasons((prevReasons) => prevReasons.map((value, index) => updatedActions[index] ? '' : value)); } }, [actions]); const handleDeny = (index) => { setDenied((prevDenied) => { const newDeniedState = [...prevDenied]; newDeniedState[index] = !newDeniedState[index]; return newDeniedState; }); }; const handleSelection = (index, status, permissionId) => { setHiddenActions((prevHiddenActions) => [...prevHiddenActions, index]); const data = { status: status, user_feedback: reasons[index], }; updatePermissions(permissionId, data).then((response) => { if (response.status === 200) setPendingPermissions(pendingPermission - 1) }); }; return ( <> {actions && actions.length > 0 ? (
{actions.map((action, index) => { if (action.status === 'PENDING' && !hiddenActions.includes(index)) { return (); } else if (action.status === 'APPROVED' || action.status === 'REJECTED') { return (); } return null; })}
) : (
no-permissions No Actions to Display!
)} ); } ================================================ FILE: gui/pages/Content/Agents/ActivityFeed.js ================================================ import React, {useEffect, useRef, useState} from 'react'; import styles from './Agents.module.css'; import {getExecutionFeeds, getDateTime} from "@/pages/api/DashboardService"; import Image from "next/image"; import {loadingTextEffect, formatTimeDifference, convertWaitingPeriod, updateDateBasedOnValue} from "@/utils/utils"; import {EventBus} from "@/utils/eventBus"; import {ClipLoader} from 'react-spinners'; export default function ActivityFeed({selectedRunId, selectedView, setFetchedData, agent, selectedRunStatus}) { const [loadingText, setLoadingText] = useState("Thinking"); const [feeds, setFeeds] = useState([]); const feedContainerRef = useRef(null); const [runStatus, setRunStatus] = useState("CREATED"); const [prevFeedsLength, setPrevFeedsLength] = useState(0); const [scheduleDate, setScheduleDate] = useState(null); const [scheduleTime, setScheduleTime] = useState(null); const [isLoading, setIsLoading] = useState(true); const [waitingPeriod, setWaitingPeriod] = useState(null); const [errorMsg, setErrorMsg] = useState(''); useEffect(() => { const interval = window.setInterval(function () { if (selectedRunStatus !== "ERROR_PAUSED") { fetchFeeds(); } }, 5000); return () => clearInterval(interval); }, [selectedRunId, selectedRunStatus]); function fetchDateTime() { getDateTime(agent.id) .then((response) => { const {start_date, start_time} = response.data; setScheduleDate(start_date); setScheduleTime(start_time); }) .catch((error) => { console.error('Error fetching agent data:', error); }); } useEffect(() => { loadingTextEffect('Thinking', setLoadingText, 250); if (agent?.is_scheduled && !agent?.is_running) { fetchDateTime(); } }, []); useEffect(() => { if (feeds.length !== prevFeedsLength) { if (feedContainerRef.current) { setTimeout(() => { if (feedContainerRef.current !== null) { feedContainerRef.current.scrollTo({top: feedContainerRef.current.scrollHeight, behavior: 'smooth'}); setPrevFeedsLength(feeds.length); } }, 100); } } }, [feeds]); function scrollToTop() { if (feedContainerRef.current) { setTimeout(() => { feedContainerRef.current.scrollTo({top: 0, behavior: 'smooth'}); }, 100); } } useEffect(() => { fetchFeeds(); }, [selectedRunId]) useEffect(() => { EventBus.emit('reFetchAgents', {}); }, [runStatus]) function fetchFeeds() { if (selectedRunId !== null) { setIsLoading(true); getExecutionFeeds(selectedRunId) .then((response) => { const data = response.data; setFeeds(data.feeds); setErrorMsg(data.errors) setRunStatus(data.status); setFetchedData(data.permissions); setWaitingPeriod(data.waiting_period ? data.waiting_period : null) EventBus.emit('resetRunStatus', {executionId: selectedRunId, status: data.status}); setIsLoading(false); //add this line }) .catch((error) => { console.error('Error fetching execution feeds:', error); setIsLoading(false); // and this line }); } } useEffect(() => { const updateRunStatus = (eventData) => { if (eventData.selectedRunId === selectedRunId) { setRunStatus(eventData.status); } }; const refreshDate = () => { fetchDateTime(); }; EventBus.on('updateRunStatus', updateRunStatus); EventBus.on('refreshDate', refreshDate); return () => { EventBus.off('updateRunStatus', updateRunStatus); EventBus.off('refreshDate', refreshDate); }; }); return (<>
{agent?.is_scheduled && !agent?.is_running && !selectedRunId ?
github
This agent is scheduled to start on {scheduleDate}, at {scheduleTime}
:
{feeds && feeds.map((f, index) => (
{f.role === 'user' &&
💁
} {f.role === 'system' &&
🛠️
} {f.role === 'assistant' &&
💡
}
{f?.feed || ''}
{f.time_difference &&
schedule-icon
{formatTimeDifference(f.time_difference)}
}
))} {runStatus === 'WAIT_STEP' &&
Waiting Block Initiated. The Agent will wait for {convertWaitingPeriod(waitingPeriod) || null}
} {runStatus === 'RUNNING' &&
🧠
{loadingText}
} {runStatus === 'COMPLETED' &&
🏁
All goals completed successfully!
} {runStatus === 'ITERATION_LIMIT_EXCEEDED' &&
⚠️
Stopped: Maximum iterations exceeded!
} {runStatus === 'ERROR_PAUSED' &&
{errorMsg}
}
} {feeds.length < 1 && !agent?.is_running && !agent?.is_scheduled &&
The Agent is not scheduled
}
{feedContainerRef.current && feedContainerRef.current.scrollTop >= 1200 &&
back-to-top
}
) } ================================================ FILE: gui/pages/Content/Agents/AgentCreate.js ================================================ import React, {useState, useEffect, useRef} from 'react'; import Image from "next/image"; import {ToastContainer, toast} from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; import { createAgent, editAgentTemplate, fetchAgentTemplateConfigLocal, getOrganisationConfig, getLlmModels, updateExecution, uploadFile, getAgentDetails, addAgentRun, fetchModels, getAgentWorkflows, publishTemplateToMarketplace } from "@/pages/api/DashboardService"; import {formatBytes, openNewTab, removeTab, setLocalStorageValue, setLocalStorageArray, returnResourceIcon, getUserTimezone, createInternalId, preventDefault, excludedToolkits, getUserClick} from "@/utils/utils"; import {EventBus} from "@/utils/eventBus"; import styles from "@/pages/Content/Agents/Agents.module.css"; import styles1 from "@/pages/Content/Knowledge/Knowledge.module.css"; import 'moment-timezone'; import AgentSchedule from "@/pages/Content/Agents/AgentSchedule"; export default function AgentCreate({ sendAgentData, knowledge, selectedProjectId, fetchAgents, toolkits, organisationId, template, internalId, sendKnowledgeData, env, edit, editAgentId, agents }) { const [advancedOptions, setAdvancedOptions] = useState(false); const [agentName, setAgentName] = useState(""); const [agentTemplateId, setAgentTemplateId] = useState(null); const [agentDescription, setAgentDescription] = useState(""); const [longTermMemory, setLongTermMemory] = useState(true); const [addResources, setAddResources] = useState(true); const [input, setInput] = useState([]); const [isDragging, setIsDragging] = useState(false); const [createClickable, setCreateClickable] = useState(true); const fileInputRef = useRef(null); const [maxIterations, setIterations] = useState(25); const [toolkitList, setToolkitList] = useState(toolkits) const [searchValue, setSearchValue] = useState(''); const [showButton, setShowButton] = useState(false); const [showPlaceholder, setShowPlaceholder] = useState(true); const [modelsArray, setModelsArray] = useState(['gpt-4', 'gpt-3.5-turbo', 'gpt-3.5-turbo-16k']); const constraintsArray = [ "If you are unsure how you previously did something or want to recall past events, thinking about similar events will help you remember.", "Ensure the tool and args are as per current plan and reasoning", 'Exclusively use the tools listed under "TOOLS"', "REMEMBER to format your response as JSON, using double quotes (\"\") around keys and string values, and commas (,) to separate items in arrays and objects. IMPORTANTLY, to use a JSON object as a string in another JSON object, you need to escape the double quotes." ]; const [constraints, setConstraints] = useState(constraintsArray); const [goals, setGoals] = useState(['Describe the agent goals here']); const [instructions, setInstructions] = useState(['']); const models = ['gpt-4', 'gpt-3.5-turbo', 'gpt-3.5-turbo-16k'] const [model, setModel] = useState(models[1]); const modelRef = useRef(null); const [modelDropdown, setModelDropdown] = useState(false); const [agentWorkflows, setAgentWorkflows] = useState(''); const [agentWorkflow, setAgentWorkflow] = useState(agentWorkflows[0]); const agentRef = useRef(null); const [agentDropdown, setAgentDropdown] = useState(false); const exitCriteria = ["No exit criterion", "System defined", "User defined", "Number of steps/tasks"] const [exitCriterion, setExitCriterion] = useState(exitCriteria[0]); const exitRef = useRef(null); const [exitDropdown, setExitDropdown] = useState(false); const [stepTime, setStepTime] = useState(500); const rollingRef = useRef(null); const [rollingDropdown, setRollingDropdown] = useState(false); const [selectedKnowledge, setSelectedKnowledge] = useState(''); const [selectedKnowledgeId, setSelectedKnowledgeId] = useState(null); const knowledgeRef = useRef(null); const [knowledgeDropdown, setKnowledgeDropdown] = useState(false); const databases = ["Pinecone"] const [database, setDatabase] = useState(databases[0]); const databaseRef = useRef(null); const [databaseDropdown, setDatabaseDropdown] = useState(false); const permissions = ["God Mode", "RESTRICTED (Will ask for permission before using any tool)"] const [permission, setPermission] = useState(permissions[0]); const permissionRef = useRef(null); const [permissionDropdown, setPermissionDropdown] = useState(false); const [selectedTools, setSelectedTools] = useState([]); const [toolNames, setToolNames] = useState(['SearxSearch', 'Read File', 'Write File']); const toolkitRef = useRef(null); const [toolkitDropdown, setToolkitDropdown] = useState(false); const [hasAPIkey, setHasAPIkey] = useState(false); const [createDropdown, setCreateDropdown] = useState(false); const [createModal, setCreateModal] = useState(false); const [scheduleData, setScheduleData] = useState(null); const [editModal, setEditModal] = useState(false) const [editButtonClicked, setEditButtonClicked] = useState(false); const [dropdown, setDropdown] = useState(false); const [publishModal, setPublishModal] = useState(false); useEffect(() => { getOrganisationConfig(organisationId, "model_api_key") .then((response) => { console.log(response.data['api_key']) const apiKey = response.data['api_key'] setHasAPIkey(!(apiKey === null)); }) .catch((error) => { console.error('Error fetching project:', error); }); }, [organisationId]); const filterToolsByNames = () => { if (toolkitList) { const selectedToolIds = toolkits .flatMap(toolkit => toolkit.tools) .filter(tool => toolNames.includes(tool.name)) .map(tool => tool.id); setLocalStorageArray("tool_ids_" + String(internalId), selectedToolIds, setSelectedTools); } }; const handleIterationChange = (event) => { setLocalStorageValue("agent_iterations_" + String(internalId), parseInt(event.target.value), setIterations); }; useEffect(() => { filterToolsByNames(); }, [toolNames]); useEffect(() => { fetchModels() .then((response) => { const models = response.data.map(model => model.name) || []; const selected_model = localStorage.getItem("agent_model_" + String(internalId)) || ''; setModelsArray(models); if (models.length > 0 && !selected_model) { setLocalStorageValue("agent_model_" + String(internalId), models[0], setModel); } else { setModel(selected_model); } console.log(response) }) .catch((error) => { console.error('Error fetching models:', error); }); getAgentWorkflows() .then((response) => { const agentWorkflows = response.data || []; const selectedAgentWorkflow = localStorage.getItem("agent_workflow_" + String(internalId)) || ''; setAgentWorkflows(agentWorkflows); if (agentWorkflows.length > 0 && !selectedAgentWorkflow) { setLocalStorageValue("agent_workflow_" + String(internalId), agentWorkflows[0], setAgentWorkflow); } else { setAgentWorkflow(selectedAgentWorkflow); } }) .catch((error) => { console.error('Error fetching agent workflows:', error); }); if (edit) { editingAgent(); } if (template !== null) { fillDetails(template) setLocalStorageValue("agent_template_id_" + String(internalId), template.id, setAgentTemplateId); fetchAgentTemplateConfigLocal(template.id) .then((response) => { const data = response.data || []; fillAdvancedDetails(data) setLocalStorageArray("tool_names_" + String(internalId), data.tools, setToolNames); setLocalStorageValue("is_agent_template_" + String(internalId), true, setShowButton); setShowButton(true); }) .catch((error) => { console.error('Error fetching template details:', error); }); } }, []); useEffect(() => { function handleClickOutside(event) { if (modelRef.current && !modelRef.current.contains(event.target)) { setModelDropdown(false) } if (agentRef.current && !agentRef.current.contains(event.target)) { setAgentDropdown(false) } if (exitRef.current && !exitRef.current.contains(event.target)) { setExitDropdown(false) } if (rollingRef.current && !rollingRef.current.contains(event.target)) { setRollingDropdown(false) } if (knowledgeRef.current && !knowledgeRef.current.contains(event.target)) { setKnowledgeDropdown(false) } if (databaseRef.current && !databaseRef.current.contains(event.target)) { setDatabaseDropdown(false) } if (permissionRef.current && !permissionRef.current.contains(event.target)) { setPermissionDropdown(false) } if (toolkitRef.current && !toolkitRef.current.contains(event.target)) { setToolkitDropdown(false) } } document.addEventListener('mousedown', handleClickOutside); return () => { document.removeEventListener('mousedown', handleClickOutside); }; }, []); const addTool = (tool) => { if (!selectedTools.includes(tool.id) && !toolNames.includes(tool.name)) { const updatedToolIds = [...selectedTools, tool.id]; setLocalStorageArray("tool_ids_" + String(internalId), updatedToolIds, setSelectedTools); const updatedToolNames = [...toolNames, tool.name]; setLocalStorageArray("tool_names_" + String(internalId), updatedToolNames, setToolNames); } setSearchValue(''); }; const editingAgent = () => { const isLoaded = localStorage.getItem('is_editing_agent_' + String(internalId)); const agent = agents.find(agent => agent.id === editAgentId); if (!isLoaded) { fillDetails(agent) } getAgentDetails(editAgentId, -1) .then((response) => { const data = response.data || [] if (!isLoaded) { fillAdvancedDetails(data) setLocalStorageArray("tool_names_" + String(internalId), data.tools.map(tool => tool.name), setToolNames); } }) .catch((error) => { console.error('Error fetching agent details:', error); }); localStorage.setItem('is_editing_agent_' + String(internalId), true); }; const fillDetails = (agent) => { setLocalStorageValue("agent_name_" + String(internalId), agent.name, setAgentName); setLocalStorageValue("agent_description_" + String(internalId), agent.description, setAgentDescription); setLocalStorageValue("advanced_options_" + String(internalId), true, setAdvancedOptions); } const fillAdvancedDetails = (data) => { setLocalStorageArray("agent_goals_" + String(internalId), data.goal, setGoals); setLocalStorageValue("agent_workflow_" + String(internalId), data.agent_workflow, setAgentWorkflow); setLocalStorageArray("agent_constraints_" + String(internalId), data.constraints, setConstraints); setLocalStorageValue("agent_iterations_" + String(internalId), data.max_iterations, setIterations); setLocalStorageValue("agent_step_time_" + String(internalId), data.iteration_interval, setStepTime); setLocalStorageValue("agent_permission_" + String(internalId), data.permission_type, setPermission); setLocalStorageArray("agent_instructions_" + String(internalId), data.instruction, setInstructions); setLocalStorageValue("agent_database_" + String(internalId), data.LTM_DB, setDatabase); setLocalStorageValue("agent_model_" + String(internalId), data.model, setModel); } const addToolkit = (toolkit) => { const updatedToolIds = [...selectedTools]; const updatedToolNames = [...toolNames]; toolkit.tools.map((tool) => { if (!selectedTools.includes(tool.id) && !toolNames.includes(tool.name)) { updatedToolIds.push(tool.id); updatedToolNames.push(tool.name); } }); setLocalStorageArray("tool_ids_" + String(internalId), updatedToolIds, setSelectedTools); setLocalStorageArray("tool_names_" + String(internalId), updatedToolNames, setToolNames); setSearchValue(''); } const removeTool = (indexToDelete) => { const updatedToolIds = [...selectedTools]; updatedToolIds.splice(indexToDelete, 1); setLocalStorageArray("tool_ids_" + String(internalId), updatedToolIds, setSelectedTools); const updatedToolNames = [...toolNames]; updatedToolNames.splice(indexToDelete, 1); setLocalStorageArray("tool_names_" + String(internalId), updatedToolNames, setToolNames); }; const handlePermissionSelect = (index) => { setLocalStorageValue("agent_permission_" + String(internalId), permissions[index], setPermission); setPermissionDropdown(false); }; const handleDatabaseSelect = (index) => { setLocalStorageValue("agent_database_" + String(internalId), databases[index], setDatabase); setDatabaseDropdown(false); }; const handleKnowledgeSelect = (index) => { setLocalStorageValue("agent_knowledge_" + String(internalId), knowledge[index].name, setSelectedKnowledge); setLocalStorageValue("agent_knowledge_id_" + String(internalId), knowledge[index].id, setSelectedKnowledgeId); setKnowledgeDropdown(false); }; const handleStepChange = (event) => { setLocalStorageValue("agent_step_time_" + String(internalId), event.target.value, setStepTime); }; const handleExitSelect = (index) => { setLocalStorageValue("agent_exit_criterion_" + String(internalId), exitCriteria[index], setExitCriterion); setExitDropdown(false); }; const handleAgentSelect = (index) => { setLocalStorageValue("agent_workflow_" + String(internalId), agentWorkflows[index], setAgentWorkflow); setAgentDropdown(false); }; const handleModelSelect = (index) => { setLocalStorageValue("agent_model_" + String(internalId), modelsArray[index], setModel); if (modelsArray[index] === "google-palm-bison-001" || modelsArray[index] === "replicate-llama13b-v2-chat") { setAgentType("Fixed Task Queue") } setModelDropdown(false); }; const handleGoalChange = (index, newValue) => { const updatedGoals = [...goals]; updatedGoals[index] = newValue; setLocalStorageArray("agent_goals_" + String(internalId), updatedGoals, setGoals); }; const handleInstructionChange = (index, newValue) => { const updatedInstructions = [...instructions]; updatedInstructions[index] = newValue; setLocalStorageArray("agent_instructions_" + String(internalId), updatedInstructions, setInstructions); }; const handleConstraintChange = (index, newValue) => { const updatedConstraints = [...constraints]; updatedConstraints[index] = newValue; setLocalStorageArray("agent_constraints_" + String(internalId), updatedConstraints, setConstraints); }; const handleGoalDelete = (index) => { const updatedGoals = [...goals]; updatedGoals.splice(index, 1); setLocalStorageArray("agent_goals_" + String(internalId), updatedGoals, setGoals); }; const handleInstructionDelete = (index) => { const updatedInstructions = [...instructions]; updatedInstructions.splice(index, 1); setLocalStorageArray("agent_instructions_" + String(internalId), updatedInstructions, setInstructions); }; const handleConstraintDelete = (index) => { const updatedConstraints = [...constraints]; updatedConstraints.splice(index, 1); setLocalStorageArray("agent_constraints_" + String(internalId), updatedConstraints, setConstraints); }; const addGoal = () => { setLocalStorageArray("agent_goals_" + String(internalId), [...goals, 'new goal'], setGoals); }; const addInstruction = () => { setLocalStorageArray("agent_instructions_" + String(internalId), [...instructions, 'new instructions'], setInstructions); }; const addConstraint = () => { setLocalStorageArray("agent_constraints_" + String(internalId), [...constraints, 'new constraint'], setConstraints); }; const handleNameChange = (event) => { setLocalStorageValue("agent_name_" + String(internalId), event.target.value, setAgentName); }; const handleDescriptionChange = (event) => { setLocalStorageValue("agent_description_" + String(internalId), event.target.value, setAgentDescription); }; const closeCreateModal = () => { setCreateModal(false); setCreateDropdown(false); }; function uploadResource(agentId, fileData) { const formData = new FormData(); formData.append('file', fileData.file); formData.append('name', fileData.name); formData.append('size', fileData.size); formData.append('type', fileData.type); return uploadFile(agentId, formData); } useEffect(() => { const keySet = (eventData) => { setHasAPIkey(true); }; const handleAgentScheduling = (item) => { setScheduleData(item) }; EventBus.on('keySet', keySet); EventBus.on('handleAgentScheduling', handleAgentScheduling); return () => { EventBus.off('keySet', keySet); EventBus.off('handleAgentScheduling', handleAgentScheduling); }; }); useEffect(() => { if (scheduleData) { handleAddAgent() } }, [scheduleData]); const validateAgentData = (isNewAgent) => { if (isNewAgent && !hasAPIkey) { toast.error("Your API key is empty!", {autoClose: 1800}); openNewTab(-3, "Settings", "Settings", false); return false; } if (agentName?.replace(/\s/g, '') === '') { toast.error("Agent name can't be blank", {autoClose: 1800}); return false; } if (agentDescription?.replace(/\s/g, '') === '') { toast.error("Agent description can't be blank", {autoClose: 1800}); return false; } const isEmptyGoal = goals.some((goal) => goal.replace(/\s/g, '') === ''); if (isEmptyGoal) { toast.error("Goal can't be empty", {autoClose: 1800}); return false; } if (selectedTools.length <= 0) { toast.error("Add atleast one tool", {autoClose: 1800}); return false; } if (!modelsArray.includes(model)) { toast.error("Your key does not have access to the selected model", {autoClose: 1800}); return false; } if (toolNames.includes('Knowledge Search') && !selectedKnowledge) { toast.error("Add atleast one knowledge", {autoClose: 1800}); return; } return true; } const handleAddAgent = async () => { if (!validateAgentData(true)) { return; } setCreateClickable(false); const agentData = setAgentData() const scheduleAgentData = { "agent_config": agentData, "schedule": scheduleData, } if(edit){ if (editButtonClicked) return; setEditButtonClicked(true); agentData.agent_id = editAgentId; const name = agentData.name const adjustedDate = new Date((new Date()).getTime()); const formattedDate = `${adjustedDate.getDate()} ${['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][adjustedDate.getMonth()]} ${adjustedDate.getFullYear()} ${adjustedDate.getHours().toString().padStart(2, '0')}:${adjustedDate.getMinutes().toString().padStart(2, '0')}`; agentData.name = "Run " + formattedDate addAgentRun(agentData) .then((response) => { if(response){ fetchAgents(); uploadResources(editAgentId, name) } }) } else { createAgent(createModal ? scheduleAgentData : agentData, createModal) .then((response) => { const agentId = response.data.id; const name = response.data.name; const executionId = response.data.execution_id; fetchAgents(); getUserClick('Agent Created Successfully', {'templateName': template?.id ? template.name : ''}) getUserClick('Agent Run created successfully', {}) uploadResources(agentId, name, executionId) }) .catch((error) => { console.error('Error creating agent:', error); setCreateClickable(true); }); } }; const setAgentData= () => { let permission_type = permission; if (permission.includes("RESTRICTED")) { permission_type = "RESTRICTED"; } const agentData = { "name": agentName, "project_id": selectedProjectId, "description": agentDescription, "goal": goals, "instruction": instructions, "agent_workflow": agentWorkflow, "constraints": constraints, "toolkits": [], "tools": selectedTools, "exit": exitCriterion, "iteration_interval": stepTime, "model": model, "max_iterations": maxIterations, "permission_type": permission_type, "LTM_DB": longTermMemory ? database : null, "user_timezone": getUserTimezone(), "knowledge": toolNames.includes('Knowledge Search') ? selectedKnowledgeId : null, }; return agentData } const uploadResources = (agentId, name, executionId) => { if (addResources && input.length > 0) { const uploadPromises = input.map(fileData => { return uploadResource(agentId, fileData) .catch(error => { console.error('Error uploading resource:', error); return Promise.reject(error); }); }); Promise.all(uploadPromises) .then(() => { runDecision(agentId, name, executionId) }) .catch(error => { console.error('Error uploading files:', error); setCreateClickable(true); }); } else { runDecision(agentId, name, executionId) } } const runDecision = (agentId, name, executionId) => { if(edit){ setEditModal(false) sendAgentData({ id: editAgentId, name: name, contentType: "Agents", }); removeTab(editAgentId, name, "Agents", internalId) } else { runExecution(agentId, name, executionId, createModal); } } const finaliseAgentCreation = (agentId, name, executionId) => { toast.success('Agent created successfully', {autoClose: 1800}); let timeoutValue = executionId ? 0 : 1500; setTimeout(() => { sendAgentData({ id: agentId, name: name, contentType: "Agents", execution_id: executionId, internalId: createInternalId() }); setCreateClickable(true); setCreateModal(false); }, timeoutValue) } function runExecution(agentId, name, executionId, createModal) { if (createModal) { finaliseAgentCreation(agentId, name, null); return; } updateExecution(executionId, {"status": 'RUNNING'}) .then((response) => { finaliseAgentCreation(agentId, name, executionId); }) .catch((error) => { setCreateClickable(true); console.error('Error updating execution:', error); }); } const toggleToolkit = (e, id) => { e.stopPropagation(); const toolkitToUpdate = toolkitList.find(toolkit => toolkit.id === id); if (toolkitToUpdate) { const newOpenValue = !toolkitToUpdate.isOpen; setToolkitOpen(id, newOpenValue); } }; const setToolkitOpen = (id, isOpen) => { const updatedToolkits = toolkitList.map(toolkit => toolkit.id === id ? {...toolkit, isOpen: isOpen} : {...toolkit, isOpen: false} ); setToolkitList(updatedToolkits); }; const clearTools = (e) => { e.stopPropagation(); setLocalStorageArray("tool_names_" + String(internalId), [], setToolNames); setLocalStorageArray("tool_ids_" + String(internalId), [], setSelectedTools); }; const handleFileInputChange = (event) => { const files = event.target.files; setFileData(files); }; const handleDropAreaClick = () => { fileInputRef.current.click(); }; const handleDragEnter = (event) => { event.preventDefault(); setIsDragging(true); }; const handleDragLeave = () => { setIsDragging(false); }; const handleDragOver = (event) => { event.preventDefault(); }; function updateTemplate() { if (!validateAgentData(false)) return; let permission_type = permission; if (permission.includes("RESTRICTED")) { permission_type = "RESTRICTED"; } const agentTemplateConfigData = { "goal": goals, "instruction": instructions, "agent_workflow": agentWorkflow, "constraints": constraints, "tools": toolNames, "exit": exitCriterion, "iteration_interval": stepTime, "model": model, "max_iterations": maxIterations, "permission_type": permission_type, "LTM_DB": longTermMemory ? database : null, } const editTemplateData = { "name": agentName, "description": agentDescription, "agent_configs": agentTemplateConfigData } editAgentTemplate(agentTemplateId, editTemplateData) .then((response) => { if (response.status === 200) { toast.success('Agent template has been updated successfully!', {autoClose: 1800}); } }) .catch((error) => { toast.error("Error updating agent template") console.error('Error updating agent template:', error); }); }; function setFileData(files) { if (files.length > 0) { const fileData = { "file": files[0], "name": files[0].name, "size": files[0].size, "type": files[0].type, }; const updatedFiles = [...input, fileData]; setLocalStorageArray('agent_files_' + String(internalId), updatedFiles, setInput); } } function checkSelectedToolkit(toolkit) { const toolIds = toolkit.tools.map((tool) => tool.id); const toolNameList = toolkit.tools.map((tool) => tool.name); return toolIds.every((toolId) => selectedTools.includes(toolId)) && toolNameList.every((toolName) => toolNames.includes(toolName)); } const handleDrop = (event) => { event.preventDefault(); setIsDragging(false); const files = event.dataTransfer.files; setFileData(files); }; const removeFile = (index) => { const updatedFiles = input.filter((file) => input.indexOf(file) !== index); setLocalStorageArray('agent_files_' + String(internalId), updatedFiles, setInput); }; useEffect(() => { if (internalId !== null) { const has_resource = localStorage.getItem("has_resource_" + String(internalId)) || 'true'; if (has_resource) { setAddResources(JSON.parse(has_resource)); } const has_LTM = localStorage.getItem("has_LTM_" + String(internalId)) || 'true'; if (has_LTM) { setLongTermMemory(JSON.parse(has_LTM)); } const advanced_options = localStorage.getItem("advanced_options_" + String(internalId)) || 'false'; if (advanced_options) { setAdvancedOptions(JSON.parse(advanced_options)); } const is_agent_template = localStorage.getItem("is_agent_template_" + String(internalId)); if (is_agent_template) { setShowButton(true); } const agent_name = localStorage.getItem("agent_name_" + String(internalId)); if (agent_name) { setAgentName(agent_name); } const agent_template_id = localStorage.getItem("agent_template_id_" + String(internalId)); if (agent_template_id) { setAgentTemplateId(agent_template_id) } const agent_description = localStorage.getItem("agent_description_" + String(internalId)); if (agent_description) { setAgentDescription(agent_description); } const agent_goals = localStorage.getItem("agent_goals_" + String(internalId)); if (agent_goals) { setGoals(JSON.parse(agent_goals)); } const tool_ids = localStorage.getItem("tool_ids_" + String(internalId)); if (tool_ids) { setSelectedTools(JSON.parse(tool_ids)); } const tool_names = localStorage.getItem("tool_names_" + String(internalId)); if (tool_names) { setToolNames(JSON.parse(tool_names)); } const agent_instructions = localStorage.getItem("agent_instructions_" + String(internalId)); if (agent_instructions) { setInstructions(JSON.parse(agent_instructions)); } const agent_constraints = localStorage.getItem("agent_constraints_" + String(internalId)); if (agent_constraints) { setConstraints(JSON.parse(agent_constraints)); } const agent_model = localStorage.getItem("agent_model_" + String(internalId)); if (agent_model) { setModel(agent_model); } const agent_workflow = localStorage.getItem("agent_workflow_" + String(internalId)); if (agent_workflow) { setAgentWorkflow(agent_workflow); } const agent_database = localStorage.getItem("agent_database_" + String(internalId)); if (agent_database) { setDatabase(agent_database); } const agent_permission = localStorage.getItem("agent_permission_" + String(internalId)); if (agent_permission) { setPermission(agent_permission); } const exit_criterion = localStorage.getItem("agent_exit_criterion_" + String(internalId)); if (exit_criterion) { setExitCriterion(exit_criterion); } const iterations = localStorage.getItem("agent_iterations_" + String(internalId)); if (iterations) { setIterations(Number(iterations)); } const step_time = localStorage.getItem("agent_step_time_" + String(internalId)); if (step_time) { setStepTime(Number(step_time)); } const agent_files = localStorage.getItem("agent_files_" + String(internalId)); if (agent_files) { setInput(JSON.parse(agent_files)); } } const agent_knowledge = localStorage.getItem("agent_knowledge_" + String(internalId)); if (agent_knowledge) { setSelectedKnowledge(agent_knowledge); } }, [internalId]) function openMarketplace() { openNewTab(-4, "Marketplace", "Marketplace", false); localStorage.setItem('marketplace_tab', 'market_knowledge'); } const checkPermissionValidity = (permit) => { if(!(agentWorkflow === 'Fixed Task Workflow' || agentWorkflow === 'Dynamic Task Workflow' || agentWorkflow === 'Goal Based Workflow' ) && permit === 'RESTRICTED (Will ask for permission before using any tool)') return true; else return false; } const openModelMarket = () => { openNewTab(-4, "Marketplace", "Marketplace", false); localStorage.setItem('marketplace_tab', 'market_models'); } const handleAddToMarketplace = () => { const agentData = setAgentData() agentData.agent_template_id = template.id publishTemplateToMarketplace(agentData) .then((response) => { setDropdown(false) setPublishModal(true) }) .catch((error) => { toast.error("Error Publishing to marketplace") console.error('Error Publishing to marketplace:', error); }); } return (<>
{!edit ?
Create new agent
:
Edit agent
}