├── .env.template ├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── assets ├── AutoAgent_Arxiv_2025.pdf ├── AutoAgent_logo.svg ├── agent_editor │ ├── 1-requirement.png │ ├── 2-profiling.png │ ├── 3-profiles.png │ ├── 4-tools.png │ ├── 5-task.png │ └── 6-output-next.png ├── arrow.png ├── autoagent-intro-final.pdf ├── autoagent-intro.pdf ├── autoagent-intro.png ├── autoagent-intro.svg ├── autoagent-wechat.jpg ├── autoagent.png ├── cookies │ ├── export.png │ └── extension.png ├── cover.png ├── paper │ └── metachain_arxiv.pdf ├── rec.png ├── technology-278512.mp3 ├── user_mode │ ├── 4-upload.png │ ├── 5-select.png │ ├── 6-success.png │ ├── input.png │ ├── output.png │ └── select_agent.png ├── video_v1_compressed.mp4 └── workflow_editor │ ├── 1-requirement.png │ ├── 2-profiling.png │ ├── 3-profiles.png │ ├── 4-task.png │ └── 5-output-next.png ├── autoagent ├── __init__.py ├── agents │ ├── __init__.py │ ├── dummy_agent.py │ ├── github_agent.py │ ├── math │ │ ├── math_solver_agent.py │ │ └── vote_aggregator_agent.py │ ├── meta_agent │ │ ├── agent_creator.py │ │ ├── agent_editor.py │ │ ├── agent_former.py │ │ ├── form_complie.py │ │ ├── tool_editor.py │ │ ├── workflow_creator.py │ │ ├── workflow_former.py │ │ └── worklow_form_complie.py │ ├── system_agent │ │ ├── filesurfer_agent.py │ │ ├── programming_agent.py │ │ ├── system_triage_agent.py │ │ └── websurfer_agent.py │ └── tool_retriver_agent.py ├── cli.py ├── cli_utils │ ├── file_select.py │ ├── metachain_meta_agent.py │ └── metachain_meta_workflow.py ├── core.py ├── environment │ ├── __init__.py │ ├── browser_cookies.py │ ├── browser_env.py │ ├── cookie_json │ │ └── README.md │ ├── cookies_data.py │ ├── docker_env.py │ ├── local_env.py │ ├── markdown_browser │ │ ├── __init__.py │ │ ├── abstract_markdown_browser.py │ │ ├── markdown_search.py │ │ ├── mdconvert.py │ │ └── requests_markdown_browser.py │ ├── mdconvert.py │ ├── shutdown_listener.py │ ├── tcp_server.py │ ├── tenacity_stop.py │ └── utils.py ├── flow │ ├── __init__.py │ ├── broker.py │ ├── core.py │ ├── dynamic.py │ ├── types.py │ └── utils.py ├── fn_call_converter.py ├── io_utils.py ├── logger.py ├── main.py ├── memory │ ├── __init__.py │ ├── code_memory.py │ ├── code_tree │ │ └── code_parser.py │ ├── codetree_memory.py │ ├── paper_memory.py │ ├── rag_memory.py │ ├── tool_memory.py │ └── utils.py ├── registry.py ├── repl │ ├── __init__.py │ └── repl.py ├── server.py ├── tcp_server.py ├── tools │ ├── __init__.py │ ├── code_search.py │ ├── dummy_tool.py │ ├── file_surfer_tool.py │ ├── github_client.py │ ├── github_ops.py │ ├── inner.py │ ├── md_obs.py │ ├── meta │ │ ├── edit_agents.py │ │ ├── edit_tools.py │ │ ├── edit_workflow.py │ │ ├── search_tools.py │ │ └── tool_retriever.py │ ├── rag_code.py │ ├── rag_tools.py │ ├── terminal_tools.py │ ├── tool_utils.py │ └── web_tools.py ├── types.py ├── util.py └── workflows │ ├── __init__.py │ └── math_solver_workflow_flow.py ├── constant.py ├── docs ├── .gitignore ├── DOC_STYLE_GUIDE.md ├── README.md ├── babel.config.js ├── docs │ ├── Dev-Guideline │ │ ├── dev-guide-build-your-project.md │ │ ├── dev-guide-create-agent.md │ │ ├── dev-guide-create-tools.md │ │ └── dev-guide-edit-mem.md │ ├── Get-Started │ │ ├── get-started-installation.md │ │ ├── get-started-quickstart.md │ │ └── welcome-to-autoagent.md │ ├── Starter-Projects │ │ ├── starter-projects-agentic-rag.md │ │ ├── starter-projects-auto-deep-research.md │ │ └── starter-projects-nl-to-agent.md │ ├── User-Guideline │ │ ├── user-guide-daily-tasks.md │ │ └── user-guide-how-to-create-agent.md │ └── python │ │ ├── python.md │ │ └── sidebar.json ├── docusaurus.config.ts ├── i18n │ ├── fr │ │ ├── code.json │ │ ├── docusaurus-plugin-content-blog │ │ │ └── options.json │ │ ├── docusaurus-plugin-content-docs │ │ │ ├── current.json │ │ │ └── current │ │ │ │ ├── python │ │ │ │ ├── python.md │ │ │ │ └── sidebar.json │ │ │ │ └── usage │ │ │ │ ├── about.md │ │ │ │ ├── agents.md │ │ │ │ ├── architecture.mdx │ │ │ │ ├── architecture │ │ │ │ ├── backend.mdx │ │ │ │ └── runtime.md │ │ │ │ ├── configuration-options.md │ │ │ │ ├── custom_sandbox_guide.md │ │ │ │ ├── feedback.md │ │ │ │ ├── getting-started.mdx │ │ │ │ ├── how-to │ │ │ │ ├── cli-mode.md │ │ │ │ ├── custom-sandbox-guide.md │ │ │ │ ├── debugging.md │ │ │ │ ├── evaluation-harness.md │ │ │ │ ├── github-action.md │ │ │ │ ├── gui-mode.md │ │ │ │ ├── headless-mode.md │ │ │ │ └── persist-session-data.md │ │ │ │ ├── installation.mdx │ │ │ │ ├── intro.mdx │ │ │ │ ├── llms │ │ │ │ ├── azure-llms.md │ │ │ │ ├── azureLLMs.md │ │ │ │ ├── custom-llm-configs.md │ │ │ │ ├── google-llms.md │ │ │ │ ├── googleLLMs.md │ │ │ │ ├── groq.md │ │ │ │ ├── litellm-proxy.md │ │ │ │ ├── llms.md │ │ │ │ ├── local-llms.md │ │ │ │ ├── localLLMs.md │ │ │ │ ├── openai-llms.md │ │ │ │ └── openrouter.md │ │ │ │ ├── prompting-best-practices.md │ │ │ │ ├── prompting │ │ │ │ ├── customization.md │ │ │ │ ├── microagents.md │ │ │ │ └── prompting-best-practices.md │ │ │ │ ├── runtimes.md │ │ │ │ ├── troubleshooting │ │ │ │ └── troubleshooting.md │ │ │ │ └── upgrade-guide.md │ │ └── docusaurus-theme-classic │ │ │ └── navbar.json │ └── zh-Hans │ │ ├── code.json │ │ ├── docusaurus-plugin-content-blog │ │ └── options.json │ │ ├── docusaurus-plugin-content-docs │ │ ├── current.json │ │ └── current │ │ │ ├── python │ │ │ ├── python.md │ │ │ └── sidebar.json │ │ │ └── usage │ │ │ ├── about.md │ │ │ ├── agents.md │ │ │ ├── architecture.mdx │ │ │ ├── architecture │ │ │ ├── backend.mdx │ │ │ └── runtime.md │ │ │ ├── configuration-options.md │ │ │ ├── custom_sandbox_guide.md │ │ │ ├── feedback.md │ │ │ ├── getting-started.mdx │ │ │ ├── how-to │ │ │ ├── cli-mode.md │ │ │ ├── custom-sandbox-guide.md │ │ │ ├── debugging.md │ │ │ ├── evaluation-harness.md │ │ │ ├── github-action.md │ │ │ ├── gui-mode.md │ │ │ ├── headless-mode.md │ │ │ └── persist-session-data.md │ │ │ ├── installation.mdx │ │ │ ├── intro.mdx │ │ │ ├── llms │ │ │ ├── azure-llms.md │ │ │ ├── azureLLMs.md │ │ │ ├── google-llms.md │ │ │ ├── googleLLMs.md │ │ │ ├── groq.md │ │ │ ├── litellm-proxy.md │ │ │ ├── llms.md │ │ │ ├── local-llms.md │ │ │ ├── localLLMs.md │ │ │ ├── openai-llms.md │ │ │ └── openrouter.md │ │ │ ├── prompting-best-practices.md │ │ │ ├── prompting │ │ │ ├── customization.md │ │ │ ├── microagents.md │ │ │ └── prompting-best-practices.md │ │ │ ├── runtimes.md │ │ │ ├── troubleshooting │ │ │ └── troubleshooting.md │ │ │ └── upgrade-guide.md │ │ └── docusaurus-theme-classic │ │ └── navbar.json ├── package-lock.json ├── package.json ├── plugins │ └── tailwind-config.cjs ├── sidebars.ts ├── src │ ├── components │ │ ├── CustomFooter.tsx │ │ ├── Demo │ │ │ ├── Demo.tsx │ │ │ └── index.module.css │ │ ├── Footer │ │ │ ├── Footer.css │ │ │ └── Footer.tsx │ │ ├── HomepageHeader │ │ │ └── HomepageHeader.tsx │ │ └── KeyFeatures │ │ │ ├── KeyFeatures.css │ │ │ └── KeyFeatures.tsx │ ├── css │ │ ├── custom.css │ │ ├── footer.css │ │ └── homepageHeader.css │ ├── pages │ │ ├── _footer.tsx │ │ └── index.tsx │ └── theme │ │ └── Layout │ │ └── index.tsx ├── static │ ├── .nojekyll │ └── img │ │ ├── autoagent-intro.svg │ │ ├── discord.svg │ │ ├── github.svg │ │ ├── metachain_logo.svg │ │ ├── slack.svg │ │ └── video_v1_compressed.mp4 ├── translation_cache.json ├── translation_updater.py ├── tsconfig.json └── yarn.lock ├── evaluation ├── README.md ├── gaia │ ├── get_score.py │ ├── run_infer.py │ ├── scorer.py │ ├── scripts │ │ └── run_infer.sh │ └── test_imaes.py ├── math500 │ ├── get_score.py │ ├── prompts.py │ └── run_infer.py ├── multihoprag │ ├── result.json │ ├── run_rag.py │ └── scripts │ │ └── run_rag.sh ├── types.py └── utils.py ├── loop_utils └── font_page.py ├── process_tool_docs.py ├── pyproject.toml ├── setup.cfg └── tool_docs.csv /.env.template: -------------------------------------------------------------------------------- 1 | # Required Github Tokens 2 | GITHUB_AI_TOKEN= 3 | 4 | # Optional API Keys 5 | OPENAI_API_KEY= 6 | DEEPSEEK_API_KEY= 7 | ANTHROPIC_API_KEY= 8 | GEMINI_API_KEY= 9 | HUGGINGFACE_API_KEY= 10 | GROQ_API_KEY= 11 | XAI_API_KEY= 12 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # *.mp4 filter=lfs diff=lfs merge=lfs -text 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | workplace_*/ 2 | workspace_*/ 3 | *.log 4 | code_db/* 5 | results/* 6 | 7 | __pycache__/ 8 | tmp/* 9 | logs/* 10 | *.tar.gz 11 | 12 | *.egg-info 13 | 14 | .DS_Store 15 | *.csv 16 | 17 | eval_data/* 18 | evaluation_results/* 19 | casestudy_results/* 20 | 21 | evaluation/*/data/ 22 | evaluation/*/data/* 23 | evaluation/**/data/ 24 | 25 | .env 26 | 27 | terminal_tmp/* 28 | 29 | !tool_docs.csv 30 | 31 | .port* 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright © 2023 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated documentation 8 | files (the “Software”), to deal in the Software without 9 | restriction, including without limitation the rights to use, 10 | copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the 12 | Software is furnished to do so, subject to the following 13 | conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | OTHER DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /assets/AutoAgent_Arxiv_2025.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/AutoAgent_Arxiv_2025.pdf -------------------------------------------------------------------------------- /assets/agent_editor/1-requirement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/agent_editor/1-requirement.png -------------------------------------------------------------------------------- /assets/agent_editor/2-profiling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/agent_editor/2-profiling.png -------------------------------------------------------------------------------- /assets/agent_editor/3-profiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/agent_editor/3-profiles.png -------------------------------------------------------------------------------- /assets/agent_editor/4-tools.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/agent_editor/4-tools.png -------------------------------------------------------------------------------- /assets/agent_editor/5-task.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/agent_editor/5-task.png -------------------------------------------------------------------------------- /assets/agent_editor/6-output-next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/agent_editor/6-output-next.png -------------------------------------------------------------------------------- /assets/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/arrow.png -------------------------------------------------------------------------------- /assets/autoagent-intro-final.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/autoagent-intro-final.pdf -------------------------------------------------------------------------------- /assets/autoagent-intro.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/autoagent-intro.pdf -------------------------------------------------------------------------------- /assets/autoagent-intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/autoagent-intro.png -------------------------------------------------------------------------------- /assets/autoagent-wechat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/autoagent-wechat.jpg -------------------------------------------------------------------------------- /assets/autoagent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/autoagent.png -------------------------------------------------------------------------------- /assets/cookies/export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/cookies/export.png -------------------------------------------------------------------------------- /assets/cookies/extension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/cookies/extension.png -------------------------------------------------------------------------------- /assets/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/cover.png -------------------------------------------------------------------------------- /assets/paper/metachain_arxiv.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/paper/metachain_arxiv.pdf -------------------------------------------------------------------------------- /assets/rec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/rec.png -------------------------------------------------------------------------------- /assets/technology-278512.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/technology-278512.mp3 -------------------------------------------------------------------------------- /assets/user_mode/4-upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/user_mode/4-upload.png -------------------------------------------------------------------------------- /assets/user_mode/5-select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/user_mode/5-select.png -------------------------------------------------------------------------------- /assets/user_mode/6-success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/user_mode/6-success.png -------------------------------------------------------------------------------- /assets/user_mode/input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/user_mode/input.png -------------------------------------------------------------------------------- /assets/user_mode/output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/user_mode/output.png -------------------------------------------------------------------------------- /assets/user_mode/select_agent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/user_mode/select_agent.png -------------------------------------------------------------------------------- /assets/video_v1_compressed.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/video_v1_compressed.mp4 -------------------------------------------------------------------------------- /assets/workflow_editor/1-requirement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/workflow_editor/1-requirement.png -------------------------------------------------------------------------------- /assets/workflow_editor/2-profiling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/workflow_editor/2-profiling.png -------------------------------------------------------------------------------- /assets/workflow_editor/3-profiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/workflow_editor/3-profiles.png -------------------------------------------------------------------------------- /assets/workflow_editor/4-task.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/workflow_editor/4-task.png -------------------------------------------------------------------------------- /assets/workflow_editor/5-output-next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/assets/workflow_editor/5-output-next.png -------------------------------------------------------------------------------- /autoagent/__init__.py: -------------------------------------------------------------------------------- 1 | from .core import MetaChain 2 | from .types import Agent, Response 3 | # from .workflow import Graph, meta_workflow, FlowEngine 4 | from .flow import default_drive 5 | 6 | import autoagent.workflows 7 | import autoagent.tools 8 | import autoagent.agents 9 | __all__ = ["MetaChain", "Agent", "Response", "default_drive", ] 10 | -------------------------------------------------------------------------------- /autoagent/agents/__init__.py: -------------------------------------------------------------------------------- 1 | # from autoagent.agents.programming_agent import get_programming_agent 2 | # from autoagent.agents.tool_retriver_agent import get_tool_retriver_agent 3 | # from autoagent.agents.agent_check_agent import get_agent_check_agent 4 | # from autoagent.agents.tool_check_agent import get_tool_check_agent 5 | # from autoagent.agents.github_agent import get_github_agent 6 | # from autoagent.agents.programming_triage_agent import get_programming_triage_agent 7 | # from autoagent.agents.plan_agent import get_plan_agent 8 | 9 | # import os 10 | # import importlib 11 | # from autoagent.registry import registry 12 | 13 | # # 获取当前目录下的所有 .py 文件 14 | # current_dir = os.path.dirname(__file__) 15 | # for file in os.listdir(current_dir): 16 | # if file.endswith('.py') and not file.startswith('__'): 17 | # module_name = file[:-3] 18 | # importlib.import_module(f'autoagent.agents.{module_name}') 19 | 20 | # # 导出所有注册的 agent 创建函数 21 | # globals().update(registry.agents) 22 | 23 | # __all__ = list(registry.agents.keys()) 24 | 25 | import os 26 | import importlib 27 | from autoagent.registry import registry 28 | 29 | def import_agents_recursively(base_dir: str, base_package: str): 30 | """Recursively import all agents in .py files 31 | 32 | Args: 33 | base_dir: the root directory to start searching 34 | base_package: the base name of the Python package 35 | """ 36 | for root, dirs, files in os.walk(base_dir): 37 | # get the relative path to the base directory 38 | rel_path = os.path.relpath(root, base_dir) 39 | 40 | for file in files: 41 | if file.endswith('.py') and not file.startswith('__'): 42 | # build the module path 43 | if rel_path == '.': 44 | # in the root directory 45 | module_path = f"{base_package}.{file[:-3]}" 46 | else: 47 | # in the subdirectory 48 | package_path = rel_path.replace(os.path.sep, '.') 49 | module_path = f"{base_package}.{package_path}.{file[:-3]}" 50 | 51 | try: 52 | importlib.import_module(module_path) 53 | except Exception as e: 54 | print(f"Warning: Failed to import {module_path}: {e}") 55 | 56 | # get the current directory and import all agents 57 | current_dir = os.path.dirname(__file__) 58 | import_agents_recursively(current_dir, 'autoagent.agents') 59 | 60 | # export all agent creation functions 61 | globals().update(registry.agents) 62 | globals().update(registry.plugin_agents) 63 | 64 | __all__ = list(registry.agents.keys()) -------------------------------------------------------------------------------- /autoagent/agents/dummy_agent.py: -------------------------------------------------------------------------------- 1 | from autoagent.types import Agent 2 | from autoagent.tools import tool_dummy 3 | from typing import Union 4 | from autoagent.registry import register_plugin_agent # import the register_agent function from the registry 5 | 6 | @register_plugin_agent(name = "Dummy Agent", func_name="get_dummy_agent") # You must register the agent in the registry, otherwise the agent will not be loaded. The name of register_agent is get_xxx_agent. 7 | def get_dummy_agent(model: str): 8 | """ 9 | This is a dummy agent, it's used for demonstrating the usage of the autoagent. 10 | Args: 11 | model: The model to be used for the agent. 12 | Returns: 13 | An agent instance. 14 | """ 15 | def dummy_instructions(context_variables: dict): 16 | """ 17 | The function should take the context_variables as an argument, and return a string. The context_variables is a dictionary, and it's track the important variables of the agent in the whole conversation. 18 | The instructions should be concise and clear, and it's very important for the agent to follow the instructions. 19 | """ 20 | tmp_variables = context_variables.get("tmp_variables", {}) 21 | return f"""...""" 22 | return Agent( 23 | name="Dummy Agent", # The name of the agent, you can change it in different scenes. 24 | model=model, # The default model is gpt-4o-2024-08-06, you can change it to other models if user specified. 25 | instructions="..." or dummy_instructions, # the instructions of the agent, the instructions can be a string or a function that returns a string. If it is a function, the function should take the context_variables as an argument, and return a string. The instructions should be concise and clear, and it's very important for the agent to follow the instructions. 26 | functions=[tool_dummy], # The tools of the agent, you can add different tools in different scenes. 27 | ) 28 | 29 | """ 30 | Form to create an agent: 31 | 32 | agent_name = "Dummy Agent" 33 | agent_description = "This is a dummy agent, it's used for demonstrating the usage of the autoagent." 34 | agent_instructions = "..." | "...{global_variables}..." 35 | agent_tools = [tool_dummy] 36 | """ -------------------------------------------------------------------------------- /autoagent/agents/github_agent.py: -------------------------------------------------------------------------------- 1 | from autoagent.types import Agent 2 | from autoagent.tools import ( 3 | push_changes, submit_pull_request 4 | ) 5 | from autoagent.registry import register_agent 6 | 7 | 8 | @register_agent(name = "Github Agent", func_name="get_github_agent") 9 | def get_github_agent(model: str): 10 | def instructions(context_variables): 11 | return \ 12 | f"""You are an agent that helps user to manage the GitHub repository named 'autoagent'. 13 | The user will give you the suggestion of the changes to be pushed to the repository. 14 | Follow the following routine with the user: 15 | 1. First, use `push_changes` to push the changes to the repository. (If the user want to push all the changes, use `push_changes` with `file_paths=None` as the argument.) 16 | 2. Then, ask the user whether to submit a pull request to a target branch. (If yes, give the `target_branch`) 17 | 3. If the user wants to submit a pull request, use `submit_pull_request` to submit the pull request, if not, just ignore this step. 18 | """ 19 | return Agent( 20 | name="Github Agent", 21 | model=model, 22 | instructions=instructions, 23 | functions=[push_changes, submit_pull_request], 24 | parallel_tool_calls = False 25 | ) 26 | -------------------------------------------------------------------------------- /autoagent/agents/math/math_solver_agent.py: -------------------------------------------------------------------------------- 1 | from autoagent.types import Agent 2 | 3 | from autoagent.registry import register_plugin_agent 4 | 5 | @register_plugin_agent(name="Math Solver Agent", func_name="get_math_solver_agent") 6 | def get_math_solver_agent(model: str): 7 | ''' 8 | This agent solves mathematical problems using analytical and systematic approaches. 9 | ''' 10 | instructions = 'You are responsible for solving mathematical problems using a systematic approach. You should:\n1. Use the provided conditions and objective to formulate a solution strategy\n2. Break down complex problems into smaller steps\n3. Apply appropriate mathematical concepts and formulas\n4. Show clear step-by-step work and explanations\n5. Verify the solution matches the problem requirements' 11 | return Agent( 12 | name="Math Solver Agent", 13 | model=model, 14 | instructions=instructions, 15 | functions=[] 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /autoagent/agents/math/vote_aggregator_agent.py: -------------------------------------------------------------------------------- 1 | from autoagent.types import Agent 2 | 3 | from autoagent.registry import register_plugin_agent 4 | 5 | @register_plugin_agent(name="Vote Aggregator Agent", func_name="get_vote_aggregator_agent") 6 | def get_vote_aggregator_agent(model: str): 7 | ''' 8 | This agent aggregates solutions from different solvers and determines the final answer through majority voting. 9 | ''' 10 | instructions = 'You are a solution aggregator specializing in combining and analyzing multiple solutions to determine the most accurate answer. Your responsibilities include:\n\n1. Carefully review all provided solutions\n2. Compare the reasoning and calculations in each solution\n3. Identify commonalities and differences between solutions\n4. Implement majority voting when solutions differ\n5. Evaluate the confidence level of each solution\n6. Provide justification for the final selected answer\n\nWhen aggregating solutions:\n1. List all solutions received\n2. Compare the approach and methodology used in each\n3. Identify the final answer from each solution\n4. Apply majority voting to determine the consensus\n5. If no clear majority, analyze the reasoning quality to break ties\n6. Present the final selected answer with explanation of the selection process' 11 | return Agent( 12 | name="Vote Aggregator Agent", 13 | model=model, 14 | instructions=instructions, 15 | functions=[] 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /autoagent/agents/meta_agent/agent_editor.py: -------------------------------------------------------------------------------- 1 | from autoagent.registry import register_agent 2 | from autoagent.tools.meta.edit_agents import list_agents, create_agent, delete_agent, run_agent 3 | from autoagent.tools.terminal_tools import execute_command 4 | from autoagent.types import Agent 5 | from autoagent.io_utils import read_file 6 | 7 | @register_agent(name = "Agent Editor Agent", func_name="get_agent_editor_agent") 8 | def get_agent_editor_agent(model: str) -> str: 9 | """ 10 | The agent editor is an agent that can be used to edit the agents. 11 | """ 12 | def instructions(context_variables): 13 | return f"""\ 14 | You are an agent editor agent that can be used to edit the agents. You are working on a Agent framework named MetaChain, and your responsibility is to edit the agents in the MetaChain, so that the agents can be used to help the user with their request. 15 | 16 | The existing agents are shown below: 17 | {list_agents(context_variables)} 18 | 19 | If you want to create a new agent, you should: 20 | 1. follow the format of the `get_dummy_agent` below: 21 | ```python 22 | {read_file('autoagent/agents/dummy_agent.py')} 23 | ``` 24 | 2. you successfully create the agent only after you have successfully run the agent with the `run_agent` function to satisfy the user's request. 25 | 26 | 3. If you encounter any error while creating and running the agent, like dependency missing, you should use the `execute_command` function to install the dependency. 27 | 28 | [IMPORTANT] The `register_plugin_agent` registry function is strictly required for a agent implementation to be recognized by the MetaChain framework. 29 | """ 30 | tool_list = [list_agents, create_agent, delete_agent, run_agent, execute_command] 31 | return Agent( 32 | name="Agent Editor Agent", 33 | model=model, 34 | instructions=instructions, 35 | functions=tool_list, 36 | tool_choice = "required", 37 | parallel_tool_calls = False 38 | ) 39 | -------------------------------------------------------------------------------- /autoagent/agents/system_agent/filesurfer_agent.py: -------------------------------------------------------------------------------- 1 | from autoagent.types import Agent 2 | from autoagent.registry import register_agent 3 | from autoagent.tools import open_local_file, page_up_markdown, page_down_markdown, find_on_page_ctrl_f, find_next, visual_question_answering 4 | from autoagent.tools.file_surfer_tool import with_env 5 | from autoagent.environment.markdown_browser import RequestsMarkdownBrowser 6 | import time 7 | from inspect import signature 8 | from constant import LOCAL_ROOT, DOCKER_WORKPLACE_NAME 9 | @register_agent(name = "File Surfer Agent", func_name="get_filesurfer_agent") 10 | def get_filesurfer_agent(model: str = "gpt-4o", **kwargs): 11 | 12 | def handle_mm_func(tool_name, tool_args): 13 | return f"After using tool `{tool_name}({tool_args})`, I have opened the image I want to see and prepared a question according to the image. Please answer the question based on the image." 14 | def instructions(context_variables): 15 | file_env: RequestsMarkdownBrowser = context_variables.get("file_env", None) 16 | assert file_env is not None, "file_env is required" 17 | return \ 18 | f""" 19 | You are a file surfer agent that can handle local files. 20 | 21 | You can only access the files in the folder `{file_env.docker_workplace}` and when you want to open a file, you should use absolute path from root like `{file_env.docker_workplace}/...`. 22 | 23 | Note that `open_local_file` can read a file as markdown text and ask questions about it. And `open_local_file` can handle the following file extensions: [".html", ".htm", ".xlsx", ".pptx", ".wav", ".mp3", ".flac", ".pdf", ".docx"], and all other types of text files. 24 | 25 | But IT DOES NOT HANDLE IMAGES, you should use `visual_question_answering` to see the image. 26 | 27 | If the converted markdown text has more than 1 page, you can use `page_up`, `page_down`, `find_on_page_ctrl_f`, `find_next` to navigate through the pages. 28 | 29 | When you think you have completed the task the `System Triage Agent` asked you to do, you should use `transfer_back_to_triage_agent` to transfer the conversation back to the `System Triage Agent`. And you should not stop to try to solve the user's request by transferring to `System Triage Agent` only until the task is completed. 30 | 31 | If you are unable to open the file, you can transfer the conversation back to the `System Triage Agent`, and let the `Coding Agent` try to solve the problem by coding. 32 | """ 33 | tool_list = [open_local_file, page_up_markdown, page_down_markdown, find_on_page_ctrl_f, find_next, visual_question_answering] 34 | return Agent( 35 | name="File Surfer Agent", 36 | model=model, 37 | instructions=instructions, 38 | functions=tool_list, 39 | handle_mm_func=handle_mm_func, 40 | tool_choice = "required", 41 | parallel_tool_calls = False 42 | ) 43 | 44 | -------------------------------------------------------------------------------- /autoagent/agents/system_agent/websurfer_agent.py: -------------------------------------------------------------------------------- 1 | from autoagent.types import Agent 2 | from autoagent.registry import register_agent 3 | from autoagent.tools import click, page_down, page_up, history_back, history_forward, web_search, input_text, sleep, visit_url, get_page_markdown 4 | from autoagent.tools.web_tools import with_env 5 | from autoagent.environment.browser_env import BrowserEnv 6 | import time 7 | from constant import DOCKER_WORKPLACE_NAME, LOCAL_ROOT 8 | @register_agent(name = "Web Surfer Agent", func_name="get_websurfer_agent") 9 | def get_websurfer_agent(model: str = "gpt-4o", **kwargs): 10 | 11 | def handle_mm_func(tool_name, tool_args): 12 | return f"After take last action `{tool_name}({tool_args})`, the image of current page is shown below. Please take next action based on the image, the current state of the page as well as previous actions and observations." 13 | def instructions(context_variables): 14 | web_env: BrowserEnv = context_variables.get("web_env", None) 15 | assert web_env is not None, "web_env is required" 16 | return \ 17 | f"""Review the current state of the page and all other information to find the best possible next action to accomplish your goal. Your answer will be interpreted and executed by a program, make sure to follow the formatting instructions. 18 | 19 | Note that if you want to analyze the YouTube video, Wikipedia page, or other pages that contain media content, or you just want to analyze the text content of the page in a more detailed way, you should use `get_page_markdown` tool to convert the page information to markdown text. And when browsing the web, if you have downloaded any files, the path of the downloaded files will be `{web_env.docker_workplace}/downloads`, and you CANNOT open the downloaded files directly, you should transfer back to the `System Triage Agent`, and let `System Triage Agent` to transfer to `File Surfer Agent` to open the downloaded files. 20 | 21 | When you think you have completed the task the `System Triage Agent` asked you to do, you should use `transfer_back_to_triage_agent` to transfer the conversation back to the `System Triage Agent`. And you should not stop to try to solve the user's request by transferring to `System Triage Agent` only until the task is completed. 22 | """ 23 | 24 | tool_list = [click, page_down, page_up, history_back, history_forward, web_search, input_text, sleep, visit_url, get_page_markdown] 25 | return Agent( 26 | name="Web Surfer Agent", 27 | model=model, 28 | instructions=instructions, 29 | functions=tool_list, 30 | handle_mm_func=handle_mm_func, 31 | tool_choice = "required", 32 | parallel_tool_calls = False 33 | ) 34 | 35 | """ 36 | Note that when you need to download something, you should first know the url of the file, and then use the `visit_url` tool to download the file. For example, if you want to download paper from 'https://arxiv.org/abs/2310.13023', you should use `visit_url('url'='https://arxiv.org/pdf/2310.13023.pdf')`. 37 | """ -------------------------------------------------------------------------------- /autoagent/agents/tool_retriver_agent.py: -------------------------------------------------------------------------------- 1 | from autoagent.types import Agent 2 | from autoagent.tools import ( 3 | get_api_plugin_tools_doc 4 | ) 5 | from autoagent.util import make_message, make_tool_message 6 | from autoagent.registry import register_agent 7 | @register_agent(name = "Tool Retriver Agent", func_name="get_tool_retriver_agent") 8 | def get_tool_retriver_agent(model: str): 9 | def instructions(context_variables): 10 | return \ 11 | f""" 12 | You are a tool retriver agent. 13 | You are given a task instruction, and you need to retrieve the tool docs for the task using function `get_tool_doc`. 14 | Note that if you want to complete the task, you may need to use more than one tool, so you should retrieve the tool docs for all the tools you may need. Finally, you should give a merged tool doc consisting of all the tool docs you retrieved, and the implementation code of each tool should be included in the tool doc. 15 | """ 16 | return Agent( 17 | name="Tool Retriver Agent", 18 | model=model, 19 | instructions=instructions, 20 | functions=[get_api_plugin_tools_doc], 21 | ) -------------------------------------------------------------------------------- /autoagent/cli_utils/file_select.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | from tkinter import filedialog 3 | import shutil 4 | import os 5 | from rich.console import Console 6 | 7 | def select_and_copy_files(dest_dir, console: Console, docker_files_dir: str): 8 | # 创建 tkinter 根窗口但隐藏它 9 | root = tk.Tk() 10 | root.withdraw() 11 | 12 | # 打开文件选择对话框 13 | files = filedialog.askopenfilenames( 14 | title='Select files to copy', 15 | filetypes=[ 16 | # ('Text files', '*.txt'), 17 | ('All files', '*.*'), 18 | ('PDF files', '*.pdf'), 19 | ('Docx files', '*.docx'), 20 | ('Txt files', '*.txt'), 21 | ('Zip files', '*.zip'), 22 | ('Text files', '*.txt'), 23 | ] 24 | ) 25 | 26 | if not files: 27 | print("No files selected") 28 | return 29 | 30 | # 选择目标文件夹 31 | # dest_dir = filedialog.askdirectory( 32 | # title='Select destination folder' 33 | # ) 34 | 35 | if not dest_dir: 36 | print("No destination folder selected") 37 | return 38 | 39 | # 复制文件 40 | upload_infos = [] 41 | for file_path in files: 42 | file_name = os.path.basename(file_path) 43 | dest_path = os.path.join(dest_dir, file_name) 44 | docker_dest_path = os.path.join(docker_files_dir, file_name) 45 | try: 46 | shutil.copy2(file_path, dest_path) 47 | msg = f"Uploaded: {file_name} to {docker_dest_path}" 48 | upload_infos.append(msg) 49 | console.print(f"[bold green]{msg}[/bold green]") 50 | except Exception as e: 51 | console.print(f"[bold red]Error uploading {file_name}: {e}[/bold red]") 52 | 53 | console.print(f"[bold green]Successfully uploaded {len(files)} files[/bold green]") 54 | return upload_infos 55 | if __name__ == "__main__": 56 | dest_dir = "/Users/tangjiabin/Documents/reasoning/metachain/workspace_meta_showcase/showcase_nl2agent_showcase/workplace" 57 | select_and_copy_files(dest_dir) -------------------------------------------------------------------------------- /autoagent/environment/__init__.py: -------------------------------------------------------------------------------- 1 | from .docker_env import DockerEnv, DockerConfig 2 | from .local_env import LocalEnv 3 | from .browser_env import BrowserEnv, VIEWPORT 4 | from .markdown_browser import RequestsMarkdownBrowser 5 | from .utils import setup_metachain -------------------------------------------------------------------------------- /autoagent/environment/browser_cookies.py: -------------------------------------------------------------------------------- 1 | import json 2 | from pathlib import Path 3 | import glob 4 | 5 | wd = Path(__file__).parent.resolve() 6 | def load_cookies_from_json(json_path): 7 | with open(json_path, 'r') as f: 8 | cookies = json.load(f) 9 | return cookies 10 | 11 | 12 | def convert_cookies_to_python(): 13 | all_cookies = [] 14 | # cookie_files = [ 15 | # "orcid.org.cookies.json", 16 | # "www.researchgate.net.cookies.json", 17 | # "github.com.cookies.json", 18 | # "www.youtube.com.cookies.json", 19 | # "www.ncbi.nlm.nih.gov.cookies.json", 20 | # "archive.org.cookies.json", 21 | # "nature.com.cookies.json" 22 | # ] 23 | json_dir = wd / "cookie_json" 24 | cookie_files = glob.glob(str(json_dir / "*.json")) 25 | 26 | for cookie_file in cookie_files: 27 | json_path = wd / "cookie_json" / cookie_file 28 | cookies = load_cookies_from_json(json_path) 29 | all_cookies.extend(cookies) 30 | 31 | # 生成Python格式的cookies文件 32 | output_path = wd / "cookies_data.py" 33 | output_str = "COOKIES_LIST = [\n" 34 | for cookie in all_cookies: 35 | output_str += f" {repr(cookie)},\n" 36 | output_str += "]\n" 37 | with open(output_path, "w", encoding="utf-8") as f: 38 | f.write(output_str) 39 | return output_str 40 | 41 | if __name__ == "__main__": 42 | print(convert_cookies_to_python()) -------------------------------------------------------------------------------- /autoagent/environment/cookie_json/README.md: -------------------------------------------------------------------------------- 1 | # How to obtain cookie json files 2 | 3 | ## What are cookies? 4 | Cookies are small pieces of data stored by websites on users' computers, containing information like login status and preferences. They are essential for web automation as they allow automated browsers to maintain authenticated sessions, skip repeated logins, and simulate real user behavior across multiple page visits. 5 | 6 | ## How to organize them in this folder? 7 | We recommend you to use the Google Chrome browser with the extension "Export cookie JSON file for Puppeteer", as show in the following figure: 8 | 9 | ![extension](../../../assets/cookies/extension.png) 10 | 11 | 1. Go to a specific website and login. 12 | 2. Then use the extension to export the cookies, and save it as a json file in the `cookie_json` folder. 13 | 14 | ![export](../../../assets/cookies/export.png) 15 | 16 | 3. After you have exported all cookies, use the following command to convert them to python code: 17 | 18 | ```bash 19 | cd path/to/MetaChain && python autoagent/environment/browser_cookies.py 20 | ``` 21 | 22 | ## Recommended websites 23 | 24 | We recommend you to export the cookies from the following websites: 25 | 26 | - [archive.org](https://archive.org) 27 | - [github.com](https://github.com) 28 | - [nature.com](https://nature.com) 29 | - [orcid.org](https://orcid.org) 30 | - [www.collinsdictionary.com](https://www.collinsdictionary.com) 31 | - [www.jstor.org](https://www.jstor.org) 32 | - [www.ncbi.nlm.nih.gov](https://www.ncbi.nlm.nih.gov) 33 | - [www.pnas.org](https://www.pnas.org) 34 | - [www.reddit.com](https://www.reddit.com) 35 | - [www.researchgate.net](https://www.researchgate.net) 36 | - [www.youtube.com](https://www.youtube.com) 37 | -------------------------------------------------------------------------------- /autoagent/environment/cookies_data.py: -------------------------------------------------------------------------------- 1 | COOKIES_LIST = [ 2 | ] 3 | -------------------------------------------------------------------------------- /autoagent/environment/markdown_browser/__init__.py: -------------------------------------------------------------------------------- 1 | from .abstract_markdown_browser import AbstractMarkdownBrowser 2 | from .markdown_search import AbstractMarkdownSearch, BingMarkdownSearch 3 | 4 | # TODO: Fix mdconvert 5 | from .mdconvert import ( # type: ignore 6 | DocumentConverterResult, 7 | FileConversionException, 8 | MarkdownConverter, 9 | UnsupportedFormatException, 10 | ) 11 | from .requests_markdown_browser import RequestsMarkdownBrowser 12 | 13 | __all__ = ( 14 | "AbstractMarkdownBrowser", 15 | "RequestsMarkdownBrowser", 16 | "AbstractMarkdownSearch", 17 | "BingMarkdownSearch", 18 | "MarkdownConverter", 19 | "UnsupportedFormatException", 20 | "FileConversionException", 21 | "DocumentConverterResult", 22 | ) 23 | -------------------------------------------------------------------------------- /autoagent/environment/markdown_browser/abstract_markdown_browser.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | from typing import Union 3 | 4 | 5 | class AbstractMarkdownBrowser(ABC): 6 | """ 7 | An abstract class for a Markdown web browser. 8 | 9 | All MarkdownBrowers work by: 10 | 11 | (1) fetching a web page by URL (via requests, Selenium, Playwright, etc.) 12 | (2) converting the page's HTML or DOM to Markdown 13 | (3) operating on the Markdown 14 | 15 | Such browsers are simple, and suitable for read-only agentic use. 16 | They cannot be used to interact with complex web applications. 17 | """ 18 | 19 | @abstractmethod 20 | def __init__(self) -> None: 21 | pass 22 | 23 | @property 24 | @abstractmethod 25 | def address(self) -> str: 26 | pass 27 | 28 | @abstractmethod 29 | def set_address(self, uri_or_path: str) -> None: 30 | pass 31 | 32 | @property 33 | @abstractmethod 34 | def viewport(self) -> str: 35 | pass 36 | 37 | @property 38 | @abstractmethod 39 | def page_content(self) -> str: 40 | pass 41 | 42 | @abstractmethod 43 | def page_down(self) -> None: 44 | pass 45 | 46 | @abstractmethod 47 | def page_up(self) -> None: 48 | pass 49 | 50 | @abstractmethod 51 | def visit_page(self, path_or_uri: str) -> str: 52 | pass 53 | 54 | @abstractmethod 55 | def open_local_file(self, local_path: str) -> str: 56 | pass 57 | 58 | @abstractmethod 59 | def find_on_page(self, query: str) -> Union[str, None]: 60 | pass 61 | 62 | @abstractmethod 63 | def find_next(self) -> Union[str, None]: 64 | pass 65 | -------------------------------------------------------------------------------- /autoagent/environment/shutdown_listener.py: -------------------------------------------------------------------------------- 1 | """ 2 | This module monitors the app for shutdown signals 3 | """ 4 | 5 | import asyncio 6 | import signal 7 | import threading 8 | import time 9 | from types import FrameType 10 | 11 | from uvicorn.server import HANDLED_SIGNALS 12 | 13 | _should_exit = None 14 | 15 | 16 | def _register_signal_handler(sig: signal.Signals): 17 | original_handler = None 18 | 19 | def handler(sig_: int, frame: FrameType | None): 20 | global _should_exit 21 | _should_exit = True 22 | if original_handler: 23 | original_handler(sig_, frame) # type: ignore[unreachable] 24 | 25 | original_handler = signal.signal(sig, handler) 26 | 27 | 28 | def _register_signal_handlers(): 29 | global _should_exit 30 | if _should_exit is not None: 31 | return 32 | _should_exit = False 33 | 34 | # Check if we're in the main thread of the main interpreter 35 | if threading.current_thread() is threading.main_thread(): 36 | for sig in HANDLED_SIGNALS: 37 | _register_signal_handler(sig) 38 | 39 | 40 | def should_exit() -> bool: 41 | _register_signal_handlers() 42 | return bool(_should_exit) 43 | 44 | 45 | def should_continue() -> bool: 46 | _register_signal_handlers() 47 | return not _should_exit 48 | 49 | 50 | def sleep_if_should_continue(timeout: float): 51 | if timeout <= 1: 52 | time.sleep(timeout) 53 | return 54 | start_time = time.time() 55 | while (time.time() - start_time) < timeout and should_continue(): 56 | time.sleep(1) 57 | 58 | 59 | async def async_sleep_if_should_continue(timeout: float): 60 | if timeout <= 1: 61 | await asyncio.sleep(timeout) 62 | return 63 | start_time = time.time() 64 | while time.time() - start_time < timeout and should_continue(): 65 | await asyncio.sleep(1) 66 | -------------------------------------------------------------------------------- /autoagent/environment/tcp_server.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import subprocess 3 | import json 4 | import argparse 5 | 6 | parser = argparse.ArgumentParser() 7 | parser.add_argument("--workplace", type=str, default=None) 8 | parser.add_argument("--conda_path", type=str, default=None) 9 | parser.add_argument("--port", type=int, default=None) 10 | args = parser.parse_args() 11 | 12 | if __name__ == "__main__": 13 | assert args.workplace is not None, "Workplace is not specified" 14 | assert args.conda_path is not None, "Conda path is not specified" 15 | assert args.port is not None, "Port is not specified" 16 | server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 17 | server.bind(("0.0.0.0", args.port)) 18 | server.listen(1) 19 | 20 | print(f"Listening on port {args.port}...") 21 | def receive_all(conn, buffer_size=4096): 22 | data = b"" 23 | while True: 24 | part = conn.recv(buffer_size) 25 | data += part 26 | if len(part) < buffer_size: 27 | # 如果接收的数据小于缓冲区大小,可能已经接收完毕 28 | break 29 | return data.decode() 30 | 31 | while True: 32 | conn, addr = server.accept() 33 | print(f"Connection from {addr}") 34 | while True: 35 | # command = conn.recv(1024).decode() 36 | command = receive_all(conn) 37 | if not command: 38 | break 39 | 40 | # Execute the command 41 | try: 42 | modified_command = f"/bin/bash -c 'source {args.conda_path}/etc/profile.d/conda.sh && conda activate autogpt && cd /{args.workplace} && {command}'" 43 | process = subprocess.Popen(modified_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) 44 | output = '' 45 | while True: 46 | line = process.stdout.readline() 47 | if not line and process.poll() is not None: 48 | break 49 | output += line 50 | # 立即发送每一行输出 51 | chunk_response = { 52 | "type": "chunk", 53 | "data": line 54 | } 55 | conn.send(json.dumps(chunk_response).encode() + b"\n") # 添加换行符作为分隔符 56 | 57 | # 发送最终的完整响应 58 | final_response = { 59 | "type": "final", 60 | "status": process.poll(), 61 | "result": output 62 | } 63 | conn.send(json.dumps(final_response).encode() + b"\n") 64 | except Exception as e: 65 | error_response = { 66 | "type": "final", 67 | "status": -1, 68 | "result": f"Error running command: {str(e)}" 69 | } 70 | conn.send(json.dumps(error_response).encode() + b"\n") 71 | 72 | # Create a JSON response 73 | # response = { 74 | # "status": exit_code, 75 | # "result": output 76 | # } 77 | 78 | # # Send the JSON response 79 | # conn.send(json.dumps(response).encode()) 80 | conn.close() -------------------------------------------------------------------------------- /autoagent/environment/tenacity_stop.py: -------------------------------------------------------------------------------- 1 | from tenacity import RetryCallState 2 | from tenacity.stop import stop_base 3 | 4 | from .shutdown_listener import should_exit 5 | 6 | 7 | class stop_if_should_exit(stop_base): 8 | """Stop if the should_exit flag is set.""" 9 | 10 | def __call__(self, retry_state: 'RetryCallState') -> bool: 11 | return should_exit() 12 | -------------------------------------------------------------------------------- /autoagent/environment/utils.py: -------------------------------------------------------------------------------- 1 | from autoagent.util import run_command_in_container 2 | from .docker_env import DockerEnv 3 | from autoagent.io_utils import print_stream 4 | def setup_metachain(workplace_name: str, env: DockerEnv): 5 | cmd = "pip list | grep autoagent" 6 | response = env.run_command(cmd, print_stream) 7 | if response['status'] == 0: 8 | print("AutoAgent is already installed.") 9 | return 10 | cmd = f"cd /{workplace_name}/AutoAgent && pip install -e ." 11 | response = env.run_command(cmd, print_stream) 12 | if response['status'] == 0: 13 | print("AutoAgent is installed.") 14 | return 15 | else: 16 | raise Exception(f"Failed to install autoagent. {response['result']}") 17 | -------------------------------------------------------------------------------- /autoagent/flow/__init__.py: -------------------------------------------------------------------------------- 1 | from .core import EventEngineCls 2 | from .types import EventInput, ReturnBehavior 3 | 4 | default_drive = EventEngineCls() 5 | -------------------------------------------------------------------------------- /autoagent/flow/broker.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from .types import BaseEvent, EventInput, Task, GroupEventReturns 3 | from .utils import generate_uuid 4 | 5 | 6 | class BaseBroker: 7 | async def append(self, event: BaseEvent, event_input: EventInput) -> Task: 8 | raise NotImplementedError() 9 | 10 | async def callback_after_run_done(self) -> tuple[BaseEvent, Any]: 11 | raise NotImplementedError() 12 | -------------------------------------------------------------------------------- /autoagent/flow/dynamic.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from .types import ( 3 | BaseEvent, 4 | _SpecialEventReturn, 5 | ReturnBehavior, 6 | ) 7 | 8 | 9 | def goto_events( 10 | group_markers: list[BaseEvent], any_return: Any = None 11 | ) -> _SpecialEventReturn: 12 | return _SpecialEventReturn( 13 | behavior=ReturnBehavior.GOTO, returns=(group_markers, any_return) 14 | ) 15 | 16 | 17 | def abort_this(): 18 | return _SpecialEventReturn(behavior=ReturnBehavior.ABORT, returns=None) 19 | -------------------------------------------------------------------------------- /autoagent/flow/utils.py: -------------------------------------------------------------------------------- 1 | import uuid 2 | import logging 3 | import asyncio 4 | import inspect 5 | import hashlib 6 | from typing import Callable 7 | 8 | logger = logging.getLogger("drive-flow") 9 | 10 | 11 | def generate_uuid() -> str: 12 | return str(uuid.uuid4()) 13 | 14 | 15 | def function_or_method_to_repr(func_or_method: Callable) -> str: 16 | is_method = inspect.ismethod(func_or_method) 17 | is_function = inspect.isfunction(func_or_method) 18 | if not is_method and not is_function: 19 | raise ValueError("Input must be a function or method") 20 | module = func_or_method.__module__ 21 | name = func_or_method.__name__ 22 | line_number = inspect.getsourcelines(func_or_method)[1] 23 | 24 | if is_method: 25 | class_name = func_or_method.__self__.__class__.__name__ 26 | return f"{module}.l_{line_number}.{class_name}.{name}".strip() 27 | else: 28 | return f"{module}.l_{line_number}.{name}".strip() 29 | 30 | 31 | def function_or_method_to_string(func_or_method: Callable) -> str: 32 | is_method = inspect.ismethod(func_or_method) 33 | is_function = inspect.isfunction(func_or_method) 34 | if not is_method and not is_function: 35 | raise ValueError("Input must be a function or method") 36 | module = func_or_method.__module__ 37 | source = inspect.getsource(func_or_method) 38 | line_number = inspect.getsourcelines(func_or_method)[1] 39 | 40 | if is_method: 41 | class_name = func_or_method.__self__.__class__.__name__ 42 | return f"{module}.l_{line_number}.{class_name}\n{source}".strip() 43 | else: 44 | return f"{module}.l_{line_number}\n{source}".strip() 45 | 46 | 47 | def string_to_md5_hash(string: str) -> str: 48 | return hashlib.md5(string.encode()).hexdigest() 49 | -------------------------------------------------------------------------------- /autoagent/io_utils.py: -------------------------------------------------------------------------------- 1 | import yaml 2 | import hashlib 3 | import zipfile 4 | import os 5 | import json 6 | from rich.console import Console 7 | def read_file(file_path): 8 | with open(file_path, 'r', encoding='utf-8') as file: 9 | content = file.read() 10 | return content 11 | 12 | def read_yaml_file(file_path): 13 | with open(file_path, 'r', encoding='utf-8') as file: 14 | content = yaml.safe_load(file) 15 | return content 16 | 17 | def get_file_md5(file_path): 18 | md5_hash = hashlib.md5() 19 | with open(file_path, "rb") as f: 20 | # read file block 21 | for byte_block in iter(lambda: f.read(4096), b""): 22 | md5_hash.update(byte_block) 23 | return md5_hash.hexdigest() 24 | 25 | 26 | def compress_folder(source_folder, destination_folder, archive_name): 27 | os.makedirs(destination_folder, exist_ok=True) 28 | 29 | archive_path = os.path.join(destination_folder, archive_name) 30 | 31 | with zipfile.ZipFile(archive_path, 'w', zipfile.ZIP_DEFLATED) as zipf: 32 | 33 | for root, _, files in os.walk(source_folder): 34 | for file in files: 35 | file_path = os.path.join(root, file) 36 | arcname = os.path.relpath(file_path, source_folder) 37 | zipf.write(file_path, arcname) 38 | 39 | print(f"Folder '{source_folder}' has been compressed to '{archive_path}'") 40 | 41 | def get_md5_hash_bytext(text): 42 | return hashlib.md5(text.encode('utf-8')).hexdigest() 43 | 44 | def read_json_file(file_path): 45 | with open(file_path, 'r', encoding='utf-8') as file: 46 | content = json.load(file) 47 | return content 48 | 49 | def print_stream(text): 50 | console = Console() 51 | console.print(f"[grey42]{text}[/grey42]") -------------------------------------------------------------------------------- /autoagent/memory/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HKUDS/AutoAgent/be1ae2729b25420ddb2c0b8aee126b98bcb8de92/autoagent/memory/__init__.py -------------------------------------------------------------------------------- /autoagent/memory/paper_memory.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from typing import List, Dict 3 | from autoagent.memory.rag_memory import Memory, Reranker 4 | import json 5 | import math 6 | import os 7 | from litellm import completion 8 | from autoagent.memory.utils import chunking_by_token_size 9 | 10 | class TextMemory(Memory): 11 | def __init__( 12 | self, 13 | project_path: str, 14 | db_name: str = '.text_table', 15 | platform: str = 'OpenAI', 16 | api_key: str = None, 17 | embedding_model: str = "text-embedding-3-small", 18 | ): 19 | super().__init__( 20 | project_path=project_path, 21 | db_name=db_name, 22 | platform=platform, 23 | api_key=api_key, 24 | embedding_model=embedding_model 25 | ) 26 | self.collection_name = 'text_memory' 27 | 28 | def add_text_content(self, paper_content: str, batch_size: int = 100, collection = None): 29 | assert collection is not None, "Collection is required. Should be the path of the paper." 30 | queries = [] 31 | content_chunks = chunking_by_token_size(paper_content, max_token_size=4096) 32 | 33 | idx_list = ["chunk_" + str(chunk['chunk_order_index']) for chunk in content_chunks] 34 | for chunk in content_chunks: 35 | query = { 36 | 'query': chunk['content'], 37 | 'response': chunk['content'] 38 | } 39 | queries.append(query) 40 | 41 | # self.add_query(queries, collection=collection) 42 | print(f'Adding {len(queries)} queries to {collection} with batch size {batch_size}') 43 | num_batches = math.ceil(len(queries) / batch_size) 44 | 45 | for i in range(num_batches): 46 | start_idx = i * batch_size 47 | end_idx = min((i + 1) * batch_size, len(queries)) 48 | batch_queries = queries[start_idx:end_idx] 49 | batch_idx = idx_list[start_idx:end_idx] 50 | 51 | # Add the current batch of queries 52 | self.add_query(batch_queries, collection=collection, idx=batch_idx) 53 | 54 | print(f"Batch {i+1}/{num_batches} added") 55 | 56 | def query_text_content( 57 | self, 58 | query_text: str, 59 | collection: str = None, 60 | n_results: int = 5 61 | ) -> List[str]: 62 | """ 63 | Query the table and return the results 64 | """ 65 | assert collection is not None, "Collection is required. Should be the path of the paper." 66 | results = self.query([query_text], collection=collection, n_results=n_results) 67 | 68 | metadata_results = results['metadatas'][0] 69 | 70 | results = [item['response'] for item in metadata_results] 71 | return results 72 | 73 | def peek_table(self, collection: str = None, n_results: int = 20) -> pd.DataFrame: 74 | """ 75 | Peek at the data in the table 76 | """ 77 | assert collection is not None, "Collection is required. Should be the path of the paper." 78 | raw_results = self.peek(collection=collection, n_results=n_results) 79 | results = [item['response'] for item in raw_results['metadatas']] 80 | return results -------------------------------------------------------------------------------- /autoagent/memory/utils.py: -------------------------------------------------------------------------------- 1 | import tiktoken 2 | ENCODER = None 3 | 4 | def encode_string_by_tiktoken(content: str, model_name: str = "gpt-4o"): 5 | global ENCODER 6 | if ENCODER is None: 7 | ENCODER = tiktoken.encoding_for_model(model_name) 8 | tokens = ENCODER.encode(content) 9 | return tokens 10 | 11 | 12 | def decode_tokens_by_tiktoken(tokens: list[int], model_name: str = "gpt-4o"): 13 | global ENCODER 14 | if ENCODER is None: 15 | ENCODER = tiktoken.encoding_for_model(model_name) 16 | content = ENCODER.decode(tokens) 17 | return content 18 | def chunking_by_token_size( 19 | content: str, overlap_token_size=128, max_token_size=1024, tiktoken_model="gpt-4o" 20 | ): 21 | tokens = encode_string_by_tiktoken(content, model_name=tiktoken_model) 22 | results = [] 23 | for index, start in enumerate( 24 | range(0, len(tokens), max_token_size - overlap_token_size) 25 | ): 26 | chunk_content = decode_tokens_by_tiktoken( 27 | tokens[start : start + max_token_size], model_name=tiktoken_model 28 | ) 29 | results.append( 30 | { 31 | "tokens": min(max_token_size, len(tokens) - start), 32 | "content": chunk_content.strip(), 33 | "chunk_order_index": index, 34 | } 35 | ) 36 | return results -------------------------------------------------------------------------------- /autoagent/repl/__init__.py: -------------------------------------------------------------------------------- 1 | from .repl import run_demo_loop 2 | -------------------------------------------------------------------------------- /autoagent/repl/repl.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | from autoagent.core import MetaChain 4 | 5 | 6 | def process_and_print_streaming_response(response): 7 | content = "" 8 | last_sender = "" 9 | 10 | for chunk in response: 11 | if "sender" in chunk: 12 | last_sender = chunk["sender"] 13 | 14 | if "content" in chunk and chunk["content"] is not None: 15 | if not content and last_sender: 16 | print(f"\033[94m{last_sender}:\033[0m", end=" ", flush=True) 17 | last_sender = "" 18 | print(chunk["content"], end="", flush=True) 19 | content += chunk["content"] 20 | 21 | if "tool_calls" in chunk and chunk["tool_calls"] is not None: 22 | for tool_call in chunk["tool_calls"]: 23 | f = tool_call["function"] 24 | name = f["name"] 25 | if not name: 26 | continue 27 | print(f"\033[94m{last_sender}: \033[95m{name}\033[0m()") 28 | 29 | if "delim" in chunk and chunk["delim"] == "end" and content: 30 | print() # End of response message 31 | content = "" 32 | 33 | if "response" in chunk: 34 | return chunk["response"] 35 | 36 | 37 | def pretty_print_messages(messages) -> None: 38 | for message in messages: 39 | if message["role"] != "assistant": 40 | continue 41 | 42 | # print agent name in blue 43 | print(f"\033[94m{message['sender']}\033[0m:", end=" ") 44 | 45 | # print response, if any 46 | if message["content"]: 47 | print(message["content"]) 48 | 49 | # print tool calls in purple, if any 50 | tool_calls = message.get("tool_calls") or [] 51 | if len(tool_calls) > 1: 52 | print() 53 | for tool_call in tool_calls: 54 | f = tool_call["function"] 55 | name, args = f["name"], f["arguments"] 56 | arg_str = json.dumps(json.loads(args)).replace(":", "=") 57 | print(f"\033[95m{name}\033[0m({arg_str[1:-1]})") 58 | 59 | 60 | def run_demo_loop( 61 | starting_agent, context_variables=None, stream=False, debug=False 62 | ) -> None: 63 | client = MetaChain() 64 | print("Starting Swarm CLI 🐝") 65 | 66 | messages = [] 67 | agent = starting_agent 68 | 69 | while True: 70 | user_input = input("\033[90mUser\033[0m: ") 71 | messages.append({"role": "user", "content": user_input}) 72 | 73 | response = client.run( 74 | agent=agent, 75 | messages=messages, 76 | context_variables=context_variables or {}, 77 | stream=stream, 78 | debug=debug, 79 | ) 80 | 81 | if stream: 82 | response = process_and_print_streaming_response(response) 83 | else: 84 | pretty_print_messages(response.messages) 85 | 86 | messages.extend(response.messages) 87 | agent = response.agent 88 | -------------------------------------------------------------------------------- /autoagent/tcp_server.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import subprocess 3 | import json 4 | import argparse 5 | 6 | parser = argparse.ArgumentParser() 7 | parser.add_argument("--workplace", type=str, default=None) 8 | args = parser.parse_args() 9 | 10 | if __name__ == "__main__": 11 | assert args.workplace is not None, "Workplace is not specified" 12 | server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 13 | server.bind(("0.0.0.0", 12345)) 14 | server.listen(1) 15 | 16 | print("Listening on port 12345...") 17 | def receive_all(conn, buffer_size=4096): 18 | data = b"" 19 | while True: 20 | part = conn.recv(buffer_size) 21 | data += part 22 | if len(part) < buffer_size: 23 | # 如果接收的数据小于缓冲区大小,可能已经接收完毕 24 | break 25 | return data.decode() 26 | 27 | while True: 28 | conn, addr = server.accept() 29 | print(f"Connection from {addr}") 30 | while True: 31 | # command = conn.recv(1024).decode() 32 | command = receive_all(conn) 33 | if not command: 34 | break 35 | 36 | # Execute the command 37 | try: 38 | modified_command = f"/bin/bash -c 'source /home/user/micromamba/etc/profile.d/conda.sh && conda activate autogpt && cd /{args.workplace} && {command}'" 39 | process = subprocess.Popen(modified_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) 40 | output = '' 41 | while True: 42 | line = process.stdout.readline() 43 | if not line and process.poll() is not None: 44 | break 45 | output += line 46 | print(line, end='') 47 | 48 | exit_code = process.wait() 49 | except Exception as e: 50 | exit_code = -1 51 | output = f"Error running command: {str(e)}" 52 | 53 | # Create a JSON response 54 | response = { 55 | "status": exit_code, 56 | "result": output 57 | } 58 | 59 | # Send the JSON response 60 | conn.send(json.dumps(response).encode()) 61 | conn.close() -------------------------------------------------------------------------------- /autoagent/tools/__init__.py: -------------------------------------------------------------------------------- 1 | # from .code_knowledge import gen_code_tree_structure 2 | # from .execution import execute_command 3 | # from .files import read_file, create_file, write_file, list_files, create_directory 4 | # from .PythonAction import run_python 5 | # from .rag_code import code_rag 6 | # from .tool_retriever import get_api_doc 7 | # from .rag_code_tree import code_tree_rag 8 | # from .inner import case_resolved 9 | # from .code_report import check_tool, check_agent 10 | # from .github_ops import get_current_branch, get_diff, push_changes, submit_pull_request 11 | 12 | # import os 13 | # import importlib 14 | # from autoagent.registry import registry 15 | 16 | # # 获取当前目录下的所有 .py 文件 17 | # current_dir = os.path.dirname(__file__) 18 | # for file in os.listdir(current_dir): 19 | # if file.endswith('.py') and not file.startswith('__'): 20 | # module_name = file[:-3] 21 | # importlib.import_module(f'autoagent.tools.{module_name}') 22 | 23 | # # 导出所有注册的工具 24 | # globals().update(registry.tools) 25 | 26 | # __all__ = list(registry.tools.keys()) 27 | 28 | import os 29 | import importlib 30 | from autoagent.registry import registry 31 | 32 | def import_tools_recursively(base_dir: str, base_package: str): 33 | """Recursively import all tools in .py files 34 | 35 | Args: 36 | base_dir: the root directory to start searching 37 | base_package: the base name of the Python package 38 | """ 39 | for root, dirs, files in os.walk(base_dir): 40 | # get the relative path to the base directory 41 | rel_path = os.path.relpath(root, base_dir) 42 | 43 | for file in files: 44 | if file.endswith('.py') and not file.startswith('__'): 45 | # build the module path 46 | if rel_path == '.': 47 | # in the root directory 48 | module_path = f"{base_package}.{file[:-3]}" 49 | else: 50 | # in the subdirectory 51 | package_path = rel_path.replace(os.path.sep, '.') 52 | module_path = f"{base_package}.{package_path}.{file[:-3]}" 53 | 54 | try: 55 | importlib.import_module(module_path) 56 | except Exception as e: 57 | print(f"Warning: Failed to import {module_path}: {e}") 58 | 59 | # get the current directory and import all tools 60 | current_dir = os.path.dirname(__file__) 61 | import_tools_recursively(current_dir, 'autoagent.tools') 62 | 63 | # export all tool creation functions 64 | globals().update(registry.tools) 65 | globals().update(registry.plugin_tools) 66 | 67 | __all__ = list(registry.tools.keys()) + list(registry.plugin_tools.keys()) -------------------------------------------------------------------------------- /autoagent/tools/dummy_tool.py: -------------------------------------------------------------------------------- 1 | from autoagent.types import Result, Agent 2 | from typing import Union 3 | from autoagent.registry import register_plugin_tool 4 | 5 | @register_plugin_tool("tool_dummy") # the name of registry should be the same as the name of the tool 6 | def tool_dummy(args1, args2, context_variables)-> Union[str, Agent, Result]: 7 | """ 8 | [This is a dummy tool, it's used for demonstrating the usage of the autoagent, you should write your own tool instead of using this dummy tool, and the following docstring is just a template, you should modify it to fit your own tool.] 9 | The tool is used to ... 10 | 11 | Args: 12 | args1: ... 13 | args2: ... 14 | ... 15 | Returns: 16 | ... 17 | Notes: 18 | The return value can be a string, an agent, or an instance of Result. 19 | 1. The most common return value is a string, but the length of the string should not be too long, and you can save the result to a file if the length is too long. 20 | 2. If the tool is used to transfer the conversation context to an agent, you can return an instance of Agent, like: 21 | ```python 22 | sales_agent = Agent(name="sales_agent", instructions="You are a sales agent.") 23 | def transfer_to_sales_agent(): 24 | return sales_agent 25 | ``` 26 | 3. If there is some complex operations inside the tool, you can return an instance of Result, for example, you should modify the context variables in the result. 27 | ```python 28 | def sales_agent_tool(recommendation: str, context_variables: dict): 29 | ''' 30 | The tool is used to recommend products to the user. 31 | ''' 32 | context_variables["recommendation"] = recommendation 33 | return Result(value="I recommend the product: " + recommendation, agent=user_agent, context_variables=context_variables) 34 | 35 | 4. The value of Result class should be a string, if you want to return a json dictionary, you should convert it to string by json.dumps(result) 36 | ``` 37 | 5. The tools should be created in the python file in the `autoagent/autoagent/tools` folder. 38 | """ 39 | ... # the implementation of the tool 40 | return "..." # the return value of the tool. 41 | 42 | -------------------------------------------------------------------------------- /autoagent/tools/inner.py: -------------------------------------------------------------------------------- 1 | from autoagent.registry import register_tool 2 | 3 | @register_tool("case_resolved") 4 | def case_resolved(result: str): 5 | """ 6 | Use this function when the case is resolved and no further actions are needed. Please encapsulate your final answer (answer ONLY) within and . 7 | 8 | Args: 9 | result: The final result of the case resolution following the instructions. 10 | 11 | Example: case_resolved(`The answer to the question is 42 `) 12 | """ 13 | return f"Case resolved. No further actions are needed. The result of the case resolution is: {result}" 14 | 15 | @register_tool("case_not_resolved") 16 | def case_not_resolved(failure_reason: str): 17 | """ 18 | Use this function when the case is not resolved when all agents have tried their best. 19 | [IMPORTANT] Please do not use this function unless all of you have tried your best. 20 | 21 | Args: 22 | failure_reason: The reason why the case is not resolved. 23 | """ 24 | return f"Case not resolved. No further actions are needed. The reason is: {failure_reason}" 25 | 26 | if __name__ == "__main__": 27 | print(case_resolved()) -------------------------------------------------------------------------------- /autoagent/tools/meta/tool_retriever.py: -------------------------------------------------------------------------------- 1 | from autoagent.memory.tool_memory import ToolMemory, ToolReranker 2 | import os 3 | from autoagent.io_utils import get_file_md5 4 | import pandas as pd 5 | from autoagent.registry import register_tool 6 | from constant import COMPLETION_MODEL, EMBEDDING_MODEL 7 | 8 | @register_tool("get_api_plugin_tools_doc") 9 | def get_api_plugin_tools_doc(query_text: str) -> str: 10 | """ 11 | Retrieve satisfied tool documents based on the query text. 12 | Args: 13 | query_text: A query or request from users and you need to find the satisfied tool documents based on the query text. 14 | Returns: 15 | A string representation of the reranked results. 16 | """ 17 | platform = 'default' 18 | tool_memory = ToolMemory(project_path = './code_db', db_name = ".tool_table_" + platform, platform=platform, api_key=os.getenv("OPENAI_API_KEY"), embedding_model=EMBEDDING_MODEL) 19 | # tool_reranker = ToolReranker(model="gpt-4o-2024-08-06") 20 | tool_reranker = ToolReranker(model=COMPLETION_MODEL) 21 | tool_path = "./tool_docs.csv" 22 | code_id = get_file_md5(tool_path) 23 | # print(code_id) 24 | tool_memory.collection_name = tool_memory.collection_name + f"_{code_id}" 25 | if tool_memory.count() == 0: 26 | tool_memory.add_dataframe(pd.read_csv(tool_path), batch_size=100) 27 | res_df = tool_memory.query_table(query_text, n_results=5) 28 | # print(res_df) 29 | try: 30 | reranked_result = tool_reranker.dummy_rerank(query_text, res_df) 31 | except Exception as e: 32 | return "Failed to rerank the tool documentation. Error: " + str(e) 33 | 34 | return reranked_result 35 | 36 | if __name__ == "__main__": 37 | os.environ["GEMINI_API_KEY"] = "AIzaSyDblGdaCwhWq0RpXe7aCPFQr0MBg__GN2E" 38 | print(get_api_plugin_tools_doc("Youtube")) -------------------------------------------------------------------------------- /autoagent/tools/rag_code.py: -------------------------------------------------------------------------------- 1 | from autoagent.memory.code_memory import CodeMemory, CodeReranker 2 | import os 3 | from autoagent.environment import DockerEnv, LocalEnv 4 | from autoagent.io_utils import compress_folder, get_file_md5 5 | from autoagent.registry import register_tool 6 | from typing import Union 7 | @register_tool("code_rag") 8 | def code_rag(query_text: str, context_variables) -> str: 9 | """ 10 | Retrieve information from a code directory. Use this function when there is a need to search for information in the codebase. 11 | Args: 12 | query_text: Anything you want to search in the code directory, like a function name, a class name, a variable name, etc. 13 | Returns: 14 | A string representation of the reranked results. 15 | """ 16 | env: Union[DockerEnv, LocalEnv] = context_variables.get("code_env", LocalEnv()) 17 | code_memory = CodeMemory(project_path = './code_db', platform='OpenAI', api_key=os.getenv("OPENAI_API_KEY"),embedding_model='text-embedding-3-small') 18 | code_reranker = CodeReranker(model="gpt-4o-2024-08-06") 19 | code_path = f"{env.local_workplace}/autoagent" 20 | compress_folder(code_path, f"{env.local_workplace}/", "autoagent.zip") 21 | code_id = get_file_md5(f"{env.local_workplace}/autoagent.zip") 22 | code_memory.collection_name = code_memory.collection_name + f"_{code_id}" 23 | 24 | if code_memory.count() == 0: 25 | code_memory.add_code_files(f"{env.local_workplace}/autoagent", exclude_prefix=['__pycache__', 'code_db', '.git']) 26 | 27 | query_results = code_memory.query_code(query_text, n_results=20) 28 | reranked_results = code_reranker.rerank(query_text, query_results) 29 | return reranked_results 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /autoagent/tools/tool_utils.py: -------------------------------------------------------------------------------- 1 | from autoagent.environment.docker_env import DockerEnv 2 | 3 | import tiktoken 4 | from datetime import datetime 5 | 6 | def truncate_by_tokens(env: DockerEnv, text, max_tokens = 4096, model="gpt-4o-2024-08-06"): 7 | from autoagent.tools.terminal_tools import create_file 8 | encoding = tiktoken.encoding_for_model(model) 9 | tokens = encoding.encode(text) 10 | 11 | if len(tokens) <= max_tokens: 12 | return text 13 | timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") 14 | 15 | output_path = f"{env.docker_workplace}/console_output/truncated_output_{timestamp}.txt" 16 | create_msg = create_file(output_path, content = text, context_variables={'code_env': env}) 17 | # 截断tokens并解码回字符串 18 | truncated_tokens_bos = tokens[:max_tokens//2] 19 | truncated_tokens_eos = tokens[-(max_tokens - len(truncated_tokens_bos)):] 20 | if create_msg.startswith("Error"): 21 | return encoding.decode(truncated_tokens_bos) + "\n...\n" + encoding.decode(truncated_tokens_eos) + "\n\nThe full console output is too long, so I want to save them into the file: {0}\n\nBut I got an error: {1}".format(output_path, create_msg) 22 | 23 | return encoding.decode(truncated_tokens_bos) + "\n...\n" + encoding.decode(truncated_tokens_eos) + "\n\nThe full console output is too long, so it is saved in the file: {0}\n\nYou may use the `File Surfer Agent` to view the full output.".format(output_path) 24 | 25 | -------------------------------------------------------------------------------- /autoagent/types.py: -------------------------------------------------------------------------------- 1 | from litellm.types.utils import ChatCompletionMessageToolCall, Function, Message 2 | from typing import List, Callable, Union, Optional, Tuple, Dict 3 | 4 | # Third-party imports 5 | from pydantic import BaseModel 6 | 7 | AgentFunction = Callable[[], Union[str, "Agent", dict]] 8 | 9 | 10 | class Agent(BaseModel): 11 | name: str = "Agent" 12 | model: str = "gpt-4o" 13 | instructions: Union[str, Callable[[], str]] = "You are a helpful agent." 14 | functions: List[AgentFunction] = [] 15 | tool_choice: str = None 16 | parallel_tool_calls: bool = False 17 | examples: Union[List[Tuple[dict, str]], Callable[[], str]] = [] 18 | handle_mm_func: Callable[[], str] = None 19 | agent_teams: Dict[str, Callable] = {} 20 | 21 | 22 | class Response(BaseModel): 23 | messages: List = [] 24 | agent: Optional[Agent] = None 25 | context_variables: dict = {} 26 | 27 | 28 | class Result(BaseModel): 29 | """ 30 | Encapsulates the possible return values for an agent function. 31 | 32 | Attributes: 33 | value (str): The result value as a string. 34 | agent (Agent): The agent instance, if applicable. 35 | context_variables (dict): A dictionary of context variables. 36 | """ 37 | 38 | value: str = "" 39 | agent: Optional[Agent] = None 40 | context_variables: dict = {} 41 | image: Optional[str] = None # base64 encoded image 42 | -------------------------------------------------------------------------------- /autoagent/workflows/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import importlib 3 | from autoagent.registry import registry 4 | 5 | def import_workflows_recursively(base_dir: str, base_package: str): 6 | """Recursively import all workflows in .py files 7 | 8 | Args: 9 | base_dir: the root directory to start searching 10 | base_package: the base name of the Python package 11 | """ 12 | for root, dirs, files in os.walk(base_dir): 13 | # get the relative path to the base directory 14 | rel_path = os.path.relpath(root, base_dir) 15 | 16 | for file in files: 17 | if file.endswith('.py') and not file.startswith('__'): 18 | # build the module path 19 | if rel_path == '.': 20 | # in the root directory 21 | module_path = f"{base_package}.{file[:-3]}" 22 | else: 23 | # in the subdirectory 24 | package_path = rel_path.replace(os.path.sep, '.') 25 | module_path = f"{base_package}.{package_path}.{file[:-3]}" 26 | 27 | try: 28 | importlib.import_module(module_path) 29 | except Exception as e: 30 | print(f"Warning: Failed to import {module_path}: {e}") 31 | 32 | # get the current directory and import all tools 33 | current_dir = os.path.dirname(__file__) 34 | import_workflows_recursively(current_dir, 'autoagent.workflows') 35 | 36 | # export all tool creation functions 37 | globals().update(registry.workflows) 38 | 39 | __all__ = list(registry.workflows.keys()) -------------------------------------------------------------------------------- /constant.py: -------------------------------------------------------------------------------- 1 | import os 2 | from dotenv import load_dotenv 3 | import platform 4 | # utils: 5 | load_dotenv() # 加载.env文件 6 | def str_to_bool(value): 7 | """convert string to bool""" 8 | true_values = {'true', 'yes', '1', 'on', 't', 'y'} 9 | false_values = {'false', 'no', '0', 'off', 'f', 'n'} 10 | 11 | if isinstance(value, bool): 12 | return value 13 | 14 | if value == None: 15 | return None 16 | 17 | value = str(value).lower().strip() 18 | if value in true_values: 19 | return True 20 | if value in false_values: 21 | return False 22 | return True # default return True 23 | 24 | 25 | DOCKER_WORKPLACE_NAME = os.getenv('DOCKER_WORKPLACE_NAME', 'workplace') 26 | GITHUB_AI_TOKEN = os.getenv('GITHUB_AI_TOKEN', None) 27 | AI_USER = os.getenv('AI_USER', "tjb-tech") 28 | LOCAL_ROOT = os.getenv('LOCAL_ROOT', os.getcwd()) 29 | 30 | DEBUG = str_to_bool(os.getenv('DEBUG', False)) 31 | 32 | DEFAULT_LOG = str_to_bool(os.getenv('DEFAULT_LOG', False)) 33 | LOG_PATH = os.getenv('LOG_PATH', None) 34 | EVAL_MODE = str_to_bool(os.getenv('EVAL_MODE', False)) 35 | BASE_IMAGES = os.getenv('BASE_IMAGES', None) 36 | 37 | def get_architecture(): 38 | machine = platform.machine().lower() 39 | if 'x86' in machine or 'amd64' in machine or 'i386' in machine: 40 | return "tjbtech1/metachain:amd64_latest" 41 | elif 'arm' in machine: 42 | return "tjbtech1/metachain:latest" 43 | else: 44 | return "tjbtech1/metachain:latest" 45 | if BASE_IMAGES is None: 46 | BASE_IMAGES = get_architecture() 47 | 48 | COMPLETION_MODEL = os.getenv('COMPLETION_MODEL', "claude-3-5-sonnet-20241022") 49 | EMBEDDING_MODEL = os.getenv('EMBEDDING_MODEL', "text-embedding-3-small") 50 | 51 | MC_MODE = str_to_bool(os.getenv('MC_MODE', True)) 52 | 53 | # add Env for function call and non-function call 54 | 55 | FN_CALL = str_to_bool(os.getenv('FN_CALL', None)) 56 | API_BASE_URL = os.getenv('API_BASE_URL', None) 57 | ADD_USER = str_to_bool(os.getenv('ADD_USER', None)) 58 | 59 | 60 | 61 | NOT_SUPPORT_SENDER = ["mistral", "groq"] 62 | MUST_ADD_USER = ["deepseek-reasoner", "o1-mini", "deepseek-r1"] 63 | 64 | NOT_SUPPORT_FN_CALL = ["o1-mini", "deepseek-reasoner", "deepseek-r1", "llama", "grok-2"] 65 | NOT_USE_FN_CALL = [ "deepseek-chat"] + NOT_SUPPORT_FN_CALL 66 | 67 | if ADD_USER is None: 68 | ADD_USER = False 69 | for model in MUST_ADD_USER: 70 | if model in COMPLETION_MODEL: 71 | ADD_USER = True 72 | break 73 | 74 | if FN_CALL is None: 75 | FN_CALL = True 76 | for model in NOT_USE_FN_CALL: 77 | if model in COMPLETION_MODEL: 78 | FN_CALL = False 79 | break 80 | 81 | NON_FN_CALL = False 82 | for model in NOT_SUPPORT_FN_CALL: 83 | if model in COMPLETION_MODEL: 84 | NON_FN_CALL = True 85 | break 86 | 87 | 88 | if EVAL_MODE: 89 | DEFAULT_LOG = False 90 | 91 | # print(FN_CALL, NON_FN_CALL, ADD_USER) -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /docs/DOC_STYLE_GUIDE.md: -------------------------------------------------------------------------------- 1 | # Documentation Style Guide 2 | 3 | ## General Writing Principles 4 | 5 | - **Clarity & Conciseness**: Always prioritize clarity and brevity. Avoid unnecessary jargon or overly complex explanations. 6 | Keep sentences short and to the point. 7 | - **Gradual Complexity**: Start with the simplest, most basic setup, and then gradually introduce more advanced 8 | concepts and configurations. 9 | 10 | ## Formatting Guidelines 11 | 12 | ### Headers 13 | 14 | Use **Title Case** for the first and second level headers. 15 | 16 | Example: 17 | - **Basic Usage** 18 | - **Advanced Configuration Options** 19 | 20 | ### Lists 21 | 22 | When listing items or options, use bullet points to enhance readability. 23 | 24 | Example: 25 | - Option A 26 | - Option B 27 | - Option C 28 | 29 | ### Procedures 30 | 31 | For instructions or processes that need to be followed in a specific order, use numbered steps. 32 | 33 | Example: 34 | 1. Step one: Do this. 35 | 2. Step two: Complete this action. 36 | 3. Step three: Verify the result. 37 | 38 | ### Code Blocks 39 | 40 | * Use code blocks for multi-line inputs, outputs, commands and code samples. 41 | 42 | Example: 43 | ```bash 44 | docker run -it \ 45 | -e THIS=this \ 46 | -e THAT=that 47 | ... 48 | ``` 49 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Website 2 | 3 | This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator. 4 | 5 | ### Installation 6 | 7 | ``` 8 | $ yarn 9 | ``` 10 | 11 | ### Local Development 12 | 13 | ``` 14 | $ yarn start 15 | ``` 16 | 17 | This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. 18 | 19 | ### Build 20 | 21 | ``` 22 | $ yarn build 23 | ``` 24 | 25 | This command generates static content into the `build` directory and can be served using any static contents hosting service. 26 | 27 | ### Deployment 28 | 29 | Using SSH: 30 | 31 | ``` 32 | $ USE_SSH=true yarn deploy 33 | ``` 34 | 35 | Not using SSH: 36 | 37 | ``` 38 | $ GIT_USER= yarn deploy 39 | ``` 40 | 41 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. 42 | -------------------------------------------------------------------------------- /docs/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /docs/docs/Dev-Guideline/dev-guide-build-your-project.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Build Your Project 3 | slug: /dev-guide-build-your-project 4 | --- 5 | -------------------------------------------------------------------------------- /docs/docs/Dev-Guideline/dev-guide-create-agent.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Create Agent 3 | slug: /dev-guide-create-agent 4 | --- 5 | -------------------------------------------------------------------------------- /docs/docs/Dev-Guideline/dev-guide-create-tools.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Create Tools 3 | slug: /dev-guide-create-tools 4 | --- 5 | -------------------------------------------------------------------------------- /docs/docs/Dev-Guideline/dev-guide-edit-mem.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Edit Memory 3 | slug: /dev-guide-edit-memory 4 | --- 5 | -------------------------------------------------------------------------------- /docs/docs/Get-Started/get-started-installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Install Langflow 3 | slug: /get-started-installation 4 | --- 5 | -------------------------------------------------------------------------------- /docs/docs/Get-Started/get-started-quickstart.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Quickstart 3 | slug: /get-started-quickstart 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /docs/docs/Get-Started/welcome-to-autoagent.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Welcome to AutoAgent 3 | sidebar_position: 0 4 | slug: / 5 | --- 6 | 7 | Welcome to AutoAgent! AutoAgent is a **Fully-Automated** and highly **Self-Developing** framework that enables users to create and deploy LLM agents through **Natural Language Alone**. 8 | 9 | ## ✨Key Features 10 | 11 | * 🏆 Top Performer on the GAIA Benchmark 12 |
AutoAgent has ranked the **#1** spot among open-sourced methods, delivering comparable performance to **OpenAI's Deep Research**. 13 | 14 | * 📚 Agentic-RAG with Native Self-Managing Vector Database 15 |
AutoAgent equipped with a native self-managing vector database, outperforms industry-leading solutions like **LangChain**. 16 | 17 | * ✨ Agent and Workflow Create with Ease 18 |
AutoAgent leverages natural language to effortlessly build ready-to-use **tools**, **agents** and **workflows** - no coding required. 19 | 20 | * 🌐 Universal LLM Support 21 |
AutoAgent seamlessly integrates with **A Wide Range** of LLMs (e.g., OpenAI, Anthropic, Deepseek, vLLM, Grok, Huggingface ...) 22 | 23 | * 🔀 Flexible Interaction 24 |
Benefit from support for both **function-calling** and **ReAct** interaction modes. 25 | 26 | * 🤖 Dynamic, Extensible, Lightweight 27 |
AutoAgent is your **Personal AI Assistant**, designed to be dynamic, extensible, customized, and lightweight. 28 | 29 | 🚀 Unlock the Future of LLM Agents. Try 🔥AutoAgent🔥 Now! -------------------------------------------------------------------------------- /docs/docs/Starter-Projects/starter-projects-auto-deep-research.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Auto Deep Research 3 | slug: /starter-projects-auto-deep-research 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /docs/docs/Starter-Projects/starter-projects-nl-to-agent.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: From Natural Language to Agent 3 | slug: /starter-projects-nl-to-agent 4 | --- 5 | -------------------------------------------------------------------------------- /docs/docs/User-Guideline/user-guide-daily-tasks.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: For Daily Tasks 3 | slug: /user-guide-daily-tasks 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /docs/docs/User-Guideline/user-guide-how-to-create-agent.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: How to create an agent with Natural Language 3 | slug: /user-guide-how-to-create-agent 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /docs/docs/python/python.md: -------------------------------------------------------------------------------- 1 | # Python Docs 2 | 3 | Docs will appear here after deployment. 4 | -------------------------------------------------------------------------------- /docs/docs/python/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "items": ["python/python"], 3 | "label": "Backend", 4 | "type": "category" 5 | } 6 | -------------------------------------------------------------------------------- /docs/docusaurus.config.ts: -------------------------------------------------------------------------------- 1 | import type * as Preset from "@docusaurus/preset-classic"; 2 | import type { Config } from "@docusaurus/types"; 3 | import { themes as prismThemes } from "prism-react-renderer"; 4 | 5 | const config: Config = { 6 | title: "AutoAgent", 7 | tagline: "Fully-Automated & Zero-Code LLM Agent Framework", 8 | favicon: "img/metachain_logo.svg", 9 | 10 | // Set the production url of your site here 11 | url: "https://autoagent-ai.github.io", 12 | baseUrl: "/", 13 | 14 | // GitHub pages deployment config. 15 | organizationName: "autoagent-ai", 16 | projectName: "autoagent-ai.github.io", 17 | trailingSlash: false, 18 | deploymentBranch: "main", 19 | 20 | onBrokenLinks: "throw", 21 | onBrokenMarkdownLinks: "warn", 22 | 23 | markdown: { 24 | mermaid: true, 25 | }, 26 | themes: ['@docusaurus/theme-mermaid'], 27 | presets: [ 28 | [ 29 | "classic", 30 | { 31 | docs: { 32 | path: "docs", 33 | routeBasePath: "docs", 34 | sidebarPath: "./sidebars.ts", 35 | exclude: [ 36 | "**/*.test.{js,jsx,ts,tsx}", 37 | "**/__tests__/**", 38 | ], 39 | }, 40 | blog: { 41 | showReadingTime: true, 42 | }, 43 | theme: { 44 | customCss: "./src/css/custom.css", 45 | }, 46 | } satisfies Preset.Options, 47 | ], 48 | ], 49 | themeConfig: { 50 | image: "img/docusaurus.png", 51 | navbar: { 52 | title: "AutoAgent", 53 | logo: { 54 | alt: "AutoAgent", 55 | src: "img/metachain_logo.svg", 56 | }, 57 | items: [ 58 | { 59 | type: "docSidebar", 60 | sidebarId: "docsSidebar", 61 | position: "left", 62 | label: "Docs", 63 | }, 64 | { 65 | href: "https://github.com/HKUDS/AutoAgent", 66 | label: "GitHub", 67 | position: "right", 68 | }, 69 | ], 70 | }, 71 | prism: { 72 | theme: prismThemes.oneLight, 73 | darkTheme: prismThemes.oneDark, 74 | }, 75 | } satisfies Preset.ThemeConfig, 76 | }; 77 | 78 | export default config; 79 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-blog/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": { 3 | "message": "Blog", 4 | "description": "The title for the blog used in SEO" 5 | }, 6 | "description": { 7 | "message": "Blog", 8 | "description": "The description for the blog used in SEO" 9 | }, 10 | "sidebar.title": { 11 | "message": "Articles récents", 12 | "description": "The label for the left sidebar" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "version.label": { 3 | "message": "Next", 4 | "description": "The label for version current" 5 | }, 6 | "sidebar.docsSidebar.category.🤖 Backends LLM": { 7 | "message": "🤖 Backends LLM", 8 | "description": "The label for category 🤖 Backends LLM in sidebar docsSidebar" 9 | }, 10 | "sidebar.docsSidebar.category.🚧 Dépannage": { 11 | "message": "🚧 Dépannage", 12 | "description": "The label for category 🚧 Dépannage in sidebar docsSidebar" 13 | }, 14 | "sidebar.apiSidebar.category.Backend": { 15 | "message": "Backend", 16 | "description": "The label for category Backend in sidebar apiSidebar" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/python/python.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Documentation Python 4 | 5 | La documentation apparaîtra ici après le déploiement. 6 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/python/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "items": ["python/python"], 3 | "label": "Backend", 4 | "type": "categorie" 5 | } 6 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/about.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # À propos d'OpenHands 4 | 5 | ## Stratégie de recherche 6 | 7 | La réplication complète d'applications de niveau production avec des LLM est une entreprise complexe. Notre stratégie implique : 8 | 9 | 1. **Recherche technique fondamentale :** Se concentrer sur la recherche fondamentale pour comprendre et améliorer les aspects techniques de la génération et de la gestion du code 10 | 2. **Capacités spécialisées :** Améliorer l'efficacité des composants de base grâce à la curation des données, aux méthodes d'entraînement, et plus encore 11 | 3. **Planification des tâches :** Développer des capacités pour la détection des bugs, la gestion des bases de code et l'optimisation 12 | 4. **Évaluation :** Établir des métriques d'évaluation complètes pour mieux comprendre et améliorer nos modèles 13 | 14 | ## Agent par défaut 15 | 16 | Notre Agent par défaut est actuellement le [CodeActAgent](agents), qui est capable de générer du code et de gérer des fichiers. 17 | 18 | ## Construit avec 19 | 20 | OpenHands est construit en utilisant une combinaison de frameworks et de bibliothèques puissants, fournissant une base solide pour son développement. Voici les principales technologies utilisées dans le projet : 21 | 22 | ![FastAPI](https://img.shields.io/badge/FastAPI-black?style=for-the-badge) ![uvicorn](https://img.shields.io/badge/uvicorn-black?style=for-the-badge) ![LiteLLM](https://img.shields.io/badge/LiteLLM-black?style=for-the-badge) ![Docker](https://img.shields.io/badge/Docker-black?style=for-the-badge) ![Ruff](https://img.shields.io/badge/Ruff-black?style=for-the-badge) ![MyPy](https://img.shields.io/badge/MyPy-black?style=for-the-badge) ![LlamaIndex](https://img.shields.io/badge/LlamaIndex-black?style=for-the-badge) ![React](https://img.shields.io/badge/React-black?style=for-the-badge) 23 | 24 | Veuillez noter que la sélection de ces technologies est en cours et que des technologies supplémentaires peuvent être ajoutées ou des technologies existantes peuvent être supprimées à mesure que le projet évolue. Nous nous efforçons d'adopter les outils les plus appropriés et les plus efficaces pour améliorer les capacités d'OpenHands. 25 | 26 | ## Licence 27 | 28 | Distribué sous la [Licence](https://github.com/All-Hands-AI/OpenHands/blob/main/LICENSE) MIT. 29 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/agents.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # 🧠 Agent Principal et Capacités 4 | 5 | ## CodeActAgent 6 | 7 | ### Description 8 | 9 | Cet agent implémente l'idée de CodeAct ([article](https://arxiv.org/abs/2402.01030), [tweet](https://twitter.com/xingyaow_/status/1754556835703751087)) qui consolide les **act**ions des agents LLM dans un espace d'action de **code** unifié à la fois pour la _simplicité_ et la _performance_. 10 | 11 | L'idée conceptuelle est illustrée ci-dessous. À chaque tour, l'agent peut : 12 | 13 | 1. **Converser** : Communiquer avec les humains en langage naturel pour demander des clarifications, des confirmations, etc. 14 | 2. **CodeAct** : Choisir d'effectuer la tâche en exécutant du code 15 | 16 | - Exécuter n'importe quelle commande Linux `bash` valide 17 | - Exécuter n'importe quel code `Python` valide avec [un interpréteur Python interactif](https://ipython.org/). Ceci est simulé via une commande `bash`, voir le système de plugin ci-dessous pour plus de détails. 18 | 19 | ![image](https://github.com/All-Hands-AI/OpenHands/assets/38853559/92b622e3-72ad-4a61-8f41-8c040b6d5fb3) 20 | 21 | ### Démo 22 | 23 | https://github.com/All-Hands-AI/OpenHands/assets/38853559/f592a192-e86c-4f48-ad31-d69282d5f6ac 24 | 25 | _Exemple de CodeActAgent avec `gpt-4-turbo-2024-04-09` effectuant une tâche de science des données (régression linéaire)_. 26 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/architecture.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 4 3 | --- 4 | 5 | # 🏛️ Aperçu de l'Architecture Système 6 | 7 | Voici un aperçu de haut niveau de l'architecture du système. Le système est divisé en deux composants principaux : le frontend et le backend. Le frontend est responsable de la gestion des interactions avec l'utilisateur et de l'affichage des résultats. Le backend est responsable de la gestion de la logique métier et de l'exécution des agents. 8 | 9 | ![system_architecture.svg](/img/system_architecture.svg) 10 | 11 | Cet aperçu est simplifié pour montrer les principaux composants et leurs interactions. Pour une vue plus détaillée de l'architecture du backend, consultez la section [Architecture du Backend](#backend-architecture-fr). 12 | 13 | # Architecture du Backend {#backend-architecture-fr} 14 | 15 | _**Avertissement**: L'architecture du backend est en cours de développement et est sujette à modifications. Le schéma suivant montre l'architecture actuelle du backend basée sur le commit indiqué dans le pied de page du schéma._ 16 | 17 | ![backend_architecture.svg](/img/backend_architecture.svg) 18 | 19 |
20 | Mise à jour de ce Schéma 21 |
22 | La génération du schéma d'architecture du backend est partiellement automatisée. 23 | Le schéma est généré à partir des annotations de type dans le code en utilisant l'outil py2puml. 24 | Le schéma est ensuite revu manuellement, ajusté et exporté en PNG et SVG. 25 | 26 | ## Prérequis 27 | 28 | - Un environnement Python dans lequel openhands est exécutable 29 | (selon les instructions du fichier README.md à la racine du dépôt) 30 | - [py2puml](https://github.com/lucsorel/py2puml) installé 31 | 32 | ## Étapes 33 | 34 | 1. Générez automatiquement le schéma en exécutant la commande suivante depuis la racine du dépôt : 35 | `py2puml openhands openhands > docs/architecture/backend_architecture.puml` 36 | 37 | 2. Ouvrez le fichier généré dans un éditeur PlantUML, par exemple Visual Studio Code avec l'extension PlantUML ou [PlantText](https://www.planttext.com/) 38 | 39 | 3. Révisez le PUML généré et apportez toutes les modifications nécessaires au schéma (ajoutez les parties manquantes, corrigez les erreurs, améliorez l'agencement). 40 | _py2puml crée le schéma à partir des annotations de type dans le code, donc les annotations de type manquantes ou incorrectes peuvent entraîner un schéma incomplet ou incorrect._ 41 | 42 | 4. Examinez la différence entre le nouveau schéma et le précédent et vérifiez manuellement si les modifications sont correctes. 43 | _Assurez-vous de ne pas supprimer les parties ajoutées manuellement au schéma par le passé et qui sont toujours pertinentes._ 44 | 45 | 5. Ajoutez le hash du commit qui a été utilisé pour générer le schéma dans le pied de page du schéma. 46 | 47 | 6. Exporte le schéma sous forme de fichiers PNG et SVG et remplacez les schémas existants dans le répertoire `docs/architecture`. Cela peut être fait avec (par exemple [PlantText](https://www.planttext.com/)) 48 | 49 |
50 |
51 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/how-to/custom-sandbox-guide.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Sandbox Personnalisé 4 | 5 | Le sandbox est l'endroit où l'agent effectue ses tâches. Au lieu d'exécuter des commandes directement sur votre ordinateur (ce qui pourrait être risqué), l'agent les exécute à l'intérieur d'un conteneur Docker. 6 | 7 | Le sandbox OpenHands par défaut (`python-nodejs:python3.12-nodejs22` de [nikolaik/python-nodejs](https://hub.docker.com/r/nikolaik/python-nodejs)) est livré avec certains paquets installés tels que Python et Node.js mais peut nécessiter l'installation d'autres logiciels par défaut. 8 | 9 | Vous avez deux options pour la personnalisation : 10 | 11 | 1. Utiliser une image existante avec les logiciels requis. 12 | 2. Créer votre propre image Docker personnalisée. 13 | 14 | Si vous choisissez la première option, vous pouvez passer la section `Créer Votre Image Docker`. 15 | 16 | ## Créer Votre Image Docker 17 | 18 | Pour créer une image Docker personnalisée, elle doit être basée sur Debian. 19 | 20 | Par exemple, si vous voulez qu'OpenHands ait `ruby` installé, créez un `Dockerfile` avec le contenu suivant : 21 | 22 | ```dockerfile 23 | FROM debian:latest 24 | 25 | # Installer les paquets requis 26 | RUN apt-get update && apt-get install -y ruby 27 | ``` 28 | 29 | Enregistrez ce fichier dans un dossier. Ensuite, construisez votre image Docker (par exemple, nommée custom-image) en naviguant vers le dossier dans le terminal et en exécutant : 30 | 31 | ```bash 32 | docker build -t custom-image . 33 | ``` 34 | 35 | Cela produira une nouvelle image appelée `custom-image`, qui sera disponible dans Docker. 36 | 37 | > Notez que dans la configuration décrite dans ce document, OpenHands s'exécutera en tant qu'utilisateur "openhands" à l'intérieur du sandbox et donc tous les paquets installés via le docker file devraient être disponibles pour tous les utilisateurs du système, pas seulement root. 38 | 39 | ## Utilisation du Workflow de Développement 40 | 41 | ### Configuration 42 | 43 | Tout d'abord, assurez-vous de pouvoir exécuter OpenHands en suivant les instructions dans [Development.md](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md). 44 | 45 | ### Spécifier l'Image de Base du Sandbox 46 | 47 | Dans le fichier `config.toml` dans le répertoire OpenHands, définissez `sandbox_base_container_image` sur l'image que vous souhaitez utiliser. Cela peut être une image que vous avez déjà extraite ou une que vous avez construite : 48 | 49 | ```bash 50 | [core] 51 | ... 52 | sandbox_base_container_image="custom-image" 53 | ``` 54 | 55 | ### Exécution 56 | 57 | Exécutez OpenHands en exécutant ```make run``` dans le répertoire de niveau supérieur. 58 | 59 | ## Explication Technique 60 | 61 | Veuillez vous référer à la [section image docker personnalisée de la documentation d'exécution](https://docs.all-hands.dev/modules/usage/architecture/runtime#advanced-how-openhands-builds-and-maintains-od-runtime-images) pour plus de détails. 62 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/how-to/debugging.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Débogage 4 | 5 | Ce qui suit est destiné à servir d'introduction au débogage d'OpenHands à des fins de développement. 6 | 7 | ## Serveur / VSCode 8 | 9 | Le `launch.json` suivant permettra de déboguer les éléments agent, contrôleur et serveur, mais pas le bac à sable (qui s'exécute dans docker). Il ignorera toutes les modifications à l'intérieur du répertoire `workspace/` : 10 | 11 | ``` 12 | { 13 | "version": "0.2.0", 14 | "configurations": [ 15 | { 16 | "name": "OpenHands CLI", 17 | "type": "debugpy", 18 | "request": "launch", 19 | "module": "openhands.core.cli", 20 | "justMyCode": false 21 | }, 22 | { 23 | "name": "OpenHands WebApp", 24 | "type": "debugpy", 25 | "request": "launch", 26 | "module": "uvicorn", 27 | "args": [ 28 | "openhands.server.listen:app", 29 | "--reload", 30 | "--reload-exclude", 31 | "${workspaceFolder}/workspace", 32 | "--port", 33 | "3000" 34 | ], 35 | "justMyCode": false 36 | } 37 | ] 38 | } 39 | ``` 40 | 41 | Des configurations de débogage plus spécifiques qui incluent plus de paramètres peuvent être spécifiées : 42 | 43 | ``` 44 | ... 45 | { 46 | "name": "Debug CodeAct", 47 | "type": "debugpy", 48 | "request": "launch", 49 | "module": "openhands.core.main", 50 | "args": [ 51 | "-t", 52 | "Demandez-moi quelle est votre tâche.", 53 | "-d", 54 | "${workspaceFolder}/workspace", 55 | "-c", 56 | "CodeActAgent", 57 | "-l", 58 | "llm.o1", 59 | "-n", 60 | "prompts" 61 | ], 62 | "justMyCode": false 63 | } 64 | ... 65 | ``` 66 | 67 | Les valeurs dans l'extrait ci-dessus peuvent être mises à jour de telle sorte que : 68 | 69 | * *t* : la tâche 70 | * *d* : le répertoire de l'espace de travail openhands 71 | * *c* : l'agent 72 | * *l* : la configuration LLM (prédéfinie dans config.toml) 73 | * *n* : le nom de la session (par exemple, le nom du flux d'événements) 74 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/how-to/headless-mode.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Mode sans interface 4 | 5 | Vous pouvez exécuter OpenHands avec une seule commande, sans démarrer l'application web. 6 | Cela facilite l'écriture de scripts et l'automatisation des tâches avec OpenHands. 7 | 8 | Ceci est différent du [Mode CLI](cli-mode), qui est interactif et mieux adapté au développement actif. 9 | 10 | ## Avec Python 11 | 12 | Pour exécuter OpenHands en mode sans interface avec Python, 13 | [suivez les instructions de configuration de développement](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md), 14 | puis exécutez : 15 | 16 | ```bash 17 | poetry run python -m openhands.core.main -t "write a bash script that prints hi" 18 | ``` 19 | 20 | Vous devrez vous assurer de définir votre modèle, votre clé API et d'autres paramètres via des variables d'environnement 21 | [ou le fichier `config.toml`](https://github.com/All-Hands-AI/OpenHands/blob/main/config.template.toml). 22 | 23 | ## Avec Docker 24 | 25 | 1. Définissez `WORKSPACE_BASE` sur le répertoire que vous voulez qu'OpenHands modifie : 26 | 27 | ```bash 28 | WORKSPACE_BASE=$(pwd)/workspace 29 | ``` 30 | 31 | 2. Définissez `LLM_MODEL` sur le modèle que vous voulez utiliser : 32 | 33 | ```bash 34 | LLM_MODEL="anthropic/claude-3-5-sonnet-20241022" 35 | 36 | ``` 37 | 38 | 3. Définissez `LLM_API_KEY` sur votre clé API : 39 | 40 | ```bash 41 | LLM_API_KEY="sk_test_12345" 42 | ``` 43 | 44 | 4. Exécutez la commande Docker suivante : 45 | 46 | ```bash 47 | docker run -it \ 48 | --pull=always \ 49 | -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.23-nikolaik \ 50 | -e SANDBOX_USER_ID=$(id -u) \ 51 | -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \ 52 | -e LLM_API_KEY=$LLM_API_KEY \ 53 | -e LLM_MODEL=$LLM_MODEL \ 54 | -e LOG_ALL_EVENTS=true \ 55 | -v $WORKSPACE_BASE:/opt/workspace_base \ 56 | -v /var/run/docker.sock:/var/run/docker.sock \ 57 | --add-host host.docker.internal:host-gateway \ 58 | --name openhands-app-$(date +%Y%m%d%H%M%S) \ 59 | docker.all-hands.dev/all-hands-ai/openhands:0.23 \ 60 | python -m openhands.core.main -t "write a bash script that prints hi" --no-auto-continue 61 | ``` 62 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/how-to/persist-session-data.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Persistance des données de session 4 | 5 | Avec l'installation standard, les données de session sont stockées en mémoire. Actuellement, si le service OpenHands est redémarré, 6 | les sessions précédentes deviennent invalides (un nouveau secret est généré) et ne sont donc pas récupérables. 7 | 8 | ## Comment persister les données de session 9 | 10 | ### Workflow de développement 11 | Dans le fichier `config.toml`, spécifiez ce qui suit : 12 | ``` 13 | [core] 14 | ... 15 | file_store="local" 16 | file_store_path="/absolute/path/to/openhands/cache/directory" 17 | jwt_secret="secretpass" 18 | ``` 19 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/llms/azure-llms.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Azure 4 | 5 | OpenHands utilise LiteLLM pour faire des appels aux modèles de chat d'Azure. Vous pouvez trouver leur documentation sur l'utilisation d'Azure comme fournisseur [ici](https://docs.litellm.ai/docs/providers/azure). 6 | 7 | ## Configuration d'Azure OpenAI 8 | 9 | Lorsque vous exécutez OpenHands, vous devrez définir la variable d'environnement suivante en utilisant `-e` dans la 10 | [commande docker run](/modules/usage/installation#start-the-app) : 11 | 12 | ``` 13 | LLM_API_VERSION="" # par exemple "2023-05-15" 14 | ``` 15 | 16 | Exemple : 17 | ```bash 18 | docker run -it --pull=always \ 19 | -e LLM_API_VERSION="2023-05-15" 20 | ... 21 | ``` 22 | 23 | Ensuite, définissez les éléments suivants dans l'interface utilisateur d'OpenHands via les paramètres : 24 | 25 | :::note 26 | Vous aurez besoin du nom de votre déploiement ChatGPT qui peut être trouvé sur la page des déploiements dans Azure. Il est référencé comme 27 | <deployment-name> ci-dessous. 28 | ::: 29 | 30 | * Activez `Advanced Options` 31 | * `Custom Model` à azure/<deployment-name> 32 | * `Base URL` à votre URL de base de l'API Azure (par exemple `https://example-endpoint.openai.azure.com`) 33 | * `API Key` à votre clé API Azure 34 | 35 | ## Embeddings 36 | 37 | OpenHands utilise llama-index pour les embeddings. Vous pouvez trouver leur documentation sur Azure [ici](https://docs.llamaindex.ai/en/stable/api_reference/embeddings/azure_openai/). 38 | 39 | ### Configuration d'Azure OpenAI 40 | 41 | Lorsque vous exécutez OpenHands, définissez les variables d'environnement suivantes en utilisant `-e` dans la 42 | [commande docker run](/modules/usage/installation#start-the-app) : 43 | 44 | ``` 45 | LLM_EMBEDDING_MODEL="azureopenai" 46 | LLM_EMBEDDING_DEPLOYMENT_NAME="" # par exemple "TextEmbedding..." 47 | LLM_API_VERSION="" # par exemple "2024-02-15-preview" 48 | ``` 49 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/llms/azureLLMs.md: -------------------------------------------------------------------------------- 1 | # Azure OpenAI LLM 2 | 3 | ## Complétion 4 | 5 | OpenHands utilise LiteLLM pour les appels de complétion. Vous pouvez trouver leur documentation sur Azure [ici](https://docs.litellm.ai/docs/providers/azure) 6 | 7 | ### Configurations openai Azure 8 | 9 | Lors de l'exécution de l'image Docker OpenHands, vous devrez définir les variables d'environnement suivantes en utilisant `-e` : 10 | 11 | ``` 12 | LLM_BASE_URL="" # e.g. "https://openai-gpt-4-test-v-1.openai.azure.com/" 13 | LLM_API_KEY="" 14 | LLM_MODEL="azure/" 15 | LLM_API_VERSION = "" # e.g. "2024-02-15-preview" 16 | ``` 17 | 18 | :::note 19 | Vous pouvez trouver le nom de votre déploiement ChatGPT sur la page des déploiements sur Azure. Par défaut ou initialement, il pourrait être le même que le nom du modèle de chat (par exemple 'GPT4-1106-preview'), mais il n'est pas obligé de l'être. Exécutez OpenHands, et une fois chargé dans le navigateur, allez dans Paramètres et définissez le modèle comme suit : "azure/<your-actual-gpt-deployment-name>". Si ce n'est pas dans la liste, entrez votre propre texte et enregistrez-le. 20 | ::: 21 | 22 | ## Embeddings 23 | 24 | OpenHands utilise llama-index pour les embeddings. Vous pouvez trouver leur documentation sur Azure [ici](https://docs.llamaindex.ai/en/stable/api_reference/embeddings/azure_openai/) 25 | 26 | ### Configurations openai Azure 27 | 28 | Le modèle utilisé pour les embeddings Azure OpenAI est "text-embedding-ada-002". 29 | Vous avez besoin du nom de déploiement correct pour ce modèle dans votre compte Azure. 30 | 31 | Lors de l'exécution d'OpenHands dans Docker, définissez les variables d'environnement suivantes en utilisant `-e` : 32 | 33 | ``` 34 | LLM_EMBEDDING_MODEL="azureopenai" 35 | LLM_EMBEDDING_DEPLOYMENT_NAME = "" # e.g. "TextEmbedding..." 36 | LLM_API_VERSION = "" # e.g. "2024-02-15-preview" 37 | ``` 38 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/llms/google-llms.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Google Gemini/Vertex 4 | 5 | OpenHands utilise LiteLLM pour faire des appels aux modèles de chat de Google. Vous pouvez trouver leur documentation sur l'utilisation de Google comme fournisseur : 6 | 7 | - [Gemini - Google AI Studio](https://docs.litellm.ai/docs/providers/gemini) 8 | - [VertexAI - Google Cloud Platform](https://docs.litellm.ai/docs/providers/vertex) 9 | 10 | ## Configurations de Gemini - Google AI Studio 11 | 12 | Lors de l'exécution d'OpenHands, vous devrez définir les éléments suivants dans l'interface utilisateur d'OpenHands via les paramètres : 13 | * `LLM Provider` à `Gemini` 14 | * `LLM Model` au modèle que vous utiliserez. 15 | Si le modèle ne figure pas dans la liste, activez `Advanced Options` et entrez-le dans `Custom Model` (par exemple, gemini/<model-name> comme `gemini/gemini-1.5-pro`). 16 | * `API Key` à votre clé API Gemini 17 | 18 | ## Configurations de VertexAI - Google Cloud Platform 19 | 20 | Pour utiliser Vertex AI via Google Cloud Platform lors de l'exécution d'OpenHands, vous devrez définir les variables d'environnement suivantes en utilisant `-e` dans la [commande docker run](/modules/usage/installation#start-the-app) : 21 | 22 | ``` 23 | GOOGLE_APPLICATION_CREDENTIALS="" 24 | VERTEXAI_PROJECT="" 25 | VERTEXAI_LOCATION="" 26 | ``` 27 | 28 | Ensuite, définissez les éléments suivants dans l'interface utilisateur d'OpenHands via les paramètres : 29 | * `LLM Provider` à `VertexAI` 30 | * `LLM Model` au modèle que vous utiliserez. 31 | Si le modèle ne figure pas dans la liste, activez `Advanced Options` et entrez-le dans `Custom Model` (par exemple, vertex_ai/<model-name>). 32 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/llms/googleLLMs.md: -------------------------------------------------------------------------------- 1 | # Google Gemini/Vertex LLM 2 | 3 | ## Complétion 4 | 5 | OpenHands utilise LiteLLM pour les appels de complétion. Les ressources suivantes sont pertinentes pour utiliser OpenHands avec les LLMs de Google : 6 | 7 | - [Gemini - Google AI Studio](https://docs.litellm.ai/docs/providers/gemini) 8 | - [VertexAI - Google Cloud Platform](https://docs.litellm.ai/docs/providers/vertex) 9 | 10 | ### Configurations de Gemini - Google AI Studio 11 | 12 | Pour utiliser Gemini via Google AI Studio lors de l'exécution de l'image Docker d'OpenHands, vous devez définir les variables d'environnement suivantes en utilisant `-e` : 13 | 14 | ``` 15 | GEMINI_API_KEY="" 16 | LLM_MODEL="gemini/gemini-1.5-pro" 17 | ``` 18 | 19 | ### Configurations de Vertex AI - Google Cloud Platform 20 | 21 | Pour utiliser Vertex AI via Google Cloud Platform lors de l'exécution de l'image Docker d'OpenHands, vous devez définir les variables d'environnement suivantes en utilisant `-e` : 22 | 23 | ``` 24 | GOOGLE_APPLICATION_CREDENTIALS="" 25 | VERTEXAI_PROJECT="" 26 | VERTEXAI_LOCATION="" 27 | LLM_MODEL="vertex_ai/" 28 | ``` 29 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/llms/groq.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Groq 4 | 5 | OpenHands utilise LiteLLM pour faire des appels aux modèles de chat sur Groq. Vous pouvez trouver leur documentation sur l'utilisation de Groq comme fournisseur [ici](https://docs.litellm.ai/docs/providers/groq). 6 | 7 | ## Configuration 8 | 9 | Lorsque vous exécutez OpenHands, vous devrez définir les éléments suivants dans l'interface utilisateur d'OpenHands via les paramètres : 10 | * `LLM Provider` à `Groq` 11 | * `LLM Model` au modèle que vous utiliserez. [Visitez ici pour voir la liste des modèles hébergés par Groq](https://console.groq.com/docs/models). Si le modèle n'est pas dans la liste, activez les `Advanced Options` et entrez-le dans `Custom Model` (par exemple, groq/<model-name> comme `groq/llama3-70b-8192`). 12 | * `API key` à votre clé API Groq. Pour trouver ou créer votre clé API Groq, [voir ici](https://console.groq.com/keys). 13 | 14 | 15 | 16 | ## Utilisation de Groq comme point de terminaison compatible OpenAI 17 | 18 | Le point de terminaison Groq pour la complétion de chat est [principalement compatible OpenAI](https://console.groq.com/docs/openai). Par conséquent, vous pouvez accéder aux modèles Groq comme vous le feriez pour n'importe quel point de terminaison compatible OpenAI. Vous pouvez définir les éléments suivants dans l'interface utilisateur d'OpenHands via les paramètres : 19 | * Activer les `Advanced Options` 20 | * `Custom Model` au préfixe `openai/` + le modèle que vous utiliserez (par exemple, `openai/llama3-70b-8192`) 21 | * `Base URL` à `https://api.groq.com/openai/v1` 22 | * `API Key` à votre clé API Groq 23 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/llms/litellm-proxy.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Proxy LiteLLM 4 | 5 | OpenHands prend en charge l'utilisation du [proxy LiteLLM](https://docs.litellm.ai/docs/proxy/quick_start) pour accéder à divers fournisseurs de LLM. 6 | 7 | ## Configuration 8 | 9 | Pour utiliser le proxy LiteLLM avec OpenHands, vous devez : 10 | 11 | 1. Configurer un serveur proxy LiteLLM (voir la [documentation LiteLLM](https://docs.litellm.ai/docs/proxy/quick_start)) 12 | 2. Lors de l'exécution d'OpenHands, vous devrez définir les éléments suivants dans l'interface utilisateur d'OpenHands via les paramètres : 13 | * Activer les `Options avancées` 14 | * `Custom Model` au préfixe `litellm_proxy/` + le modèle que vous utiliserez (par exemple, `litellm_proxy/anthropic.claude-3-5-sonnet-20241022-v2:0`) 15 | * `Base URL` à l'URL de votre proxy LiteLLM (par exemple, `https://your-litellm-proxy.com`) 16 | * `API Key` à votre clé API du proxy LiteLLM 17 | 18 | ## Modèles pris en charge 19 | 20 | Les modèles pris en charge dépendent de la configuration de votre proxy LiteLLM. OpenHands prend en charge tous les modèles que votre proxy LiteLLM est configuré pour gérer. 21 | 22 | Reportez-vous à la configuration de votre proxy LiteLLM pour obtenir la liste des modèles disponibles et leurs noms. 23 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/llms/openai-llms.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # OpenAI 4 | 5 | OpenHands utilise LiteLLM pour effectuer des appels aux modèles de chat d'OpenAI. Vous pouvez trouver leur documentation sur l'utilisation d'OpenAI en tant que fournisseur [ici](https://docs.litellm.ai/docs/providers/openai). 6 | 7 | ## Configuration 8 | 9 | Lors de l'exécution d'OpenHands, vous devrez définir les éléments suivants dans l'interface utilisateur d'OpenHands via les paramètres : 10 | * `LLM Provider` à `OpenAI` 11 | * `LLM Model` au modèle que vous utiliserez. 12 | [Visitez ce lien pour voir une liste complète des modèles OpenAI pris en charge par LiteLLM.](https://docs.litellm.ai/docs/providers/openai#openai-chat-completion-models) 13 | Si le modèle ne figure pas dans la liste, activez les `Advanced Options` et entrez-le dans `Custom Model` (par exemple, openai/<model-name> comme `openai/gpt-4o`). 14 | * `API Key` à votre clé API OpenAI. Pour trouver ou créer votre clé API de projet OpenAI, [voir ici](https://platform.openai.com/api-keys). 15 | 16 | ## Utilisation des endpoints compatibles OpenAI 17 | 18 | Tout comme pour les chat completions OpenAI, nous utilisons LiteLLM pour les endpoints compatibles OpenAI. Vous pouvez trouver leur documentation complète sur ce sujet [ici](https://docs.litellm.ai/docs/providers/openai_compatible). 19 | 20 | ## Utilisation d'un proxy OpenAI 21 | 22 | Si vous utilisez un proxy OpenAI, vous devrez définir les éléments suivants dans l'interface utilisateur d'OpenHands via les paramètres : 23 | * Activer les `Advanced Options` 24 | * `Custom Model` à openai/<model-name> (par exemple, `openai/gpt-4o` ou openai/<proxy-prefix>/<model-name>) 25 | * `Base URL` à l'URL de votre proxy OpenAI 26 | * `API Key` à votre clé API OpenAI 27 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/llms/openrouter.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # OpenRouter 4 | 5 | OpenHands utilise LiteLLM pour effectuer des appels aux modèles de chat sur OpenRouter. Vous pouvez trouver leur documentation sur l'utilisation d'OpenRouter en tant que fournisseur [ici](https://docs.litellm.ai/docs/providers/openrouter). 6 | 7 | ## Configuration 8 | 9 | Lors de l'exécution d'OpenHands, vous devrez définir les éléments suivants dans l'interface utilisateur d'OpenHands via les paramètres : 10 | * `LLM Provider` à `OpenRouter` 11 | * `LLM Model` au modèle que vous utiliserez. 12 | [Visitez ici pour voir une liste complète des modèles OpenRouter](https://openrouter.ai/models). 13 | Si le modèle ne figure pas dans la liste, activez `Advanced Options`, et entrez-le dans `Custom Model` (par exemple openrouter/<model-name> comme `openrouter/anthropic/claude-3.5-sonnet`). 14 | * `API Key` à votre clé API OpenRouter. 15 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/prompting-best-practices.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Meilleures pratiques pour les prompts 4 | 5 | Lorsque vous travaillez avec le développeur de logiciels OpenHands AI, il est crucial de fournir des prompts clairs et efficaces. Ce guide décrit les meilleures pratiques pour créer des prompts qui produiront les réponses les plus précises et utiles. 6 | 7 | ## Caractéristiques des bons prompts 8 | 9 | Les bons prompts sont : 10 | 11 | 1. **Concrets** : Ils expliquent exactement quelle fonctionnalité doit être ajoutée ou quelle erreur doit être corrigée. 12 | 2. **Spécifiques à l'emplacement** : Si connu, ils expliquent les emplacements dans la base de code qui doivent être modifiés. 13 | 3. **Correctement dimensionnés** : Ils doivent avoir la taille d'une seule fonctionnalité, ne dépassant généralement pas 100 lignes de code. 14 | 15 | ## Exemples 16 | 17 | ### Exemples de bons prompts 18 | 19 | 1. "Ajoutez une fonction `calculate_average` dans `utils/math_operations.py` qui prend une liste de nombres en entrée et renvoie leur moyenne." 20 | 21 | 2. "Corrigez le TypeError dans `frontend/src/components/UserProfile.tsx` se produisant à la ligne 42. L'erreur suggère que nous essayons d'accéder à une propriété de undefined." 22 | 23 | 3. "Implémentez la validation des entrées pour le champ email dans le formulaire d'inscription. Mettez à jour `frontend/src/components/RegistrationForm.tsx` pour vérifier si l'email est dans un format valide avant la soumission." 24 | 25 | ### Exemples de mauvais prompts 26 | 27 | 1. "Améliorez le code." (Trop vague, pas concret) 28 | 29 | 2. "Réécrivez tout le backend pour utiliser un framework différent." (Pas correctement dimensionné) 30 | 31 | 3. "Il y a un bug quelque part dans l'authentification des utilisateurs. Pouvez-vous le trouver et le corriger ?" (Manque de spécificité et d'informations de localisation) 32 | 33 | ## Conseils pour des prompts efficaces 34 | 35 | 1. Soyez aussi précis que possible sur le résultat souhaité ou le problème à résoudre. 36 | 2. Fournissez du contexte, y compris les chemins de fichiers et les numéros de ligne pertinents si disponibles. 37 | 3. Décomposez les grandes tâches en prompts plus petits et gérables. 38 | 4. Incluez tous les messages d'erreur ou logs pertinents. 39 | 5. Spécifiez le langage de programmation ou le framework s'il n'est pas évident d'après le contexte. 40 | 41 | N'oubliez pas, plus votre prompt est précis et informatif, mieux l'IA pourra vous aider à développer ou à modifier le logiciel OpenHands. 42 | 43 | Voir [Getting Started with OpenHands](./getting-started) pour plus d'exemples de prompts utiles. 44 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/prompting/prompting-best-practices.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Meilleures pratiques pour les prompts 4 | 5 | Lorsque vous travaillez avec le développeur de logiciels OpenHands AI, il est crucial de fournir des prompts clairs et efficaces. Ce guide décrit les meilleures pratiques pour créer des prompts qui produiront les réponses les plus précises et les plus utiles. 6 | 7 | ## Caractéristiques des bons prompts 8 | 9 | Les bons prompts sont : 10 | 11 | 1. **Concrets** : Ils expliquent exactement quelle fonctionnalité doit être ajoutée ou quelle erreur doit être corrigée. 12 | 2. **Spécifiques à l'emplacement** : Si connu, ils expliquent les emplacements dans la base de code qui doivent être modifiés. 13 | 3. **Correctement dimensionnés** : Ils doivent avoir la taille d'une seule fonctionnalité, ne dépassant généralement pas 100 lignes de code. 14 | 15 | ## Exemples 16 | 17 | ### Exemples de bons prompts 18 | 19 | 1. "Ajoutez une fonction `calculate_average` dans `utils/math_operations.py` qui prend une liste de nombres en entrée et renvoie leur moyenne." 20 | 21 | 2. "Corrigez le TypeError dans `frontend/src/components/UserProfile.tsx` se produisant à la ligne 42. L'erreur suggère que nous essayons d'accéder à une propriété de undefined." 22 | 23 | 3. "Implémentez la validation des entrées pour le champ email dans le formulaire d'inscription. Mettez à jour `frontend/src/components/RegistrationForm.tsx` pour vérifier si l'email est dans un format valide avant la soumission." 24 | 25 | ### Exemples de mauvais prompts 26 | 27 | 1. "Améliorez le code." (Trop vague, pas concret) 28 | 29 | 2. "Réécrivez tout le backend pour utiliser un framework différent." (Pas correctement dimensionné) 30 | 31 | 3. "Il y a un bug quelque part dans l'authentification des utilisateurs. Pouvez-vous le trouver et le corriger ?" (Manque de spécificité et d'informations de localisation) 32 | 33 | ## Conseils pour des prompts efficaces 34 | 35 | 1. Soyez aussi précis que possible sur le résultat souhaité ou le problème à résoudre. 36 | 2. Fournissez du contexte, y compris les chemins de fichiers et les numéros de ligne pertinents si disponibles. 37 | 3. Décomposez les grandes tâches en prompts plus petits et gérables. 38 | 4. Incluez tous les messages d'erreur ou logs pertinents. 39 | 5. Spécifiez le langage de programmation ou le framework s'il n'est pas évident d'après le contexte. 40 | 41 | N'oubliez pas, plus votre prompt est précis et informatif, mieux l'IA pourra vous aider à développer ou à modifier le logiciel OpenHands. 42 | 43 | Voir [Démarrer avec OpenHands](../getting-started) pour plus d'exemples de prompts utiles. 44 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/troubleshooting/troubleshooting.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # 🚧 Dépannage 4 | 5 | :::tip 6 | OpenHands ne prend en charge Windows que via WSL. Veuillez vous assurer d'exécuter toutes les commandes dans votre terminal WSL. 7 | ::: 8 | 9 | ### Échec du lancement du client docker 10 | 11 | **Description** 12 | 13 | Lors de l'exécution d'OpenHands, l'erreur suivante est observée : 14 | ``` 15 | Launch docker client failed. Please make sure you have installed docker and started docker desktop/daemon. 16 | ``` 17 | 18 | **Résolution** 19 | 20 | Essayez ces étapes dans l'ordre : 21 | * Vérifiez que `docker` est en cours d'exécution sur votre système. Vous devriez pouvoir exécuter `docker ps` dans le terminal avec succès. 22 | * Si vous utilisez Docker Desktop, assurez-vous que `Settings > Advanced > Allow the default Docker socket to be used` est activé. 23 | * Selon votre configuration, vous devrez peut-être activer `Settings > Resources > Network > Enable host networking` dans Docker Desktop. 24 | * Réinstallez Docker Desktop. 25 | --- 26 | 27 | # Spécifique au flux de travail de développement 28 | ### Erreur lors de la construction de l'image docker du runtime 29 | 30 | **Description** 31 | 32 | Les tentatives de démarrage d'une nouvelle session échouent et des erreurs contenant des termes comme les suivants apparaissent dans les logs : 33 | ``` 34 | debian-security bookworm-security 35 | InRelease At least one invalid signature was encountered. 36 | ``` 37 | 38 | Cela semble se produire lorsque le hash d'une bibliothèque externe existante change et que votre instance docker locale a 39 | mis en cache une version précédente. Pour contourner ce problème, veuillez essayer ce qui suit : 40 | 41 | * Arrêtez tous les conteneurs dont le nom a le préfixe `openhands-runtime-` : 42 | `docker ps --filter name=openhands-runtime- --filter status=running -aq | xargs docker stop` 43 | * Supprimez tous les conteneurs dont le nom a le préfixe `openhands-runtime-` : 44 | `docker rmi $(docker images --filter name=openhands-runtime- -q --no-trunc)` 45 | * Arrêtez et supprimez tous les conteneurs / images dont le nom a le préfixe `openhands-runtime-` 46 | * Nettoyez les conteneurs / images : `docker container prune -f && docker image prune -f` 47 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/upgrade-guide.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # ⬆️ Guide de mise à niveau 4 | 5 | ## 0.8.0 (2024-07-13) 6 | 7 | ### Changements de configuration importants 8 | 9 | Dans cette version, nous avons introduit quelques changements importants dans les configurations backend. 10 | Si vous avez uniquement utilisé OpenHands via l'interface frontend (interface web), aucune action n'est nécessaire. 11 | 12 | Voici une liste des changements importants dans les configurations. Ils ne s'appliquent qu'aux utilisateurs qui 13 | utilisent OpenHands CLI via `main.py`. Pour plus de détails, voir [#2756](https://github.com/All-Hands-AI/OpenHands/pull/2756). 14 | 15 | #### Suppression de l'option --model-name de main.py 16 | 17 | Veuillez noter que l'option `--model-name`, ou `-m`, n'existe plus. Vous devez configurer les 18 | configurations LLM dans `config.toml` ou via des variables d'environnement. 19 | 20 | #### Les groupes de configuration LLM doivent être des sous-groupes de 'llm' 21 | 22 | Avant la version 0.8, vous pouviez utiliser un nom arbitraire pour la configuration LLM dans `config.toml`, par exemple : 23 | 24 | ```toml 25 | [gpt-4o] 26 | model="gpt-4o" 27 | api_key="" 28 | ``` 29 | 30 | puis utiliser l'argument CLI `--llm-config` pour spécifier le groupe de configuration LLM souhaité 31 | par nom. Cela ne fonctionne plus. Au lieu de cela, le groupe de configuration doit être sous le groupe `llm`, 32 | par exemple : 33 | 34 | ```toml 35 | [llm.gpt-4o] 36 | model="gpt-4o" 37 | api_key="" 38 | ``` 39 | 40 | Si vous avez un groupe de configuration nommé `llm`, il n'est pas nécessaire de le modifier, il sera utilisé 41 | comme groupe de configuration LLM par défaut. 42 | 43 | #### Le groupe 'agent' ne contient plus le champ 'name' 44 | 45 | Avant la version 0.8, vous pouviez avoir ou non un groupe de configuration nommé `agent` qui 46 | ressemblait à ceci : 47 | 48 | ```toml 49 | [agent] 50 | name="CodeActAgent" 51 | memory_max_threads=2 52 | ``` 53 | 54 | Notez que le champ `name` est maintenant supprimé. Au lieu de cela, vous devez mettre le champ `default_agent` 55 | sous le groupe `core`, par exemple : 56 | 57 | ```toml 58 | [core] 59 | # autres configurations 60 | default_agent='CodeActAgent' 61 | 62 | [agent] 63 | llm_config='llm' 64 | memory_max_threads=2 65 | 66 | [agent.CodeActAgent] 67 | llm_config='gpt-4o' 68 | ``` 69 | 70 | Notez que, comme pour les sous-groupes `llm`, vous pouvez également définir des sous-groupes `agent`. 71 | De plus, un agent peut être associé à un groupe de configuration LLM spécifique. Pour plus 72 | de détails, voir les exemples dans `config.template.toml`. 73 | -------------------------------------------------------------------------------- /docs/i18n/fr/docusaurus-theme-classic/navbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": { 3 | "message": "OpenHands", 4 | "description": "The title in the navbar" 5 | }, 6 | "logo.alt": { 7 | "message": "OpenHands", 8 | "description": "The alt text of navbar logo" 9 | }, 10 | "item.label.Docs": { 11 | "message": "Docs", 12 | "description": "Navbar item with label Docs" 13 | }, 14 | "item.label.Codebase": { 15 | "message": "Codebase", 16 | "description": "Navbar item with label Codebase" 17 | }, 18 | "item.label.FAQ": { 19 | "message": "FAQ", 20 | "description": "Navbar item with label FAQ" 21 | }, 22 | "item.label.GitHub": { 23 | "message": "GitHub", 24 | "description": "Navbar item with label GitHub" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-blog/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": { 3 | "message": "博客", 4 | "description": "The title for the blog used in SEO" 5 | }, 6 | "description": { 7 | "message": "博客", 8 | "description": "The description for the blog used in SEO" 9 | }, 10 | "sidebar.title": { 11 | "message": "最近文章", 12 | "description": "The label for the left sidebar" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "version.label": { 3 | "message": "Next", 4 | "description": "The label for version current" 5 | }, 6 | "sidebar.docsSidebar.category.🤖 LLM 支持": { 7 | "message": "🤖 LLM 支持", 8 | "description": "The label for category 🤖 LLM 支持 in sidebar docsSidebar" 9 | }, 10 | "sidebar.docsSidebar.category.🚧 故障排除": { 11 | "message": "🚧 故障排除", 12 | "description": "The label for category 🚧 故障排除 in sidebar docsSidebar" 13 | }, 14 | "sidebar.apiSidebar.category.Backend": { 15 | "message": "Backend", 16 | "description": "The label for category Backend in sidebar apiSidebar" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/python/python.md: -------------------------------------------------------------------------------- 1 | # Python 文档 2 | 3 | 部署后文档将显示在此处。 4 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/python/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "items": ["python/python"], 3 | "label": "后端", 4 | "type": "category" 5 | } 6 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/about.md: -------------------------------------------------------------------------------- 1 | # 关于 OpenHands 2 | 3 | ## 研究策略 4 | 5 | 使用 LLM 实现生产级应用的完全复制是一项复杂的工作。我们的策略包括: 6 | 7 | 1. **核心技术研究:** 专注于基础研究,以理解和改进代码生成和处理的技术方面 8 | 2. **专业能力:** 通过数据整理、训练方法等提高核心组件的效率 9 | 3. **任务规划:** 开发 bug 检测、代码库管理和优化的能力 10 | 4. **评估:** 建立全面的评估指标,以更好地理解和改进我们的模型 11 | 12 | ## 默认 Agent 13 | 14 | 我们当前的默认 Agent 是 [CodeActAgent](agents),它能够生成代码并处理文件。 15 | 16 | ## 构建技术 17 | 18 | OpenHands 使用强大的框架和库组合构建,为其开发提供了坚实的基础。以下是项目中使用的关键技术: 19 | 20 | ![FastAPI](https://img.shields.io/badge/FastAPI-black?style=for-the-badge) ![uvicorn](https://img.shields.io/badge/uvicorn-black?style=for-the-badge) ![LiteLLM](https://img.shields.io/badge/LiteLLM-black?style=for-the-badge) ![Docker](https://img.shields.io/badge/Docker-black?style=for-the-badge) ![Ruff](https://img.shields.io/badge/Ruff-black?style=for-the-badge) ![MyPy](https://img.shields.io/badge/MyPy-black?style=for-the-badge) ![LlamaIndex](https://img.shields.io/badge/LlamaIndex-black?style=for-the-badge) ![React](https://img.shields.io/badge/React-black?style=for-the-badge) 21 | 22 | 请注意,这些技术的选择正在进行中,随着项目的发展,可能会添加其他技术或删除现有技术。我们努力采用最合适和最有效的工具来增强 OpenHands 的能力。 23 | 24 | ## 许可证 25 | 26 | 根据 MIT [许可证](https://github.com/All-Hands-AI/OpenHands/blob/main/LICENSE) 分发。 27 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/agents.md: -------------------------------------------------------------------------------- 1 | # 🧠 主代理和能力 2 | 3 | ## CodeActAgent 4 | 5 | ### 描述 6 | 7 | 这个代理实现了 CodeAct 的思想([论文](https://arxiv.org/abs/2402.01030),[推文](https://twitter.com/xingyaow_/status/1754556835703751087)),将 LLM 代理的**行动**整合到一个统一的**代码**行动空间中,以实现_简单性_和_性能_。 8 | 9 | 概念思想如下图所示。在每一轮中,代理可以: 10 | 11 | 1. **对话**:用自然语言与人类交流,以寻求澄清、确认等。 12 | 2. **CodeAct**:选择通过执行代码来执行任务 13 | 14 | - 执行任何有效的 Linux `bash` 命令 15 | - 使用 [交互式 Python 解释器](https://ipython.org/) 执行任何有效的 `Python` 代码。这是通过 `bash` 命令模拟的,有关更多详细信息,请参阅下面的插件系统。 16 | 17 | ![image](https://github.com/All-Hands-AI/OpenHands/assets/38853559/92b622e3-72ad-4a61-8f41-8c040b6d5fb3) 18 | 19 | ### 演示 20 | 21 | https://github.com/All-Hands-AI/OpenHands/assets/38853559/f592a192-e86c-4f48-ad31-d69282d5f6ac 22 | 23 | _使用 `gpt-4-turbo-2024-04-09` 的 CodeActAgent 执行数据科学任务(线性回归)的示例_。 24 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/architecture.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 4 3 | --- 4 | 5 | # 🏛️ 系统架构概览 6 | 7 | 这是系统架构的高层概览。系统分为两个主要组件:前端和后端。前端负责处理用户交互并显示结果。后端负责处理业务逻辑并执行代理。 8 | 9 | ![system_architecture.svg](/img/system_architecture.svg) 10 | 11 | 此概览简化显示了主要组件及其交互。有关后端架构的更详细视图,请参见[后端架构](#backend-architecture-zh-Hans)部分。 12 | 13 | # 后端架构 {#backend-architecture-zh-Hans} 14 | 15 | _**免责声明**:后端架构正在进行中,可能会有所变化。下图显示了基于图表页脚中的提交内容的当前后端架构。_ 16 | 17 | ![backend_architecture.svg](/img/backend_architecture.svg) 18 | 19 |
20 | 更新此图表 21 |
22 | 后端架构图的生成部分是自动化的。 23 | 图表是使用 py2puml 工具从代码中的类型提示生成的。 24 | 然后人工审核、调整并导出为 PNG 和 SVG。 25 | 26 | ## 前提条件 27 | 28 | - 能运行 python 环境,其中 openhands 可以执行(根据存储库根目录中的 README.md 文件中的说明) 29 | - 安装了 [py2puml](https://github.com/lucsorel/py2puml) 30 | 31 | ## 步骤 32 | 33 | 1. 通过从存储库根目录运行以下命令自动生成图表: 34 | `py2puml openhands openhands > docs/architecture/backend_architecture.puml` 35 | 36 | 2. 在 PlantUML 编辑器中打开生成的文件,例如使用 PlantUML 扩展的 Visual Studio Code 或 [PlantText](https://www.planttext.com/) 37 | 38 | 3. 审查生成的 PUML 并对图表进行所有必要的调整(添加缺失部分、修正错误、改进定位)。 39 | _py2puml 根据代码中的类型提示创建图表,因此缺失或不正确的类型提示可能导致图表不完整或不正确。_ 40 | 41 | 4. 审查新旧图表之间的差异,并手动检查更改是否正确。 42 | _确保不移除过去手动添加到图表中的和仍然相关的部分。_ 43 | 44 | 5. 将用于生成图表的提交哈希添加到图表页脚。 45 | 46 | 6. 将图表导出为 PNG 和 SVG 文件,并替换 `docs/architecture` 目录中的现有图表。这可以通过(例如 [PlantText](https://www.planttext.com/))完成。 47 | 48 |
49 |
50 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/architecture/backend.mdx: -------------------------------------------------------------------------------- 1 | 以下是翻译后的内容: 2 | 3 | # 🏛️ 系统架构 4 | 5 |
6 | OpenHands System Architecture Diagram Jul 4 2024 7 |

OpenHands 系统架构图 (2024年7月4日)

8 |
9 | 10 | 这是系统架构的高层次概述。系统分为两个主要组件:前端和后端。前端负责处理用户交互并显示结果。后端负责处理业务逻辑并执行代理。 11 | 12 | # 前端架构 {#frontend-architecture-zh} 13 | 14 | ![system_architecture.svg](/img/system_architecture.svg) 15 | 16 | 这个概述经过简化,只显示了主要组件及其交互。有关后端架构的更详细视图,请参阅下面的后端架构部分。 17 | 18 | # 后端架构 {#backend-architecture-zh} 19 | 20 | _**免责声明**:后端架构正在进行中,可能会发生变化。下图显示了基于图表页脚中显示的提交的后端当前架构。_ 21 | 22 | ![backend_architecture.svg](/img/backend_architecture.svg) 23 | 24 |
25 | 更新此图表 26 |
27 | 后端架构图的生成是部分自动化的。 28 | 该图是使用py2puml工具从代码中的类型提示生成的。然后手动审查、调整图表并导出为PNG和SVG格式。 29 | 30 | ## 先决条件 31 | 32 | - 运行可执行openhands的python环境 33 | (根据存储库根目录中README.md文件中的说明) 34 | - 已安装[py2puml](https://github.com/lucsorel/py2puml) 35 | 36 | ## 步骤 37 | 38 | 1. 通过从存储库的根目录运行以下命令来自动生成图表: 39 | `py2puml openhands openhands > docs/architecture/backend_architecture.puml` 40 | 41 | 2. 在PlantUML编辑器中打开生成的文件,例如带有PlantUML扩展的Visual Studio Code或[PlantText](https://www.planttext.com/) 42 | 43 | 3. 审查生成的PUML,并对图表进行所有必要的调整(添加缺失的部分,修复错误,改进定位)。 44 | _py2puml根据代码中的类型提示创建图表,因此缺失或不正确的类型提示可能导致图表不完整或不正确。_ 45 | 46 | 4. 审查新图表和以前图表之间的差异,并手动检查更改是否正确。 47 | _确保不要删除过去手动添加到图表中且仍然相关的部分。_ 48 | 49 | 5. 将用于生成图表的提交的提交哈希添加到图表页脚。 50 | 51 | 6. 将图表导出为PNG和SVG文件,并替换`docs/architecture`目录中的现有图表。这可以使用(例如[PlantText](https://www.planttext.com/))完成 52 | 53 |
54 |
55 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/custom_sandbox_guide.md: -------------------------------------------------------------------------------- 1 | # 💿 如何创建自定义 Docker 沙箱 2 | 3 | 默认的 OpenHands 沙箱包含一个[最小化 ubuntu 配置](https://github.com/All-Hands-AI/OpenHands/blob/main/containers/sandbox/Dockerfile)。您的应用场景可能需要在默认状态下安装额外的软件。本指南将教您如何通过使用自定义 Docker 映像来实现这一目标。 4 | 5 | 目前提供两种实现方案: 6 | 1. 从 Docker Hub 拉取已有镜像。例如,如果您想安装 `nodejs` ,您可以通过使用 `node:20` 镜像来实现。 7 | 2. 创建并使用您自定义 Docker 镜像。 8 | 9 | 若选择第一种方案,您可以直接略过 `Create Your Docker Image` 部分。 10 | 11 | 为了获得功能更丰富的环境,您可能想要考虑使用预构建的镜像,比如 [nikolaik/python-nodejs](https://hub.docker.com/r/nikolaik/python-nodejs),这个镜像预装了 Python 和 Node.js,同时还包含了许多其他有用的工具和库,比如: 12 | 13 | - Node.js: 22.x 14 | - npm: 10.x 15 | - yarn: stable 16 | - Python: latest 17 | - pip: latest 18 | - pipenv: latest 19 | - poetry: latest 20 | - uv: latest 21 | 22 | ## 环境设置 23 | 24 | 确保您能够首先通过 [Development.md](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md) 运行 OpenHands。 25 | 26 | ## 创建您的 Docker 映像 27 | 28 | 接下来,您可以开始创建一个自定义的 Docker 映像,该映像必须是基于 Debian 或 Ubuntu 的。例如,如果我们希望 OpenHands 能够访问 `node` 可执行文件,我们可以使用以下 `Dockerfile`: 29 | 30 | ```bash 31 | # 从最新版 ubuntu 开始 32 | FROM ubuntu:latest 33 | 34 | # 运行必要的更新 35 | RUN apt-get update && apt-get install 36 | 37 | # 安装 node 38 | RUN apt-get install -y nodejs 39 | ``` 40 | 41 | 然后命名并构建您选择的映像,例如“custom_image”。为此可以创建一个文件夹并将 `Dockerfile` 放入其中,并在该文件夹内运行以下命令: 42 | 43 | ```bash 44 | docker build -t custom_image . 45 | ``` 46 | 47 | 这将生成一个名为 ```custom_image``` 的新映像,并使其可用于 Docker 服务引擎。 48 | 49 | > 注意:在本文档描述的配置中,OpenHands 将在沙箱内部以“openhands”用户身份运行。因此,通过 Dockerfile 安装的所有包应可供系统上的所有用户使用,而不仅仅是 root 用户。 50 | 51 | > `Dockerfile`中,使用 `apt-get` 安装的 node 是为所有用户安装的。 52 | 53 | ## 在 config.toml 文件中指定自定义映像 54 | 55 | 在 OpenHands 的配置通过顶层的 `config.toml` 文件发生。在 OpenHands 目录下创建一个 ```config.toml``` 文件,并输入以下内容: 56 | 57 | ``` 58 | [core] 59 | workspace_base="./workspace" 60 | run_as_openhands=true 61 | sandbox_base_container_image="custom_image" 62 | ``` 63 | 64 | 对于 `sandbox_base_container_image` 的值, 您可以选择以下任意一项: 65 | 1. 在上一步中您构建的自定义镜像的名称(例如,`“custom_image”`) 66 | 2. 从 Docker Hub 拉取的镜像(例如,`“node:20”`,如果你需要一个预装 `Node.js` 的沙箱环境) 67 | 68 | ## 运行 69 | 70 | 在顶层目录下通过执行 ```make run``` 运行 OpenHands。 71 | 72 | 导航至 ```localhost:3001``` 并检查所需依赖是否可用。 73 | 74 | 在上述示例的情况下,终端中运行 `node -v` 会输出 `v20.15.0`。 75 | 76 | 恭喜您! 77 | 78 | ## 技术解释 79 | 80 | 请参考[运行时文档中自定义 Docker 镜像的章节](https://docs.all-hands.dev/modules/usage/architecture/runtime#advanced-how-openhands-builds-and-maintains-od-runtime-images)获取更详细的解释。 81 | 82 | ## 故障排除 / 错误 83 | 84 | ### 错误:```useradd: UID 1000 is not unique``` 85 | 86 | 如果在控制台输出中看到此错误,说明 OpenHands 尝试在沙箱中以 UID 1000 创建 openhands 用户,但该 UID 已经被映像中的其他部分使用(不知何故)。要解决这个问题,请更改 config.toml 文件中的 sandbox_user_id 字段为不同的值: 87 | 88 | ``` 89 | [core] 90 | workspace_base="./workspace" 91 | run_as_openhands=true 92 | sandbox_base_container_image="custom_image" 93 | sandbox_user_id="1001" 94 | ``` 95 | 96 | ### 端口使用错误 97 | 98 | 如果您遇到端口被占用或不可用的错误提示,可以尝试先用`docker ps`命令列出所有运行中的 Docker 容器,然后使用`docker rm`命令删除相关容器,最后再重新执行```make run```命令。 99 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/feedback.md: -------------------------------------------------------------------------------- 1 | # ✅ 提供反馈 2 | 3 | 在使用 OpenHands 时,您会遇到一些工作良好的情况,也会遇到一些不太理想的情况。我们鼓励您在使用 OpenHands 时提供反馈,以帮助向开发团队提供反馈,更重要的是,创建一个开放的编码智能体训练示例语料库——Share-OpenHands! 4 | 5 | ## 📝 如何提供反馈 6 | 7 | 提供反馈很容易!当您在使用 OpenHands 时,您可以在交互的任何时候按下竖起大拇指或竖起大拇指按钮。系统会提示您提供电子邮件地址(例如,以便我们在需要询问任何后续问题时与您联系),您可以选择公开或私下提供反馈。 8 | 9 | 10 | 11 | ## 📜 数据使用和隐私 12 | 13 | ### 数据共享设置 14 | 15 | 在提交数据时,您可以选择公开或私下提交。 16 | 17 | * **公开**数据将在 MIT 许可下发布,与 OpenHands 本身一样,社区可以使用这些数据来训练和测试模型。显然,您可以公开的反馈对整个社区来说会更有价值,因此当您不处理敏感信息时,我们鼓励您选择这个选项! 18 | * **私有**数据将仅与 OpenHands 团队共享,用于改进 OpenHands。 19 | 20 | ### 谁收集和存储数据? 21 | 22 | 数据由 [All Hands AI](https://all-hands.dev) 收集和存储,这是一家由 OpenHands 维护者创立的公司,旨在支持和改进 OpenHands。 23 | 24 | ### 公开数据将如何发布? 25 | 26 | 公开数据将在我们达到固定的里程碑时发布,例如 1,000 个公开示例、10,000 个公开示例等。 27 | 届时,我们将遵循以下发布流程: 28 | 29 | 1. 所有提供公开反馈的人都将收到一封电子邮件,描述数据发布情况,并有机会选择退出。 30 | 2. 负责数据发布的人员将对数据进行质量控制,删除低质量的反馈,删除提交者的电子邮件地址,并尝试删除任何敏感信息。 31 | 3. 数据将通过 github 或 Hugging Face 等常用网站在 MIT 许可下公开发布。 32 | 33 | ### 如果我想删除我的数据怎么办? 34 | 35 | 对于 All Hands AI 服务器上的数据,我们很乐意根据要求删除它: 36 | 37 | **一条数据:**如果您想删除一条数据,我们将很快添加一种机制,使用您在提交数据时显示在界面上的链接和密码来删除数据。 38 | 39 | **所有数据:**如果您想删除所有数据,或者您没有在提交数据时收到的 ID 和密码,请从您最初提交数据时注册的电子邮件地址联系`contact@all-hands.dev`。 40 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/getting-started.mdx: -------------------------------------------------------------------------------- 1 | # OpenHands 入门指南 2 | 3 | 您已经[安装了 OpenHands](./installation)并且 4 | [设置了您的 LLM](./installation#setup)。接下来呢? 5 | 6 | OpenHands 可以帮助您处理各种工程任务。但这项技术 7 | 仍然很新,我们还有很长的路要走,才能拥有无需任何指导就能承担大型、复杂 8 | 工程任务的智能体。因此,了解智能体擅长什么,以及 9 | 它可能需要什么帮助非常重要。 10 | 11 | ## Hello World 12 | 13 | 您可能想尝试的第一件事是一个简单的 "hello world" 示例。 14 | 这可能比听起来更复杂! 15 | 16 | 尝试提示智能体: 17 | > 请编写一个 bash 脚本 hello.sh,打印 "hello world!" 18 | 19 | 您应该看到,智能体不仅编写了脚本,还设置了正确的 20 | 权限并运行脚本以检查输出。 21 | 22 | 您可以继续提示智能体优化您的代码。这是一个很好的 23 | 与智能体合作的方式。从简单开始,然后迭代。 24 | 25 | > 请修改 hello.sh,使其接受一个名称作为第一个参数,但默认为 "world" 26 | 27 | 您还可以使用任何需要的语言,尽管智能体可能需要花一些 28 | 时间来设置它的环境! 29 | 30 | > 请将 hello.sh 转换为 Ruby 脚本,并运行它 31 | 32 | ## 从头开始构建 33 | 34 | 智能体在 "绿地" 任务(不需要 35 | 任何关于现有代码库的上下文的任务)方面表现得非常出色,它们可以直接从头开始。 36 | 37 | 最好从一个简单的任务开始,然后迭代它。最好也要 38 | 尽可能具体地说明您想要什么,技术栈应该是什么,等等。 39 | 40 | 例如,我们可以构建一个 TODO 应用: 41 | 42 | > 请在 React 中构建一个基本的 TODO 列表应用。它应该只有前端,所有状态 43 | > 应该保存在 localStorage 中。 44 | 45 | 一旦骨架搭建好,我们就可以继续迭代应用: 46 | 47 | > 请允许为每个任务添加一个可选的截止日期 48 | 49 | 就像正常开发一样,经常提交和推送代码是很好的做法。 50 | 这样,如果智能体偏离轨道,您总是可以恢复到旧的状态。 51 | 您可以要求智能体为您提交和推送: 52 | 53 | > 请提交更改并将其推送到名为 "feature/due-dates" 的新分支 54 | 55 | 56 | ## 添加新代码 57 | 58 | OpenHands 还可以很好地将新代码添加到现有代码库中。 59 | 60 | 例如,您可以要求 OpenHands 向您的项目添加一个新的 GitHub action 61 | 来检查您的代码。OpenHands 可能会查看您的代码库以确定应该使用什么语言, 62 | 但随后它可以直接将一个新文件放入 `./github/workflows/lint.yml` 63 | 64 | > 请添加一个 GitHub action 来检查此仓库中的代码 65 | 66 | 某些任务可能需要更多上下文。虽然 OpenHands 可以使用 `ls` 和 `grep` 67 | 在您的代码库中搜索,但提前提供上下文可以让它移动得更快、 68 | 更准确。而且这会让您花费更少的 token! 69 | 70 | > 请修改 ./backend/api/routes.js 以添加一个新路由,返回所有任务的列表 71 | 72 | > 请在 ./frontend/components 目录中添加一个新的 React 组件,用于显示 Widget 列表。 73 | > 它应该使用现有的 Widget 组件。 74 | 75 | ## 重构 76 | 77 | OpenHands 在重构现有代码方面表现出色,尤其是在小块中。 78 | 您可能不想尝试重新构建整个代码库,但拆分 79 | 长文件和函数、重命名变量等往往效果很好。 80 | 81 | > 请重命名 ./app.go 中的所有单字母变量 82 | 83 | > 请将 widget.php 中的函数 `build_and_deploy_widgets` 拆分为两个函数:`build_widgets` 和 `deploy_widgets` 84 | 85 | > 请将 ./api/routes.js 拆分为每个路由的单独文件 86 | 87 | ## Bug 修复 88 | 89 | OpenHands 还可以帮助您跟踪和修复代码中的错误。但是,任何 90 | 开发人员都知道,修复错误可能非常棘手,通常 OpenHands 需要更多上下文。 91 | 如果您已经诊断出错误,但希望 OpenHands 找出逻辑,这会有所帮助。 92 | 93 | > 目前 `/subscribe` 端点中的电子邮件字段拒绝 .io 域名。请修复这个问题。 94 | 95 | > ./app.py 中的 `search_widgets` 函数正在执行区分大小写的搜索。请使其不区分大小写。 96 | 97 | 在使用智能体进行错误修复时,进行测试驱动开发通常很有帮助。 98 | 您可以要求智能体编写一个新测试,然后迭代直到修复错误: 99 | 100 | > `hello` 函数在空字符串上崩溃。请编写一个测试来重现此错误,然后修复代码以通过测试。 101 | 102 | ## 更多 103 | 104 | OpenHands 能够在几乎任何编码任务上提供帮助。但需要一些练习 105 | 才能充分利用它。请记住: 106 | * 保持任务简单 107 | * 尽可能具体 108 | * 提供尽可能多的上下文 109 | * 经常提交和推送 110 | 111 | 有关如何充分利用 OpenHands 的更多提示,请参阅[提示最佳实践](./prompting/prompting-best-practices)。 112 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/cli-mode.md: -------------------------------------------------------------------------------- 1 | 以下是翻译后的内容: 2 | 3 | # 命令行模式 4 | 5 | OpenHands 可以在交互式命令行模式下运行,允许用户通过命令行启动交互式会话。 6 | 7 | 这种模式不同于[无头模式](headless-mode),后者是非交互式的,更适合脚本编写。 8 | 9 | ## 使用 Python 10 | 11 | 要通过命令行启动交互式 OpenHands 会话,请按照以下步骤操作: 12 | 13 | 1. 确保你已按照[开发设置说明](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md)进行操作。 14 | 15 | 2. 运行以下命令: 16 | 17 | ```bash 18 | poetry run python -m openhands.core.cli 19 | ``` 20 | 21 | 该命令将启动一个交互式会话,你可以在其中输入任务并接收来自 OpenHands 的响应。 22 | 23 | 你需要确保通过环境变量[或 `config.toml` 文件](https://github.com/All-Hands-AI/OpenHands/blob/main/config.template.toml)设置你的模型、API 密钥和其他设置。 24 | 25 | 26 | ## 使用 Docker 27 | 28 | 要在 Docker 中以命令行模式运行 OpenHands,请按照以下步骤操作: 29 | 30 | 1. 将 `WORKSPACE_BASE` 设置为你希望 OpenHands 编辑的目录: 31 | 32 | ```bash 33 | WORKSPACE_BASE=$(pwd)/workspace 34 | ``` 35 | 36 | 2. 将 `LLM_MODEL` 设置为你要使用的模型: 37 | 38 | ```bash 39 | LLM_MODEL="anthropic/claude-3-5-sonnet-20241022" 40 | ``` 41 | 42 | 3. 将 `LLM_API_KEY` 设置为你的 API 密钥: 43 | 44 | ```bash 45 | LLM_API_KEY="sk_test_12345" 46 | ``` 47 | 48 | 4. 运行以下 Docker 命令: 49 | 50 | ```bash 51 | docker run -it \ 52 | --pull=always \ 53 | -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.23-nikolaik \ 54 | -e SANDBOX_USER_ID=$(id -u) \ 55 | -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \ 56 | -e LLM_API_KEY=$LLM_API_KEY \ 57 | -e LLM_MODEL=$LLM_MODEL \ 58 | -v $WORKSPACE_BASE:/opt/workspace_base \ 59 | -v /var/run/docker.sock:/var/run/docker.sock \ 60 | --add-host host.docker.internal:host-gateway \ 61 | --name openhands-app-$(date +%Y%m%d%H%M%S) \ 62 | docker.all-hands.dev/all-hands-ai/openhands:0.23 \ 63 | python -m openhands.core.cli 64 | ``` 65 | 66 | 该命令将在 Docker 中启动一个交互式会话,你可以在其中输入任务并接收来自 OpenHands 的响应。 67 | 68 | ## CLI 命令和预期输出示例 69 | 70 | 以下是一些 CLI 命令及其预期输出的示例: 71 | 72 | ### 示例 1:简单任务 73 | 74 | ```bash 75 | How can I help? >> Write a Python script that prints "Hello, World!" 76 | ``` 77 | 78 | 预期输出: 79 | 80 | ```bash 81 | 🤖 当然!这是一个打印 "Hello, World!" 的 Python 脚本: 82 | 83 | ❯ print("Hello, World!") 84 | ``` 85 | 86 | ### 示例 2:Bash 命令 87 | 88 | ```bash 89 | How can I help? >> Create a directory named "test_dir" 90 | ``` 91 | 92 | 预期输出: 93 | 94 | ```bash 95 | 🤖 创建一个名为 "test_dir" 的目录: 96 | 97 | ❯ mkdir test_dir 98 | ``` 99 | 100 | ### 示例 3:错误处理 101 | 102 | ```bash 103 | How can I help? >> Delete a non-existent file 104 | ``` 105 | 106 | 预期输出: 107 | 108 | ```bash 109 | 🤖 发生错误。请重试。 110 | ``` 111 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/custom-sandbox-guide.md: -------------------------------------------------------------------------------- 1 | # 自定义沙箱 2 | 3 | 沙箱是代理执行任务的地方。代理不是直接在你的计算机上运行命令(这可能有风险),而是在 Docker 容器内运行。 4 | 5 | 默认的 OpenHands 沙箱(`python-nodejs:python3.12-nodejs22`,来自 [nikolaik/python-nodejs](https://hub.docker.com/r/nikolaik/python-nodejs))预装了一些软件包,如 Python 和 Node.js,但可能需要默认安装其他软件。 6 | 7 | 你有两个自定义选项: 8 | 9 | 1. 使用已有的镜像,其中包含所需的软件。 10 | 2. 创建你自己的自定义 Docker 镜像。 11 | 12 | 如果你选择第一个选项,可以跳过"创建你的 Docker 镜像"部分。 13 | 14 | ## 创建你的 Docker 镜像 15 | 16 | 要创建自定义 Docker 镜像,它必须基于 Debian。 17 | 18 | 例如,如果你想让 OpenHands 安装 `ruby`,创建一个包含以下内容的 `Dockerfile`: 19 | 20 | ```dockerfile 21 | FROM debian:latest 22 | 23 | # Install required packages 24 | RUN apt-get update && apt-get install -y ruby 25 | ``` 26 | 27 | 将此文件保存在一个文件夹中。然后,通过在终端中导航到该文件夹并运行以下命令来构建你的 Docker 镜像(例如,名为 custom-image): 28 | 29 | ```bash 30 | docker build -t custom-image . 31 | ``` 32 | 33 | 这将生成一个名为 `custom-image` 的新镜像,该镜像将在 Docker 中可用。 34 | 35 | > 请注意,在本文档描述的配置中,OpenHands 将以用户 "openhands" 的身份在沙箱内运行,因此通过 docker 文件安装的所有软件包应该对系统上的所有用户可用,而不仅仅是 root。 36 | 37 | ## 使用开发工作流 38 | 39 | ### 设置 40 | 41 | 首先,按照 [Development.md](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md) 中的说明,确保你可以运行 OpenHands。 42 | 43 | ### 指定基础沙箱镜像 44 | 45 | 在 OpenHands 目录中的 `config.toml` 文件中,将 `sandbox_base_container_image` 设置为你要使用的镜像。这可以是你已经拉取的镜像或你构建的镜像: 46 | 47 | ```bash 48 | [core] 49 | ... 50 | sandbox_base_container_image="custom-image" 51 | ``` 52 | 53 | ### 运行 54 | 55 | 通过在顶层目录中运行 ```make run``` 来运行 OpenHands。 56 | 57 | ## 技术解释 58 | 59 | 请参阅[运行时文档的自定义 docker 镜像部分](https://docs.all-hands.dev/modules/usage/architecture/runtime#advanced-how-openhands-builds-and-maintains-od-runtime-images)以获取更多详细信息。 60 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/debugging.md: -------------------------------------------------------------------------------- 1 | 以下是翻译后的内容: 2 | 3 | # 调试 4 | 5 | 以下内容旨在作为开发目的下调试 OpenHands 的入门指南。 6 | 7 | ## 服务器 / VSCode 8 | 9 | 以下 `launch.json` 将允许调试 agent、controller 和 server 元素,但不包括 sandbox(它运行在 docker 内)。它将忽略 `workspace/` 目录内的任何更改: 10 | 11 | ``` 12 | { 13 | "version": "0.2.0", 14 | "configurations": [ 15 | { 16 | "name": "OpenHands CLI", 17 | "type": "debugpy", 18 | "request": "launch", 19 | "module": "openhands.core.cli", 20 | "justMyCode": false 21 | }, 22 | { 23 | "name": "OpenHands WebApp", 24 | "type": "debugpy", 25 | "request": "launch", 26 | "module": "uvicorn", 27 | "args": [ 28 | "openhands.server.listen:app", 29 | "--reload", 30 | "--reload-exclude", 31 | "${workspaceFolder}/workspace", 32 | "--port", 33 | "3000" 34 | ], 35 | "justMyCode": false 36 | } 37 | ] 38 | } 39 | ``` 40 | 41 | 可以指定更具体的调试配置,其中包括更多参数: 42 | 43 | ``` 44 | ... 45 | { 46 | "name": "Debug CodeAct", 47 | "type": "debugpy", 48 | "request": "launch", 49 | "module": "openhands.core.main", 50 | "args": [ 51 | "-t", 52 | "Ask me what your task is.", 53 | "-d", 54 | "${workspaceFolder}/workspace", 55 | "-c", 56 | "CodeActAgent", 57 | "-l", 58 | "llm.o1", 59 | "-n", 60 | "prompts" 61 | ], 62 | "justMyCode": false 63 | } 64 | ... 65 | ``` 66 | 67 | 上面代码片段中的值可以更新,例如: 68 | 69 | * *t*: 任务 70 | * *d*: openhands 工作区目录 71 | * *c*: agent 72 | * *l*: LLM 配置 (在 config.toml 中预定义) 73 | * *n*: 会话名称 (例如 eventstream 名称) 74 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/github-action.md: -------------------------------------------------------------------------------- 1 | # 在 OpenHands 仓库中使用 GitHub Action 2 | 3 | 本指南解释了如何在 OpenHands 仓库内以及你自己的项目中使用 OpenHands GitHub Action。 4 | 5 | ## 在 OpenHands 仓库中使用 Action 6 | 7 | 要在仓库中使用 OpenHands GitHub Action,你可以: 8 | 9 | 1. 在仓库中创建一个 issue。 10 | 2. 为 issue 添加 `fix-me` 标签,或在 issue 中留下以 `@openhands-agent` 开头的评论。 11 | 12 | 该 action 将自动触发并尝试解决该 issue。 13 | 14 | ## 在新仓库中安装 Action 15 | 16 | 要在你自己的仓库中安装 OpenHands GitHub Action,请按照 [OpenHands Resolver 的 README](https://github.com/All-Hands-AI/OpenHands/blob/main/openhands/resolver/README.md) 进行操作。 17 | 18 | ## 使用技巧 19 | 20 | ### 迭代解决 21 | 22 | 1. 在仓库中创建一个 issue。 23 | 2. 为 issue 添加 `fix-me` 标签,或留下以 `@openhands-agent` 开头的评论。 24 | 3. 通过检查 pull request 来审查解决 issue 的尝试。 25 | 4. 通过一般评论、审查评论或内联线程评论提供反馈。 26 | 5. 为 pull request 添加 `fix-me` 标签,或通过以 `@openhands-agent` 开头来解决特定的评论。 27 | 28 | ### 标签与宏 29 | 30 | - 标签(`fix-me`):请求 OpenHands 解决**整个** issue 或 pull request。 31 | - 宏(`@openhands-agent`):请求 OpenHands 仅考虑 issue/pull request 描述和**特定评论**。 32 | 33 | ## 高级设置 34 | 35 | ### 添加自定义仓库设置 36 | 37 | 你可以按照 [resolver 的 README](https://github.com/All-Hands-AI/OpenHands/blob/main/openhands/resolver/README.md#providing-custom-instructions) 为 OpenHands 提供自定义指令。 38 | 39 | ### 自定义配置 40 | 41 | Github resolver 将自动检查有效的 [仓库机密](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions?tool=webui#creating-secrets-for-a-repository) 或 [仓库变量](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#creating-configuration-variables-for-a-repository) 以自定义其行为。 42 | 你可以设置的自定义选项有: 43 | 44 | | **属性名称** | **类型** | **用途** | **示例** | 45 | |----------------------------------| -------- |-------------------------------------------------------------------------------------------|------------------------------------------------------| 46 | | `LLM_MODEL` | Variable | 设置与 OpenHands 一起使用的 LLM | `LLM_MODEL="anthropic/claude-3-5-sonnet-20241022"` | 47 | | `OPENHANDS_MAX_ITER` | Variable | 设置代理迭代的最大限制 | `OPENHANDS_MAX_ITER=10` | 48 | | `OPENHANDS_MACRO` | Variable | 自定义用于调用 resolver 的默认宏 | `OPENHANDS_MACRO=@resolveit` | 49 | | `OPENHANDS_BASE_CONTAINER_IMAGE` | Variable | 自定义沙箱 ([了解更多](https://docs.all-hands.dev/modules/usage/how-to/custom-sandbox-guide)) | `OPENHANDS_BASE_CONTAINER_IMAGE="custom_image"` | 50 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/gui-mode.md: -------------------------------------------------------------------------------- 1 | # GUI 模式 2 | 3 | ## 简介 4 | 5 | OpenHands 提供了一个用户友好的图形用户界面(GUI)模式,用于与 AI 助手交互。这种模式提供了一种直观的方式来设置环境、管理设置和与 AI 通信。 6 | 7 | ## 安装和设置 8 | 9 | 1. 按照[安装](../installation)指南中的说明安装 OpenHands。 10 | 11 | 2. 运行命令后,通过 [http://localhost:3000](http://localhost:3000) 访问 OpenHands。 12 | 13 | ## 与 GUI 交互 14 | 15 | ### 初始设置 16 | 17 | 1. 首次启动时,您将看到一个设置模态框。 18 | 2. 从下拉菜单中选择 `LLM Provider` 和 `LLM Model`。 19 | 3. 输入所选提供商对应的 `API Key`。 20 | 4. 点击"保存"应用设置。 21 | 22 | ### GitHub Token 设置 23 | 24 | 如果可用,OpenHands 会自动将 `GITHUB_TOKEN` 导出到 shell 环境中。这可以通过两种方式实现: 25 | 26 | 1. **本地(OSS)**:用户直接输入他们的 GitHub token 27 | 2. **在线(SaaS)**:通过 GitHub OAuth 身份验证获取 token 28 | 29 | #### 设置本地 GitHub Token 30 | 31 | 1. **生成个人访问令牌(PAT)**: 32 | - 转到 GitHub 设置 > 开发者设置 > 个人访问令牌 > 令牌(经典) 33 | - 点击"生成新令牌(经典)" 34 | - 所需范围: 35 | - `repo`(完全控制私有仓库) 36 | - `workflow`(更新 GitHub Action 工作流) 37 | - `read:org`(读取组织数据) 38 | 39 | 2. **在 OpenHands 中输入令牌**: 40 | - 点击右上角的设置按钮(齿轮图标) 41 | - 导航到"GitHub"部分 42 | - 将令牌粘贴到"GitHub Token"字段中 43 | - 点击"保存"应用更改 44 | 45 | #### 组织令牌策略 46 | 47 | 如果您使用组织仓库,可能需要额外的设置: 48 | 49 | 1. **检查组织要求**: 50 | - 组织管理员可能会强制执行特定的令牌策略 51 | - 某些组织要求使用启用 SSO 的令牌 52 | - 查看您组织的[令牌策略设置](https://docs.github.com/en/organizations/managing-programmatic-access-to-your-organization/setting-a-personal-access-token-policy-for-your-organization) 53 | 54 | 2. **验证组织访问权限**: 55 | - 转到 GitHub 上的令牌设置 56 | - 在"组织访问"下查找组织 57 | - 如果需要,点击组织旁边的"启用 SSO" 58 | - 完成 SSO 授权过程 59 | 60 | #### OAuth 身份验证(在线模式) 61 | 62 | 在在线模式下使用 OpenHands 时,GitHub OAuth 流程: 63 | 64 | 1. 请求以下权限: 65 | - 仓库访问(读/写) 66 | - 工作流管理 67 | - 组织读取访问 68 | 69 | 2. 身份验证步骤: 70 | - 出现提示时,点击"使用 GitHub 登录" 71 | - 查看请求的权限 72 | - 授权 OpenHands 访问您的 GitHub 帐户 73 | - 如果使用组织,在出现提示时授权组织访问 74 | 75 | #### 故障排除 76 | 77 | 常见问题和解决方案: 78 | 79 | 1. **令牌无法识别**: 80 | - 确保令牌已正确保存在设置中 81 | - 检查令牌是否已过期 82 | - 验证令牌是否具有所需的范围 83 | - 尝试重新生成令牌 84 | 85 | 2. **组织访问被拒绝**: 86 | - 检查是否需要但未启用 SSO 87 | - 验证组织成员资格 88 | - 如果令牌策略阻止访问,请联系组织管理员 89 | 90 | 3. **验证令牌是否有效**: 91 | - 如果令牌有效,应用程序将显示绿色复选标记 92 | - 尝试访问仓库以确认权限 93 | - 检查浏览器控制台中是否有任何错误消息 94 | - 如果可用,使用设置中的"测试连接"按钮 95 | 96 | ### 高级设置 97 | 98 | 1. 切换`高级选项`以访问其他设置。 99 | 2. 如果列表中没有所需的模型,使用`自定义模型`文本框手动输入模型。 100 | 3. 如果您的 LLM 提供商需要,请指定`基本 URL`。 101 | 102 | ### 主界面 103 | 104 | 主界面由几个关键组件组成: 105 | 106 | 1. **聊天窗口**:中央区域,您可以在其中查看与 AI 助手的对话历史记录。 107 | 2. **输入框**:位于屏幕底部,用于输入您要发送给 AI 的消息或命令。 108 | 3. **发送按钮**:点击此按钮将消息发送给 AI。 109 | 4. **设置按钮**:打开设置模态框的齿轮图标,允许您随时调整配置。 110 | 5. **工作区面板**:显示工作区中的文件和文件夹,允许您导航和查看文件,或查看代理的过去命令或网页浏览历史记录。 111 | 112 | ### 与 AI 交互 113 | 114 | 1. 在输入框中输入您的问题、请求或任务描述。 115 | 2. 点击发送按钮或按 Enter 键提交消息。 116 | 3. AI 将处理您的输入并在聊天窗口中提供响应。 117 | 4. 您可以通过询问后续问题或提供额外信息来继续对话。 118 | 119 | ## 有效使用的提示 120 | 121 | 1. 在请求中要具体,以获得最准确和最有帮助的响应,如[提示最佳实践](../prompting/prompting-best-practices)中所述。 122 | 2. 使用工作区面板探索项目结构。 123 | 3. 使用[LLMs 部分](usage/llms/llms.md)中描述的推荐模型之一。 124 | 125 | 请记住,OpenHands 的 GUI 模式旨在使您与 AI 助手的交互尽可能流畅和直观。不要犹豫探索其功能以最大限度地提高您的工作效率。 126 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/headless-mode.md: -------------------------------------------------------------------------------- 1 | 以下是翻译后的内容: 2 | 3 | # 无头模式 4 | 5 | 你可以使用单个命令运行 OpenHands,而无需启动 Web 应用程序。 6 | 这使得使用 OpenHands 编写脚本和自动化任务变得很容易。 7 | 8 | 这与[CLI 模式](cli-mode)不同,后者是交互式的,更适合主动开发。 9 | 10 | ## 使用 Python 11 | 12 | 要在 Python 中以无头模式运行 OpenHands, 13 | [请按照开发设置说明](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md), 14 | 然后运行: 15 | 16 | ```bash 17 | poetry run python -m openhands.core.main -t "write a bash script that prints hi" 18 | ``` 19 | 20 | 你需要确保通过环境变量 21 | [或 `config.toml` 文件](https://github.com/All-Hands-AI/OpenHands/blob/main/config.template.toml) 22 | 设置你的模型、API 密钥和其他设置。 23 | 24 | ## 使用 Docker 25 | 26 | 1. 将 `WORKSPACE_BASE` 设置为你希望 OpenHands 编辑的目录: 27 | 28 | ```bash 29 | WORKSPACE_BASE=$(pwd)/workspace 30 | ``` 31 | 32 | 2. 将 `LLM_MODEL` 设置为你要使用的模型: 33 | 34 | ```bash 35 | LLM_MODEL="anthropic/claude-3-5-sonnet-20241022" 36 | 37 | ``` 38 | 39 | 3. 将 `LLM_API_KEY` 设置为你的 API 密钥: 40 | 41 | ```bash 42 | LLM_API_KEY="sk_test_12345" 43 | ``` 44 | 45 | 4. 运行以下 Docker 命令: 46 | 47 | ```bash 48 | docker run -it \ 49 | --pull=always \ 50 | -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.23-nikolaik \ 51 | -e SANDBOX_USER_ID=$(id -u) \ 52 | -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \ 53 | -e LLM_API_KEY=$LLM_API_KEY \ 54 | -e LLM_MODEL=$LLM_MODEL \ 55 | -e LOG_ALL_EVENTS=true \ 56 | -v $WORKSPACE_BASE:/opt/workspace_base \ 57 | -v /var/run/docker.sock:/var/run/docker.sock \ 58 | --add-host host.docker.internal:host-gateway \ 59 | --name openhands-app-$(date +%Y%m%d%H%M%S) \ 60 | docker.all-hands.dev/all-hands-ai/openhands:0.23 \ 61 | python -m openhands.core.main -t "write a bash script that prints hi" --no-auto-continue 62 | ``` 63 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/persist-session-data.md: -------------------------------------------------------------------------------- 1 | 以下是翻译后的内容: 2 | 3 | # 持久化会话数据 4 | 5 | 使用标准安装,会话数据存储在内存中。目前,如果 OpenHands 服务重新启动,之前的会话将失效(生成新的密钥),因此无法恢复。 6 | 7 | ## 如何持久化会话数据 8 | 9 | ### 开发工作流 10 | 在 `config.toml` 文件中,指定以下内容: 11 | ``` 12 | [core] 13 | ... 14 | file_store="local" 15 | file_store_path="/absolute/path/to/openhands/cache/directory" 16 | jwt_secret="secretpass" 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/installation.mdx: -------------------------------------------------------------------------------- 1 | # 安装 2 | 3 | ## 系统要求 4 | 5 | * Docker 版本 26.0.0+ 或 Docker Desktop 4.31.0+。 6 | * 你必须使用 Linux 或 Mac OS。 7 | * 如果你使用的是 Windows,你必须使用 [WSL](https://learn.microsoft.com/en-us/windows/wsl/install)。 8 | 9 | ## 启动应用 10 | 11 | 在 Docker 中运行 OpenHands 是最简单的方式。 12 | 13 | ```bash 14 | docker pull docker.all-hands.dev/all-hands-ai/runtime:0.23-nikolaik 15 | 16 | docker run -it --rm --pull=always \ 17 | -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.23-nikolaik \ 18 | -e LOG_ALL_EVENTS=true \ 19 | -v /var/run/docker.sock:/var/run/docker.sock \ 20 | -p 3000:3000 \ 21 | --add-host host.docker.internal:host-gateway \ 22 | --name openhands-app \ 23 | docker.all-hands.dev/all-hands-ai/openhands:0.23 24 | ``` 25 | 26 | 你也可以在可脚本化的[无头模式](https://docs.all-hands.dev/modules/usage/how-to/headless-mode)下运行 OpenHands,作为[交互式 CLI](https://docs.all-hands.dev/modules/usage/how-to/cli-mode),或使用 [OpenHands GitHub Action](https://docs.all-hands.dev/modules/usage/how-to/github-action)。 27 | 28 | ## 设置 29 | 30 | 运行上述命令后,你可以在 [http://localhost:3000](http://localhost:3000) 找到正在运行的 OpenHands。 31 | 32 | 启动 OpenHands 后,你会看到一个设置模态框。你**必须**选择一个 `LLM Provider` 和 `LLM Model`,并输入相应的 `API Key`。 33 | 这些设置可以随时通过选择 UI 中的 `Settings` 按钮(齿轮图标)进行更改。 34 | 35 | 如果所需的 `LLM Model` 不在列表中,你可以切换 `Advanced Options`,并在 `Custom Model` 文本框中使用正确的前缀手动输入。 36 | `Advanced Options` 还允许你在需要时指定 `Base URL`。 37 | 38 |
39 | settings-modal 40 | settings-modal 41 |
42 | 43 | ## 版本 44 | 45 | 上述命令拉取最新的 OpenHands 稳定版本。你还有其他选择: 46 | - 对于特定版本,使用 `docker.all-hands.dev/all-hands-ai/openhands:$VERSION`,将 $VERSION 替换为版本号。 47 | - 我们使用语义化版本,并发布主要版本、次要版本和补丁标签。因此,`0.9` 将自动指向最新的 `0.9.x` 版本,而 `0` 将指向最新的 `0.x.x` 版本。 48 | - 对于最新的开发版本,你可以使用 `docker.all-hands.dev/all-hands-ai/openhands:main`。此版本不稳定,仅建议用于测试或开发目的。 49 | 50 | 你可以根据稳定性要求和所需功能选择最适合你需求的标签。 51 | 52 | 有关开发工作流程,请参阅 [Development.md](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md)。 53 | 54 | 遇到问题了吗?查看我们的[故障排除指南](https://docs.all-hands.dev/modules/usage/troubleshooting)。 55 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/llms/azure-llms.md: -------------------------------------------------------------------------------- 1 | # Azure 2 | 3 | OpenHands 使用 LiteLLM 调用 Azure 的聊天模型。你可以在[这里](https://docs.litellm.ai/docs/providers/azure)找到他们关于使用 Azure 作为提供商的文档。 4 | 5 | ## Azure OpenAI 配置 6 | 7 | 运行 OpenHands 时,你需要在 [docker run 命令](/modules/usage/installation#start-the-app)中使用 `-e` 设置以下环境变量: 8 | 9 | ``` 10 | LLM_API_VERSION="" # 例如 "2023-05-15" 11 | ``` 12 | 13 | 示例: 14 | ```bash 15 | docker run -it --pull=always \ 16 | -e LLM_API_VERSION="2023-05-15" 17 | ... 18 | ``` 19 | 20 | 然后在 OpenHands UI 的设置中设置以下内容: 21 | 22 | :::note 23 | 你需要你的 ChatGPT 部署名称,可以在 Azure 的部署页面找到。下面将其称为 <deployment-name>。 24 | ::: 25 | 26 | * 启用 `Advanced Options` 27 | * 将 `Custom Model` 设置为 azure/<deployment-name> 28 | * 将 `Base URL` 设置为你的 Azure API 基础 URL(例如 `https://example-endpoint.openai.azure.com`) 29 | * 将 `API Key` 设置为你的 Azure API 密钥 30 | 31 | ## Embeddings 32 | 33 | OpenHands 使用 llama-index 进行 embeddings。你可以在[这里](https://docs.llamaindex.ai/en/stable/api_reference/embeddings/azure_openai/)找到他们关于 Azure 的文档。 34 | 35 | ### Azure OpenAI 配置 36 | 37 | 运行 OpenHands 时,在 [docker run 命令](/modules/usage/installation#start-the-app)中使用 `-e` 设置以下环境变量: 38 | 39 | ``` 40 | LLM_EMBEDDING_MODEL="azureopenai" 41 | LLM_EMBEDDING_DEPLOYMENT_NAME="" # 例如 "TextEmbedding..." 42 | LLM_API_VERSION="" # 例如 "2024-02-15-preview" 43 | ``` 44 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/llms/azureLLMs.md: -------------------------------------------------------------------------------- 1 | # Azure OpenAI 大型语言模型 2 | 3 | ## 完成 4 | 5 | OpenHands 使用 LiteLLM 进行完成调用。你可以在 Azure 的文档中找到他们的文档 [这里](https://docs.litellm.ai/docs/providers/azure) 6 | 7 | ### Azure openai 配置 8 | 9 | 在运行 OpenHands Docker 镜像时,你需要使用 `-e` 设置以下环境变量: 10 | 11 | ``` 12 | LLM_BASE_URL="" # 示例: "https://openai-gpt-4-test-v-1.openai.azure.com/" 13 | LLM_API_KEY="" 14 | LLM_MODEL="azure/" 15 | LLM_API_VERSION = "" # 示例: "2024-02-15-preview" 16 | ``` 17 | 18 | :::note 19 | 你可以在 Azure 的部署页面找到你的 ChatGPT 部署名称。它可能与默认或最初设置的聊天模型名称相同(例如 'GPT4-1106-preview'),但不一定相同。运行 OpenHands,当你在浏览器中加载它时,进入设置并按照上述方式设置模型: "azure/<your-actual-gpt-deployment-name>"。如果列表中没有,请输入你自己的文本并保存。 20 | ::: 21 | 22 | ## 嵌入 23 | 24 | OpenHands 使用 llama-index 进行嵌入。你可以在 Azure 的文档中找到他们的文档 [这里](https://docs.llamaindex.ai/en/stable/api_reference/embeddings/azure_openai/) 25 | 26 | ### Azure openai 配置 27 | 28 | Azure OpenAI 嵌入使用的模型是 "text-embedding-ada-002"。 29 | 你需要在你的 Azure 账户中为这个模型设置正确的部署名称。 30 | 31 | 在 Docker 中运行 OpenHands 时,使用 `-e` 设置以下环境变量: 32 | 33 | ``` 34 | LLM_EMBEDDING_MODEL="azureopenai" 35 | LLM_EMBEDDING_DEPLOYMENT_NAME = "" # 示例: "TextEmbedding..." 36 | LLM_API_VERSION = "" # 示例: "2024-02-15-preview" 37 | ``` 38 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/llms/google-llms.md: -------------------------------------------------------------------------------- 1 | # Google Gemini/Vertex 2 | 3 | OpenHands 使用 LiteLLM 调用 Google 的聊天模型。你可以在以下文档中找到使用 Google 作为提供商的说明: 4 | 5 | - [Gemini - Google AI Studio](https://docs.litellm.ai/docs/providers/gemini) 6 | - [VertexAI - Google Cloud Platform](https://docs.litellm.ai/docs/providers/vertex) 7 | 8 | ## Gemini - Google AI Studio 配置 9 | 10 | 运行 OpenHands 时,你需要在设置中设置以下内容: 11 | * 将 `LLM Provider` 设置为 `Gemini` 12 | * 将 `LLM Model` 设置为你将使用的模型。 13 | 如果模型不在列表中,请切换 `Advanced Options`,并在 `Custom Model` 中输入(例如 gemini/<model-name> 如 `gemini/gemini-1.5-pro`)。 14 | * 将 `API Key` 设置为你的 Gemini API 密钥 15 | 16 | ## VertexAI - Google Cloud Platform 配置 17 | 18 | 要在运行 OpenHands 时通过 Google Cloud Platform 使用 Vertex AI,你需要使用 [docker run 命令](/modules/usage/installation#start-the-app) 中的 `-e` 设置以下环境变量: 19 | 20 | ``` 21 | GOOGLE_APPLICATION_CREDENTIALS="" 22 | VERTEXAI_PROJECT="" 23 | VERTEXAI_LOCATION="" 24 | ``` 25 | 26 | 然后在设置中设置以下内容: 27 | * 将 `LLM Provider` 设置为 `VertexAI` 28 | * 将 `LLM Model` 设置为你将使用的模型。 29 | 如果模型不在列表中,请切换 `Advanced Options`,并在 `Custom Model` 中输入(例如 vertex_ai/<model-name>)。 30 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/llms/googleLLMs.md: -------------------------------------------------------------------------------- 1 | # Google Gemini/Vertex LLM 2 | 3 | ## Completion 4 | 5 | OpenHands 使用 LiteLLM 进行补全调用。以下资源与使用 OpenHands 和 Google 的 LLM 相关: 6 | 7 | - [Gemini - Google AI Studio](https://docs.litellm.ai/docs/providers/gemini) 8 | - [VertexAI - Google Cloud Platform](https://docs.litellm.ai/docs/providers/vertex) 9 | 10 | ### Gemini - Google AI Studio 配置 11 | 12 | 在运行 OpenHands Docker 镜像时,通过 Google AI Studio 使用 Gemini,你需要使用 `-e` 设置以下环境变量: 13 | 14 | ``` 15 | GEMINI_API_KEY="" 16 | LLM_MODEL="gemini/gemini-1.5-pro" 17 | ``` 18 | 19 | ### Vertex AI - Google Cloud Platform 配置 20 | 21 | 在运行 OpenHands Docker 镜像时,通过 Google Cloud Platform 使用 Vertex AI,你需要使用 `-e` 设置以下环境变量: 22 | 23 | ``` 24 | GOOGLE_APPLICATION_CREDENTIALS="" 25 | VERTEXAI_PROJECT="" 26 | VERTEXAI_LOCATION="" 27 | LLM_MODEL="vertex_ai/" 28 | ``` 29 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/llms/groq.md: -------------------------------------------------------------------------------- 1 | # Groq 2 | 3 | OpenHands 使用 LiteLLM 在 Groq 上调用聊天模型。你可以在[这里](https://docs.litellm.ai/docs/providers/groq)找到他们关于使用 Groq 作为提供商的文档。 4 | 5 | ## 配置 6 | 7 | 在运行 OpenHands 时,你需要在设置中设置以下内容: 8 | * `LLM Provider` 设置为 `Groq` 9 | * `LLM Model` 设置为你将使用的模型。[访问此处查看 Groq 托管的模型列表](https://console.groq.com/docs/models)。如果模型不在列表中,切换 `Advanced Options`,并在 `Custom Model` 中输入它(例如 groq/<model-name> 如 `groq/llama3-70b-8192`)。 10 | * `API key` 设置为你的 Groq API 密钥。要查找或创建你的 Groq API 密钥,[请参见此处](https://console.groq.com/keys)。 11 | 12 | 13 | 14 | ## 使用 Groq 作为 OpenAI 兼容端点 15 | 16 | Groq 的聊天完成端点[大部分与 OpenAI 兼容](https://console.groq.com/docs/openai)。因此,你可以像访问任何 OpenAI 兼容端点一样访问 Groq 模型。你可以在设置中设置以下内容: 17 | * 启用 `Advanced Options` 18 | * `Custom Model` 设置为前缀 `openai/` + 你将使用的模型(例如 `openai/llama3-70b-8192`) 19 | * `Base URL` 设置为 `https://api.groq.com/openai/v1` 20 | * `API Key` 设置为你的 Groq API 密钥 21 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/llms/litellm-proxy.md: -------------------------------------------------------------------------------- 1 | 以下是翻译后的内容: 2 | 3 | # LiteLLM 代理 4 | 5 | OpenHands 支持使用 [LiteLLM 代理](https://docs.litellm.ai/docs/proxy/quick_start)来访问各种 LLM 提供商。 6 | 7 | ## 配置 8 | 9 | 要在 OpenHands 中使用 LiteLLM 代理,你需要: 10 | 11 | 1. 设置一个 LiteLLM 代理服务器(参见 [LiteLLM 文档](https://docs.litellm.ai/docs/proxy/quick_start)) 12 | 2. 运行 OpenHands 时,你需要在 OpenHands UI 的设置中设置以下内容: 13 | * 启用`高级选项` 14 | * 将`自定义模型`设置为前缀 `litellm_proxy/` + 你将使用的模型(例如 `litellm_proxy/anthropic.claude-3-5-sonnet-20241022-v2:0`) 15 | * 将`Base URL`设置为你的 LiteLLM 代理 URL(例如 `https://your-litellm-proxy.com`) 16 | * 将`API Key`设置为你的 LiteLLM 代理 API 密钥 17 | 18 | ## 支持的模型 19 | 20 | 支持的模型取决于你的 LiteLLM 代理配置。OpenHands 支持你的 LiteLLM 代理配置的任何模型。 21 | 22 | 有关可用模型及其名称的列表,请参阅你的 LiteLLM 代理配置。 23 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/llms/llms.md: -------------------------------------------------------------------------------- 1 | # 🤖 LLM 后端 2 | 3 | OpenHands 可以连接到 LiteLLM 支持的任何 LLM。但是,它需要一个强大的模型才能工作。 4 | 5 | ## 模型推荐 6 | 7 | 根据我们对编码任务语言模型的评估(使用 SWE-bench 数据集),我们可以为模型选择提供一些建议。一些分析可以在[这篇比较 LLM 的博客文章](https://www.all-hands.dev/blog/evaluation-of-llms-as-coding-agents-on-swe-bench-at-30x-speed)和[这篇包含一些最新结果的博客文章](https://www.all-hands.dev/blog/openhands-codeact-21-an-open-state-of-the-art-software-development-agent)中找到。 8 | 9 | 在选择模型时,要同时考虑输出质量和相关成本。以下是调查结果的总结: 10 | 11 | - Claude 3.5 Sonnet 是目前最好的,在 SWE-Bench Verified 上使用 OpenHands 中的默认代理可以达到 53% 的解决率。 12 | - GPT-4o 落后于 Claude,而 o1-mini 的表现甚至比 GPT-4o 还要差一些。我们进行了一些分析,简单来说,o1 有时会"想得太多",在可以直接完成任务的情况下执行额外的环境配置任务。 13 | - 最后,最强大的开放模型是 Llama 3.1 405 B 和 deepseek-v2.5,它们表现得相当不错,甚至超过了一些封闭模型。 14 | 15 | 请参阅[完整文章](https://www.all-hands.dev/blog/evaluation-of-llms-as-coding-agents-on-swe-bench-at-30x-speed)了解更多详情。 16 | 17 | 根据这些发现和社区反馈,以下模型已经验证可以与 OpenHands 很好地配合使用: 18 | 19 | - claude-3-5-sonnet(推荐) 20 | - gpt-4 / gpt-4o 21 | - llama-3.1-405b 22 | - deepseek-v2.5 23 | 24 | :::warning 25 | OpenHands 将向您配置的 LLM 发出许多提示。这些 LLM 中的大多数都需要付费,因此请务必设置支出限制并监控使用情况。 26 | ::: 27 | 28 | 如果您已经成功地使用特定的未列出的 LLM 运行 OpenHands,请将它们添加到已验证列表中。我们也鼓励您提交 PR 分享您的设置过程,以帮助其他使用相同提供商和 LLM 的人! 29 | 30 | 有关可用提供商和模型的完整列表,请查阅 [litellm 文档](https://docs.litellm.ai/docs/providers)。 31 | 32 | :::note 33 | 目前大多数本地和开源模型都没有那么强大。使用这些模型时,您可能会看到消息之间的长时间等待、响应不佳或有关 JSON 格式错误的错误。OpenHands 只能和驱动它的模型一样强大。但是,如果您确实找到了可以使用的模型,请将它们添加到上面的已验证列表中。 34 | ::: 35 | 36 | ## LLM 配置 37 | 38 | 以下内容可以通过设置在 OpenHands UI 中设置: 39 | 40 | - `LLM Provider` 41 | - `LLM Model` 42 | - `API Key` 43 | - `Base URL`(通过`Advanced Settings`) 44 | 45 | 有些设置可能对某些 LLM/提供商是必需的,但无法通过 UI 设置。相反,可以通过传递给 [docker run 命令](/modules/usage/installation#start-the-app)的环境变量使用 `-e` 来设置这些变量: 46 | 47 | - `LLM_API_VERSION` 48 | - `LLM_EMBEDDING_MODEL` 49 | - `LLM_EMBEDDING_DEPLOYMENT_NAME` 50 | - `LLM_DROP_PARAMS` 51 | - `LLM_DISABLE_VISION` 52 | - `LLM_CACHING_PROMPT` 53 | 54 | 我们有一些使用特定模型提供商运行 OpenHands 的指南: 55 | 56 | - [Azure](llms/azure-llms) 57 | - [Google](llms/google-llms) 58 | - [Groq](llms/groq) 59 | - [LiteLLM Proxy](llms/litellm-proxy) 60 | - [OpenAI](llms/openai-llms) 61 | - [OpenRouter](llms/openrouter) 62 | 63 | ### API 重试和速率限制 64 | 65 | LLM 提供商通常有速率限制,有时非常低,可能需要重试。如果 OpenHands 收到速率限制错误(429 错误代码)、API 连接错误或其他瞬时错误,它将自动重试请求。 66 | 67 | 您可以根据使用的提供商的需要自定义这些选项。查看他们的文档,并设置以下环境变量来控制重试次数和重试之间的时间: 68 | 69 | - `LLM_NUM_RETRIES`(默认为 8) 70 | - `LLM_RETRY_MIN_WAIT`(默认为 15 秒) 71 | - `LLM_RETRY_MAX_WAIT`(默认为 120 秒) 72 | - `LLM_RETRY_MULTIPLIER`(默认为 2) 73 | 74 | 如果您在开发模式下运行 OpenHands,也可以在 `config.toml` 文件中设置这些选项: 75 | 76 | ```toml 77 | [llm] 78 | num_retries = 8 79 | retry_min_wait = 15 80 | retry_max_wait = 120 81 | retry_multiplier = 2 82 | ``` 83 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/llms/openai-llms.md: -------------------------------------------------------------------------------- 1 | # OpenAI 2 | 3 | OpenHands 使用 LiteLLM 调用 OpenAI 的聊天模型。你可以在[这里](https://docs.litellm.ai/docs/providers/openai)找到他们关于使用 OpenAI 作为提供商的文档。 4 | 5 | ## 配置 6 | 7 | 运行 OpenHands 时,你需要在设置中设置以下内容: 8 | * `LLM Provider` 设置为 `OpenAI` 9 | * `LLM Model` 设置为你将使用的模型。 10 | [访问此处查看 LiteLLM 支持的 OpenAI 模型的完整列表。](https://docs.litellm.ai/docs/providers/openai#openai-chat-completion-models) 11 | 如果模型不在列表中,请切换 `Advanced Options`,并在 `Custom Model` 中输入它(例如 openai/<model-name> 如 `openai/gpt-4o`)。 12 | * `API Key` 设置为你的 OpenAI API 密钥。要查找或创建你的 OpenAI 项目 API 密钥,[请参阅此处](https://platform.openai.com/api-keys)。 13 | 14 | ## 使用 OpenAI 兼容端点 15 | 16 | 就像 OpenAI 聊天补全一样,我们使用 LiteLLM 进行 OpenAI 兼容端点。你可以在[这里](https://docs.litellm.ai/docs/providers/openai_compatible)找到他们关于此主题的完整文档。 17 | 18 | ## 使用 OpenAI 代理 19 | 20 | 如果你使用 OpenAI 代理,你需要在设置中设置以下内容: 21 | * 启用 `Advanced Options` 22 | * `Custom Model` 设置为 openai/<model-name>(例如 `openai/gpt-4o` 或 openai/<proxy-prefix>/<model-name>) 23 | * `Base URL` 设置为你的 OpenAI 代理的 URL 24 | * `API Key` 设置为你的 OpenAI API 密钥 25 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/llms/openrouter.md: -------------------------------------------------------------------------------- 1 | 以下是翻译后的内容: 2 | 3 | # OpenRouter 4 | 5 | OpenHands 使用 LiteLLM 调用 OpenRouter 上的聊天模型。你可以在[这里](https://docs.litellm.ai/docs/providers/openrouter)找到他们关于使用 OpenRouter 作为提供者的文档。 6 | 7 | ## 配置 8 | 9 | 运行 OpenHands 时,你需要在设置中设置以下内容: 10 | * `LLM Provider` 设置为 `OpenRouter` 11 | * `LLM Model` 设置为你将使用的模型。 12 | [访问此处查看 OpenRouter 模型的完整列表](https://openrouter.ai/models)。 13 | 如果模型不在列表中,请切换 `Advanced Options`,并在 `Custom Model` 中输入(例如 openrouter/<model-name> 如 `openrouter/anthropic/claude-3.5-sonnet`)。 14 | * `API Key` 设置为你的 OpenRouter API 密钥。 15 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/prompting-best-practices.md: -------------------------------------------------------------------------------- 1 | 以下是翻译后的内容: 2 | 3 | # 提示最佳实践 4 | 5 | 在使用 OpenHands AI 软件开发者时,提供清晰有效的提示至关重要。本指南概述了创建提示的最佳实践,以产生最准确和最有用的响应。 6 | 7 | ## 好的提示的特点 8 | 9 | 好的提示是: 10 | 11 | 1. **具体的**: 它们准确解释应该添加什么功能或需要修复什么错误。 12 | 2. **位置特定的**: 如果已知,它们解释了应该修改代码库中的哪些位置。 13 | 3. **适当范围的**: 它们应该是单个功能的大小,通常不超过100行代码。 14 | 15 | ## 示例 16 | 17 | ### 好的提示示例 18 | 19 | 1. "在 `utils/math_operations.py` 中添加一个函数 `calculate_average`,它接受一个数字列表作为输入并返回它们的平均值。" 20 | 21 | 2. "修复 `frontend/src/components/UserProfile.tsx` 中第42行发生的 TypeError。错误表明我们试图访问 undefined 的属性。" 22 | 23 | 3. "为注册表单中的电子邮件字段实现输入验证。更新 `frontend/src/components/RegistrationForm.tsx` 以在提交之前检查电子邮件是否为有效格式。" 24 | 25 | ### 不好的提示示例 26 | 27 | 1. "让代码更好。"(太模糊,不具体) 28 | 29 | 2. "重写整个后端以使用不同的框架。"(范围不合适) 30 | 31 | 3. "用户身份验证中有一个错误。你能找到并修复它吗?"(缺乏具体性和位置信息) 32 | 33 | ## 有效提示的技巧 34 | 35 | 1. 尽可能具体地说明期望的结果或要解决的问题。 36 | 2. 提供上下文,包括相关的文件路径和行号(如果可用)。 37 | 3. 将大型任务分解为更小、更易管理的提示。 38 | 4. 包括任何相关的错误消息或日志。 39 | 5. 如果从上下文中不明显,请指定编程语言或框架。 40 | 41 | 请记住,您的提示越精确和信息量大,AI 就越能帮助您开发或修改 OpenHands 软件。 42 | 43 | 有关更多有用提示的示例,请参阅 [OpenHands 入门](./getting-started)。 44 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/prompting/customization.md: -------------------------------------------------------------------------------- 1 | # 自定义代理行为 2 | 3 | OpenHands 可以通过提供特定仓库的上下文和指南来进行自定义,以更有效地处理特定仓库。本节将解释如何为你的项目优化 OpenHands。 4 | 5 | ## 仓库配置 6 | 7 | 你可以通过在仓库根目录下创建 `.openhands` 目录来自定义 OpenHands 在你的仓库中的行为。至少,它应该包含文件 `.openhands/microagents/repo.md`,其中包括每次代理处理此仓库时都会提供给代理的指令。 8 | 9 | 我们建议包括以下信息: 10 | 1. **仓库概述**:简要描述你的项目的目的和架构 11 | 2. **目录结构**:关键目录及其用途 12 | 3. **开发指南**:项目特定的编码标准和实践 13 | 4. **测试要求**:如何运行测试以及需要哪些类型的测试 14 | 5. **设置说明**:构建和运行项目所需的步骤 15 | 16 | ### 仓库配置示例 17 | `.openhands/microagents/repo.md` 文件示例: 18 | ``` 19 | Repository: MyProject 20 | Description: A web application for task management 21 | 22 | Directory Structure: 23 | - src/: Main application code 24 | - tests/: Test files 25 | - docs/: Documentation 26 | 27 | Setup: 28 | - Run `npm install` to install dependencies 29 | - Use `npm run dev` for development 30 | - Run `npm test` for testing 31 | 32 | Guidelines: 33 | - Follow ESLint configuration 34 | - Write tests for all new features 35 | - Use TypeScript for new code 36 | ``` 37 | 38 | ### 自定义提示 39 | 40 | 在处理自定义仓库时: 41 | 42 | 1. **参考项目标准**:提及你的项目中使用的特定编码标准或模式 43 | 2. **包括上下文**:参考相关文档或现有实现 44 | 3. **指定测试要求**:在提示中包括项目特定的测试要求 45 | 46 | 自定义提示示例: 47 | ``` 48 | Add a new task completion feature to src/components/TaskList.tsx following our existing component patterns. 49 | Include unit tests in tests/components/ and update the documentation in docs/features/. 50 | The component should use our shared styling from src/styles/components. 51 | ``` 52 | 53 | ### 仓库自定义的最佳实践 54 | 55 | 1. **保持说明更新**:随着项目的发展,定期更新你的 `.openhands` 目录 56 | 2. **要具体**:包括特定于你的项目的具体路径、模式和要求 57 | 3. **记录依赖项**:列出开发所需的所有工具和依赖项 58 | 4. **包括示例**:提供项目中良好代码模式的示例 59 | 5. **指定约定**:记录命名约定、文件组织和代码风格偏好 60 | 61 | 通过为你的仓库自定义 OpenHands,你将获得更准确、更一致的结果,这些结果符合你的项目标准和要求。 62 | 63 | ## 其他微代理 64 | 你可以在 `.openhands/microagents/` 目录中创建其他指令,如果找到特定关键字,如 `test`、`frontend` 或 `migration`,这些指令将发送给代理。有关更多信息,请参阅 [Microagents](microagents.md)。 65 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/prompting/prompting-best-practices.md: -------------------------------------------------------------------------------- 1 | 以下是翻译后的内容: 2 | 3 | # 提示最佳实践 4 | 5 | 在使用 OpenHands AI 软件开发者时,提供清晰有效的提示至关重要。本指南概述了创建提示的最佳实践,以产生最准确和最有用的响应。 6 | 7 | ## 好的提示的特点 8 | 9 | 好的提示应该: 10 | 11 | 1. **具体**: 它们准确解释应该添加什么功能或需要修复什么错误。 12 | 2. **位置特定**: 如果已知,它们解释了应该修改代码库中的哪些位置。 13 | 3. **适当范围**: 它们应该是单个功能的大小,通常不超过100行代码。 14 | 15 | ## 示例 16 | 17 | ### 好的提示示例 18 | 19 | 1. "在 `utils/math_operations.py` 中添加一个函数 `calculate_average`,它接受一个数字列表作为输入并返回它们的平均值。" 20 | 21 | 2. "修复 `frontend/src/components/UserProfile.tsx` 第42行发生的 TypeError。错误表明我们试图访问 undefined 的属性。" 22 | 23 | 3. "为注册表单中的电子邮件字段实现输入验证。更新 `frontend/src/components/RegistrationForm.tsx` 以在提交之前检查电子邮件是否为有效格式。" 24 | 25 | ### 不好的提示示例 26 | 27 | 1. "让代码变得更好。"(太模糊,不具体) 28 | 29 | 2. "用不同的框架重写整个后端。"(范围不合适) 30 | 31 | 3. "用户身份验证中有一个错误。你能找到并修复它吗?"(缺乏具体性和位置信息) 32 | 33 | ## 有效提示的技巧 34 | 35 | 1. 尽可能具体地说明所需的结果或要解决的问题。 36 | 2. 提供上下文,包括相关的文件路径和行号(如果可用)。 37 | 3. 将大型任务分解为更小、更易管理的提示。 38 | 4. 包括任何相关的错误消息或日志。 39 | 5. 如果从上下文中不明显,请指定编程语言或框架。 40 | 41 | 请记住,您的提示越精确和信息量大,AI 就越能帮助您开发或修改 OpenHands 软件。 42 | 43 | 有关更多有用提示的示例,请参阅[OpenHands 入门](../getting-started)。 44 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/runtimes.md: -------------------------------------------------------------------------------- 1 | # 运行时配置 2 | 3 | 运行时是 OpenHands 代理可以编辑文件和运行命令的环境。 4 | 5 | 默认情况下,OpenHands 使用基于 Docker 的运行时,在您的本地计算机上运行。这意味着您只需要为使用的 LLM 付费,并且您的代码只会发送到 LLM。 6 | 7 | 我们还支持"远程"运行时,通常由第三方管理。它们可以使设置更简单、更具可扩展性,特别是当您并行运行多个 OpenHands 对话时(例如进行评估)。 8 | 9 | ## Docker 运行时 10 | 这是启动 OpenHands 时使用的默认运行时。您可能会注意到传递给 `docker run` 的一些标志使这成为可能: 11 | 12 | ``` 13 | docker run # ... 14 | -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.23-nikolaik \ 15 | -v /var/run/docker.sock:/var/run/docker.sock \ 16 | # ... 17 | ``` 18 | 19 | 来自 nikolaik 的 `SANDBOX_RUNTIME_CONTAINER_IMAGE` 是一个预构建的运行时镜像,其中包含我们的运行时服务器,以及一些用于 Python 和 NodeJS 的基本实用程序。您也可以[构建自己的运行时镜像](how-to/custom-sandbox-guide)。 20 | 21 | ### 连接到您的文件系统 22 | 这里一个有用的功能是能够连接到您的本地文件系统。 23 | 24 | 要将文件系统挂载到运行时,首先设置 WORKSPACE_BASE: 25 | ```bash 26 | export WORKSPACE_BASE=/path/to/your/code 27 | 28 | # Linux 和 Mac 示例 29 | # export WORKSPACE_BASE=$HOME/OpenHands 30 | # 将 $WORKSPACE_BASE 设置为 /home//OpenHands 31 | # 32 | # Windows 上的 WSL 示例 33 | # export WORKSPACE_BASE=/mnt/c/dev/OpenHands 34 | # 将 $WORKSPACE_BASE 设置为 C:\dev\OpenHands 35 | ``` 36 | 37 | 然后将以下选项添加到 `docker run` 命令中: 38 | 39 | ```bash 40 | docker run # ... 41 | -e SANDBOX_USER_ID=$(id -u) \ 42 | -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \ 43 | -v $WORKSPACE_BASE:/opt/workspace_base \ 44 | # ... 45 | ``` 46 | 47 | 请小心!没有任何措施可以阻止 OpenHands 代理删除或修改挂载到其工作区的任何文件。 48 | 49 | 此设置可能会导致一些文件权限问题(因此有 `SANDBOX_USER_ID` 变量),但似乎在大多数系统上都能很好地工作。 50 | 51 | ## All Hands 运行时 52 | All Hands 运行时目前处于测试阶段。您可以通过加入 Slack 上的 #remote-runtime-limited-beta 频道来请求访问权限([请参阅自述文件](https://github.com/All-Hands-AI/OpenHands?tab=readme-ov-file#-join-our-community)以获取邀请)。 53 | 54 | 要使用 All Hands 运行时,请在启动 OpenHands 时设置以下环境变量: 55 | 56 | ```bash 57 | docker run # ... 58 | -e RUNTIME=remote \ 59 | -e SANDBOX_REMOTE_RUNTIME_API_URL="https://runtime.app.all-hands.dev" \ 60 | -e SANDBOX_API_KEY="your-all-hands-api-key" \ 61 | -e SANDBOX_KEEP_RUNTIME_ALIVE="true" \ 62 | # ... 63 | ``` 64 | 65 | ## Modal 运行时 66 | 我们在 [Modal](https://modal.com/) 的合作伙伴也为 OpenHands 提供了一个运行时。 67 | 68 | 要使用 Modal 运行时,请创建一个帐户,然后[创建一个 API 密钥](https://modal.com/settings)。 69 | 70 | 然后,您需要在启动 OpenHands 时设置以下环境变量: 71 | ```bash 72 | docker run # ... 73 | -e RUNTIME=modal \ 74 | -e MODAL_API_TOKEN_ID="your-id" \ 75 | -e MODAL_API_TOKEN_SECRET="your-secret" \ 76 | ``` 77 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/troubleshooting/troubleshooting.md: -------------------------------------------------------------------------------- 1 | # 🚧 故障排除 2 | 3 | :::tip 4 | OpenHands 仅通过 WSL 支持 Windows。请确保在 WSL 终端内运行所有命令。 5 | ::: 6 | 7 | ### 启动 Docker 客户端失败 8 | 9 | **描述** 10 | 11 | 运行 OpenHands 时,出现以下错误: 12 | ``` 13 | Launch docker client failed. Please make sure you have installed docker and started docker desktop/daemon. 14 | ``` 15 | 16 | **解决方案** 17 | 18 | 请按顺序尝试以下步骤: 19 | * 确认 `docker` 正在您的系统上运行。您应该能够在终端中成功运行 `docker ps`。 20 | * 如果使用 Docker Desktop,请确保 `Settings > Advanced > Allow the default Docker socket to be used` 已启用。 21 | * 根据您的配置,您可能需要在 Docker Desktop 中启用 `Settings > Resources > Network > Enable host networking`。 22 | * 重新安装 Docker Desktop。 23 | --- 24 | 25 | # 开发工作流程特定问题 26 | ### 构建运行时 Docker 镜像时出错 27 | 28 | **描述** 29 | 30 | 尝试启动新会话失败,并且日志中出现以下术语的错误: 31 | ``` 32 | debian-security bookworm-security 33 | InRelease At least one invalid signature was encountered. 34 | ``` 35 | 36 | 当现有外部库的哈希值发生变化且本地 Docker 实例缓存了先前版本时,似乎会发生这种情况。要解决此问题,请尝试以下操作: 37 | 38 | * 停止名称以 `openhands-runtime-` 为前缀的任何容器: 39 | `docker ps --filter name=openhands-runtime- --filter status=running -aq | xargs docker stop` 40 | * 删除名称以 `openhands-runtime-` 为前缀的任何容器: 41 | `docker rmi $(docker images --filter name=openhands-runtime- -q --no-trunc)` 42 | * 停止并删除名称以 `openhands-runtime-` 为前缀的任何容器/镜像 43 | * 清理容器/镜像:`docker container prune -f && docker image prune -f` 44 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/upgrade-guide.md: -------------------------------------------------------------------------------- 1 | 以下是翻译后的内容: 2 | 3 | # ⬆️ 升级指南 4 | 5 | ## 0.8.0 (2024-07-13) 6 | 7 | ### 配置中的重大变更 8 | 9 | 在此版本中,我们对后端配置引入了一些重大变更。如果你只通过前端(Web GUI)使用OpenHands,则无需处理任何事情。 10 | 11 | 以下是配置中重大变更的列表。它们仅适用于通过 `main.py` 使用 OpenHands CLI 的用户。更多详情,请参阅 [#2756](https://github.com/All-Hands-AI/OpenHands/pull/2756)。 12 | 13 | #### 从 main.py 中移除 --model-name 选项 14 | 15 | 请注意,`--model-name` 或 `-m` 选项已不再存在。你应该在 `config.toml` 中设置 LLM 配置,或通过环境变量进行设置。 16 | 17 | #### LLM 配置组必须是 'llm' 的子组 18 | 19 | 在 0.8 版本之前,你可以在 `config.toml` 中为 LLM 配置使用任意名称,例如: 20 | 21 | ```toml 22 | [gpt-4o] 23 | model="gpt-4o" 24 | api_key="" 25 | ``` 26 | 27 | 然后使用 `--llm-config` CLI 参数按名称指定所需的 LLM 配置组。这已不再有效。相反,配置组必须位于 `llm` 组下,例如: 28 | 29 | ```toml 30 | [llm.gpt-4o] 31 | model="gpt-4o" 32 | api_key="" 33 | ``` 34 | 35 | 如果你有一个名为 `llm` 的配置组,则无需更改它,它将被用作默认的 LLM 配置组。 36 | 37 | #### 'agent' 组不再包含 'name' 字段 38 | 39 | 在 0.8 版本之前,你可能有或没有一个名为 `agent` 的配置组,如下所示: 40 | 41 | ```toml 42 | [agent] 43 | name="CodeActAgent" 44 | memory_max_threads=2 45 | ``` 46 | 47 | 请注意,`name` 字段现已被移除。相反,你应该在 `core` 组下放置 `default_agent` 字段,例如: 48 | 49 | ```toml 50 | [core] 51 | # 其他配置 52 | default_agent='CodeActAgent' 53 | 54 | [agent] 55 | llm_config='llm' 56 | memory_max_threads=2 57 | 58 | [agent.CodeActAgent] 59 | llm_config='gpt-4o' 60 | ``` 61 | 62 | 请注意,与 `llm` 子组类似,你也可以定义 `agent` 子组。此外,代理可以与特定的 LLM 配置组相关联。更多详情,请参阅 `config.template.toml` 中的示例。 63 | -------------------------------------------------------------------------------- /docs/i18n/zh-Hans/docusaurus-theme-classic/navbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": { 3 | "message": "OpenHands", 4 | "description": "The title in the navbar" 5 | }, 6 | "logo.alt": { 7 | "message": "OpenHands", 8 | "description": "The alt text of navbar logo" 9 | }, 10 | "item.label.Docs": { 11 | "message": "文档", 12 | "description": "Navbar item with label Docs" 13 | }, 14 | "item.label.Codebase": { 15 | "message": "代码库", 16 | "description": "Navbar item with label Codebase" 17 | }, 18 | "item.label.FAQ": { 19 | "message": "常见问题", 20 | "description": "Navbar item with label FAQ" 21 | }, 22 | "item.label.GitHub": { 23 | "message": "GitHub", 24 | "description": "Navbar item with label GitHub" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docs", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "docusaurus": "docusaurus", 7 | "start": "docusaurus start", 8 | "build": "docusaurus build", 9 | "swizzle": "docusaurus swizzle", 10 | "deploy": "docusaurus deploy", 11 | "clear": "docusaurus clear", 12 | "serve": "docusaurus serve", 13 | "write-translations": "docusaurus write-translations", 14 | "write-heading-ids": "docusaurus write-heading-ids", 15 | "typecheck": "tsc" 16 | }, 17 | "dependencies": { 18 | "@docusaurus/core": "^3.7.0", 19 | "@docusaurus/plugin-content-pages": "^3.7.0", 20 | "@docusaurus/preset-classic": "^3.7.0", 21 | "@docusaurus/theme-mermaid": "^3.7.0", 22 | "@mdx-js/react": "^3.1.0", 23 | "clsx": "^2.0.0", 24 | "prism-react-renderer": "^2.4.1", 25 | "react": "^19.0.0", 26 | "react-dom": "^19.0.0", 27 | "react-icons": "^5.4.0", 28 | "react-use": "^17.6.0" 29 | }, 30 | "devDependencies": { 31 | "@docusaurus/module-type-aliases": "^3.5.1", 32 | "@docusaurus/tsconfig": "^3.7.0", 33 | "@docusaurus/types": "^3.5.1", 34 | "typescript": "~5.7.3" 35 | }, 36 | "browserslist": { 37 | "production": [ 38 | ">0.5%", 39 | "not dead", 40 | "not op_mini all" 41 | ], 42 | "development": [ 43 | "last 3 chrome version", 44 | "last 3 firefox version", 45 | "last 5 safari version" 46 | ] 47 | }, 48 | "engines": { 49 | "node": ">=18.0" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /docs/plugins/tailwind-config.cjs: -------------------------------------------------------------------------------- 1 | export default function tailwindPlugin(context, options) { 2 | return { 3 | name: 'tailwind-plugin', 4 | configurePostCss(postcssOptions) { 5 | postcssOptions.plugins = [ 6 | require('postcss-import'), 7 | require('tailwindcss'), 8 | require('autoprefixer'), 9 | ]; 10 | return postcssOptions; 11 | }, 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /docs/sidebars.ts: -------------------------------------------------------------------------------- 1 | import type { SidebarsConfig } from "@docusaurus/plugin-content-docs"; 2 | 3 | const sidebars: SidebarsConfig = { 4 | docsSidebar: [ 5 | { 6 | type: 'doc', 7 | label: 'Welcome to AutoAgent', 8 | id: 'Get-Started/welcome-to-autoagent', 9 | }, 10 | { 11 | type: "category", 12 | label: "Get started", 13 | items: [ 14 | "Get-Started/get-started-installation", 15 | "Get-Started/get-started-quickstart", 16 | ], 17 | }, 18 | { 19 | type: "category", 20 | label: "Starter Projects", 21 | items: [ 22 | "Starter-Projects/starter-projects-auto-deep-research", 23 | "Starter-Projects/starter-projects-nl-to-agent", 24 | "Starter-Projects/starter-projects-agentic-rag", 25 | ], 26 | }, 27 | { 28 | type: "category", 29 | label: "User Guideline", 30 | items: [ 31 | "User-Guideline/user-guide-daily-tasks", 32 | "User-Guideline/user-guide-how-to-create-agent", 33 | ], 34 | }, 35 | { 36 | type: "category", 37 | label: "Developer Guideline", 38 | items: [ 39 | "Dev-Guideline/dev-guide-create-tools", 40 | "Dev-Guideline/dev-guide-create-agent", 41 | "Dev-Guideline/dev-guide-edit-mem", 42 | "Dev-Guideline/dev-guide-build-your-project", 43 | ], 44 | }, 45 | ], 46 | }; 47 | 48 | export default sidebars; 49 | -------------------------------------------------------------------------------- /docs/src/components/CustomFooter.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { FaSlack, FaDiscord, FaGithub } from "react-icons/fa"; 3 | import Translate from '@docusaurus/Translate'; 4 | import "../css/footer.css"; 5 | 6 | function CustomFooter() { 7 | return ( 8 | 30 | ); 31 | } 32 | 33 | export default CustomFooter; 34 | -------------------------------------------------------------------------------- /docs/src/components/Demo/Demo.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import styles from "./index.module.css"; 3 | 4 | export function Demo() { 5 | const videoRef = React.useRef(null); 6 | 7 | return ( 8 |
11 | 23 |
24 | ); 25 | } 26 | -------------------------------------------------------------------------------- /docs/src/components/Demo/index.module.css: -------------------------------------------------------------------------------- 1 | .demo { 2 | width: 100%; 3 | padding: 30px; 4 | max-width: 800px; 5 | text-align: center; 6 | border-radius: 40px; 7 | } 8 | -------------------------------------------------------------------------------- /docs/src/components/Footer/Footer.css: -------------------------------------------------------------------------------- 1 | .footer { 2 | padding: 2rem 0; 3 | } 4 | 5 | .footer-content { 6 | max-width: 1200px; 7 | margin: 0 auto; 8 | padding: 0 1rem; 9 | text-align: center; 10 | } 11 | 12 | .copyright { 13 | color: var(--ifm-color-emphasis-600); 14 | font-size: 0.9rem; 15 | } 16 | 17 | .social-icons { 18 | display: flex; 19 | align-items: center; 20 | gap: 0.5rem; 21 | } 22 | 23 | .social-icons img { 24 | width: 20px; 25 | height: 20px; 26 | opacity: 0.6; 27 | transition: opacity 0.2s ease; 28 | } 29 | 30 | .social-icons img:hover { 31 | opacity: 1; 32 | } 33 | 34 | @media screen and (max-width: 768px) { 35 | .copyright { 36 | font-size: 0.8rem; 37 | } 38 | } -------------------------------------------------------------------------------- /docs/src/components/Footer/Footer.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './Footer.css'; 3 | 4 | export function Footer() { 5 | return ( 6 |
7 |
8 |
9 | Copyright © 2025 AutoAgent Team 10 |
11 |
12 |
13 | ); 14 | } -------------------------------------------------------------------------------- /docs/src/components/HomepageHeader/HomepageHeader.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; 3 | import Heading from "@theme/Heading"; 4 | import { KeyFeatures } from "../KeyFeatures/KeyFeatures"; 5 | import Translate from '@docusaurus/Translate'; 6 | import "../../css/homepageHeader.css"; 7 | import { Demo } from "../Demo/Demo"; 8 | 9 | export function HomepageHeader() { 10 | const { siteConfig } = useDocusaurusContext(); 11 | return ( 12 |
13 | 56 |
57 | ); 58 | } 59 | -------------------------------------------------------------------------------- /docs/src/components/KeyFeatures/KeyFeatures.css: -------------------------------------------------------------------------------- 1 | .intro-image { 2 | width: 100%; 3 | max-width: 1200px; 4 | margin: 0 auto 1.5rem; 5 | text-align: center; 6 | padding: 0; 7 | border-radius: 12px; 8 | background: none; 9 | box-shadow: none; 10 | } 11 | 12 | .intro-image img { 13 | width: 100%; 14 | height: auto; 15 | display: block; 16 | filter: none !important; 17 | -webkit-filter: none !important; 18 | } 19 | 20 | .key-features { 21 | padding: 1rem; 22 | max-width: 1200px; 23 | margin: 0 auto; 24 | margin-bottom: 4rem; 25 | } 26 | 27 | .features-title { 28 | text-align: left; 29 | font-size: 1.8rem; 30 | margin-bottom: 2.5rem; 31 | color: var(--ifm-color-primary); 32 | display: flex; 33 | align-items: center; 34 | gap: 0.5rem; 35 | } 36 | 37 | .features-title::before { 38 | content: '✨'; 39 | font-size: 1.6rem; 40 | } 41 | 42 | .features-list { 43 | list-style: none; 44 | padding: 0; 45 | display: grid; 46 | grid-template-columns: repeat(3, 1fr); 47 | gap: 2rem; 48 | } 49 | 50 | .features-list li { 51 | background: var(--ifm-background-surface-color); 52 | border-radius: 24px; 53 | padding: 2.5rem; 54 | box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02), 55 | 0 8px 24px rgba(0, 0, 0, 0.04); 56 | border: 1px solid rgba(0, 0, 0, 0.05); 57 | transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 58 | display: flex; 59 | flex-direction: column; 60 | height: 100%; 61 | position: relative; 62 | overflow: hidden; 63 | text-align: left; 64 | backdrop-filter: blur(8px); 65 | } 66 | 67 | .features-list li:hover { 68 | transform: translateY(-5px); 69 | box-shadow: 0 4px 8px rgba(0, 0, 0, 0.04), 70 | 0 12px 32px rgba(0, 0, 0, 0.08); 71 | border-color: var(--ifm-color-primary-lightest); 72 | } 73 | 74 | .feature-icon { 75 | font-size: 3rem; 76 | display: block; 77 | margin-bottom: 2rem; 78 | } 79 | 80 | .feature-content { 81 | flex: 1; 82 | display: flex; 83 | flex-direction: column; 84 | } 85 | 86 | .feature-content strong { 87 | display: block; 88 | font-size: 1.2rem; 89 | margin-bottom: 1rem; 90 | color: var(--ifm-font-color-base); 91 | line-height: 1.3; 92 | font-weight: 600; 93 | } 94 | 95 | .feature-content p { 96 | margin: 0; 97 | line-height: 1.6; 98 | color: var(--ifm-color-emphasis-700); 99 | font-size: 0.95rem; 100 | } 101 | 102 | .feature-content .highlight { 103 | color: var(--ifm-color-primary); 104 | font-weight: 600; 105 | } 106 | 107 | @media (max-width: 996px) { 108 | .features-list { 109 | grid-template-columns: repeat(2, 1fr); 110 | } 111 | } 112 | 113 | @media (max-width: 768px) { 114 | .features-list { 115 | grid-template-columns: 1fr; 116 | } 117 | 118 | .features-list li { 119 | padding: 2rem; 120 | } 121 | 122 | .feature-icon { 123 | font-size: 2.5rem; 124 | margin-bottom: 1.5rem; 125 | } 126 | 127 | .feature-content strong { 128 | font-size: 1.1rem; 129 | } 130 | 131 | .feature-content p { 132 | font-size: 0.9rem; 133 | } 134 | } -------------------------------------------------------------------------------- /docs/src/components/KeyFeatures/KeyFeatures.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './KeyFeatures.css'; 3 | 4 | export function KeyFeatures() { 5 | return ( 6 |
7 | {/*
8 | AutoAgent Introduction 9 |
*/} 10 |

Key Features

11 |
    12 |
  • 13 | 🏆 14 |
    15 | Top Performer on the GAIA Benchmark 16 |

    17 | AutoAgent has ranked the #1 spot among open-sourced methods, delivering comparable performance to OpenAI's Deep Research. 18 |

    19 |
    20 |
  • 21 | 22 |
  • 23 | 📚 24 |
    25 | Agentic-RAG with Native Self-Managing Vector Database 26 |

    27 | AutoAgent equipped with a native self-managing vector database, outperforms industry-leading solutions like LangChain. 28 |

    29 |
    30 |
  • 31 | 32 |
  • 33 | 34 |
    35 | Agent and Workflow Create with Ease 36 |

    37 | AutoAgent leverages natural language to effortlessly build ready-to-use tools, agents and workflows - no coding required. 38 |

    39 |
    40 |
  • 41 | 42 |
  • 43 | 🌐 44 |
    45 | Universal LLM Support 46 |

    47 | AutoAgent seamlessly integrates with A Wide Range of LLMs (OpenAI, Anthropic, Deepseek, vLLM, Grok, Huggingface). 48 |

    49 |
    50 |
  • 51 | 52 |
  • 53 | 🔀 54 |
    55 | Flexible Interaction 56 |

    57 | Benefit from support for both function-calling and ReAct interaction modes. 58 |

    59 |
    60 |
  • 61 | 62 |
  • 63 | 🤖 64 |
    65 | Dynamic, Extensible, Lightweight 66 |

    67 | AutoAgent is your Personal AI Assistant, designed to be dynamic, extensible, customized, and lightweight. 68 |

    69 |
    70 |
  • 71 |
72 |
73 | ); 74 | } -------------------------------------------------------------------------------- /docs/src/css/custom.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Any CSS included here will be global. The classic template 3 | * bundles Infima by default. Infima is a CSS framework designed to 4 | * work well for content-centric websites. 5 | */ 6 | 7 | /* You can override the default Infima variables here. */ 8 | 9 | :root { 10 | --ifm-code-font-size: 95%; 11 | --ifm-color-primary: #000; 12 | --ifm-background-color: #F1EAE0; 13 | --ifm-navbar-background-color: #F1EAE0; 14 | --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1); 15 | --secondary: #171717; 16 | --secondary-dark: #0a0a0a; 17 | --secondary-light: #737373; 18 | } 19 | 20 | /* For readability concerns, you should choose a lighter palette in dark mode. */ 21 | [data-theme="dark"] { 22 | --ifm-color-primary: #FFF; 23 | --ifm-background-color: #000; 24 | --ifm-navbar-background-color: #000; 25 | --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3); 26 | --secondary: #737373; 27 | --secondary-dark: #171717; 28 | --secondary-light: #ccc; 29 | } 30 | 31 | article a, .a { 32 | text-decoration: underline; 33 | } 34 | -------------------------------------------------------------------------------- /docs/src/css/footer.css: -------------------------------------------------------------------------------- 1 | /* customFooter.css */ 2 | 3 | .custom-footer { 4 | background-color: dark; 5 | color: #000; 6 | height: 100px; 7 | /* background: linear-gradient(to bottom, #1a1a1a, #1a1a1a); */ 8 | background-color: #F1EAE0; 9 | 10 | } 11 | 12 | [data-theme="dark"] .custom-footer { 13 | background-color: #000; 14 | color: #fff; 15 | } 16 | 17 | 18 | .footer-content { 19 | display: flex; 20 | flex-direction: column; 21 | justify-content: space-between; 22 | align-items: center; 23 | padding: 8px; 24 | height: 100%; 25 | } 26 | 27 | .footer-top { 28 | display: flex; 29 | gap: 8px; 30 | align-items: center; 31 | } 32 | 33 | .footer-title { 34 | font-weight: bold; 35 | font-size: 1.125rem; 36 | } 37 | 38 | @media (min-width: 768px) { 39 | .footer-title { 40 | font-size: 1.875rem; 41 | } 42 | } 43 | 44 | .footer-link a { 45 | font-size: 0.875rem; 46 | text-decoration: none; 47 | color: gray; 48 | transition: color 0.3s ease; 49 | } 50 | 51 | .footer-link a:hover { 52 | color: white; 53 | } 54 | 55 | .footer-community { 56 | font-weight: 300; 57 | } 58 | 59 | .footer-icons { 60 | display: flex; 61 | gap: 24px; 62 | font-size: 1.875rem; 63 | } 64 | 65 | .footer-icons a { 66 | color:gray; 67 | transition: color 0.3s ease; 68 | } 69 | 70 | .footer-icons a:hover { 71 | color: white; 72 | } 73 | -------------------------------------------------------------------------------- /docs/src/pages/_footer.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import CustomFooter from '../components/CustomFooter'; 3 | 4 | export default function Footer() { 5 | return ; 6 | } 7 | -------------------------------------------------------------------------------- /docs/src/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; 3 | import Layout from '@theme/Layout'; 4 | import { HomepageHeader } from '../components/HomepageHeader/HomepageHeader'; 5 | import { translate } from '@docusaurus/Translate'; 6 | 7 | export default function Home(): JSX.Element { 8 | const { siteConfig } = useDocusaurusContext(); 9 | return ( 10 | 17 | 18 | 19 | ); 20 | } 21 | -------------------------------------------------------------------------------- /docs/src/theme/Layout/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import OriginalLayout from '@theme-original/Layout'; 3 | import Footer from '@site/src/pages/_footer'; 4 | 5 | export default function Layout(props) { 6 | return ( 7 | <> 8 | 9 |