Page Not Found
We could not find what you were looking for.
Please contact the owner of the site that linked you to the original URL and let them know their link is broken.
diff --git a/404.html b/404.html index e6161a23..c6680912 100644 --- a/404.html +++ b/404.html @@ -4,8 +4,8 @@
We could not find what you were looking for.
Please contact the owner of the site that linked you to the original URL and let them know their link is broken.
container
Mode",id:"limitations-of-the-container-mode",level:2},{value:"Restricting External Network Access for Docker Containers",id:"restricting-external-network-access-for-docker-containers",level:2}];function l(e){const n={a:"a",blockquote:"blockquote",br:"br",code:"code",h1:"h1",h2:"h2",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.a)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h1,{id:"code-execution",children:"Code Execution"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:["\ud83d\udca1We have set the ",(0,t.jsx)(n.code,{children:"container"})," mode as default for code execution, especially when the usage of the agent\nis open to untrusted users. Refer to ",(0,t.jsx)(n.a,{href:"https://docs.docker.com/engine/security/",children:"Docker Security"})," for better understanding\nof the security features of Docker. To opt for the ",(0,t.jsx)(n.code,{children:"local"})," mode, you need to explicitly set the ",(0,t.jsx)(n.code,{children:"execution_service.kernel_mode"}),"\nparameter in the ",(0,t.jsx)(n.code,{children:"taskweaver_config.json"})," file to ",(0,t.jsx)(n.code,{children:"local"}),"."]}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"TaskWeaver is a code-first agent framework, which means that it always converts the user request into code\nand executes the code to generate the response. In our current implementation, we use a Jupyter Kernel\nto execute the code. We choose Jupyter Kernel because it is a well-established tool for interactive computing,\nand it supports many programming languages."}),"\n",(0,t.jsx)(n.h2,{id:"two-modes-of-code-execution",children:"Two Modes of Code Execution"}),"\n",(0,t.jsxs)(n.p,{children:["TaskWeaver supports two modes of code execution: ",(0,t.jsx)(n.code,{children:"local"})," and ",(0,t.jsx)(n.code,{children:"container"}),".\nThe ",(0,t.jsx)(n.code,{children:"container"})," mode is the default mode. The key difference between the two modes is that the ",(0,t.jsx)(n.code,{children:"container"})," mode\nexecutes the code inside a Docker container, which provides a more secure environment for code execution, while\nthe ",(0,t.jsx)(n.code,{children:"local"})," mode executes the code as a subprocess of the TaskWeaver process.\nAs a result, in the ",(0,t.jsx)(n.code,{children:"local"})," mode, if the user has malicious intent, the user could potentially\ninstruct TaskWeaver to execute harmful code on the host machine. In addition, the LLM could also generate\nharmful code, leading to potential security risks."]}),"\n",(0,t.jsx)(n.h2,{id:"how-to-configure-the-code-execution-mode",children:"How to Configure the Code Execution Mode"}),"\n",(0,t.jsxs)(n.p,{children:["To configure the code execution mode, you need to set the ",(0,t.jsx)(n.code,{children:"execution_service.kernel_mode"})," parameter in the\n",(0,t.jsx)(n.code,{children:"taskweaver_config.json"})," file. The value of the parameter could be ",(0,t.jsx)(n.code,{children:"local"})," or ",(0,t.jsx)(n.code,{children:"container"}),". The default value\nis ",(0,t.jsx)(n.code,{children:"container"}),"."]}),"\n",(0,t.jsxs)(n.p,{children:["TaskWeaver supports the ",(0,t.jsx)(n.code,{children:"local"})," mode without any additional setup. However, to use the ",(0,t.jsx)(n.code,{children:"container"})," mode,\nthere are a few prerequisites:"]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"Docker is installed on the host machine."}),"\n",(0,t.jsx)(n.li,{children:"A Docker image is built and available on the host machine for code execution."}),"\n",(0,t.jsxs)(n.li,{children:["The ",(0,t.jsx)(n.code,{children:"execution_service.kernel_mode"})," parameter is set to ",(0,t.jsx)(n.code,{children:"container"})," in the ",(0,t.jsx)(n.code,{children:"taskweaver_config.json"})," file."]}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"Once the code repository is cloned to your local machine, you can build the Docker image\nby running the following command in the root directory of the code repository:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"cd scripts\n\n# based on your OS\n./build_executor.ps1 # for Windows\n./build_executor.sh # for Linux or macOS\n"})}),"\n",(0,t.jsxs)(n.p,{children:["After the Docker image is built, you can run ",(0,t.jsx)(n.code,{children:"docker images"})," to check if a Docker image\nnamed ",(0,t.jsx)(n.code,{children:"executor_container"})," is available.\nIf the prerequisite is met, you can now run TaskWeaver in the ",(0,t.jsx)(n.code,{children:"container"})," mode."]}),"\n",(0,t.jsxs)(n.p,{children:["After running TaskWeaver in the ",(0,t.jsx)(n.code,{children:"container"})," mode, you can check if the container is running by running ",(0,t.jsx)(n.code,{children:"docker ps"}),".\nYou should see a container of image ",(0,t.jsx)(n.code,{children:"taskweavercontainers/taskweaver-executor"})," running after executing some code."]}),"\n",(0,t.jsx)(n.h2,{id:"how-to-customize-the-docker-image-for-code-execution",children:"How to customize the Docker image for code execution"}),"\n",(0,t.jsxs)(n.p,{children:["You may want to customize the Docker image for code execution to include additional packages or libraries, especially\nfor your developed plugins. The current Docker image for code execution is ",(0,t.jsx)(n.code,{children:"taskweavercontainers/taskweaver-executor"}),", which\nonly includes the dependencies specified in the ",(0,t.jsx)(n.code,{children:"TaskWeaver/requirements.txt"})," file. To customize the Docker image, you need to\nmodify the ",(0,t.jsx)(n.code,{children:"Dockerfile"})," at ",(0,t.jsx)(n.code,{children:"TaskWeaver/docker/ces_container/Dockerfile"})," and rebuild the Docker image."]}),"\n",(0,t.jsxs)(n.p,{children:["When you open the ",(0,t.jsx)(n.code,{children:"Dockerfile"}),", you will see the following content, and you can add additional packages or libraries\nby adding the corresponding ",(0,t.jsx)(n.code,{children:"RUN"})," command. In this example, we add the ",(0,t.jsx)(n.code,{children:"sentence-transformers"})," package to the Docker image."]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-Dockerfile",children:"FROM python:3.10-slim\n...\n# TODO: Install additional packages for plugins\nRUN pip install --no-cache-dir --no-warn-script-location --user sentence-transformers\n...\n"})}),"\n",(0,t.jsxs)(n.p,{children:["Then, you need to rebuild the Docker image by running the ",(0,t.jsx)(n.code,{children:"build_executor.sh"})," script at ",(0,t.jsx)(n.code,{children:"TaskWeaver/scripts/build_executor.sh"}),"\nor ",(0,t.jsx)(n.code,{children:"TaskWeaver/scripts/build.ps1"})," depending on your operating system."]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"cd TaskWeaver/scripts\n./build_executor.sh\n# or ./build_executor.ps1 if you are using Windows\n"})}),"\n",(0,t.jsxs)(n.p,{children:["If you have successfully rebuilt the Docker image, you can check the new image by running ",(0,t.jsx)(n.code,{children:"docker images"}),".\nAfter building the Docker image, you need to restart the TaskWeaver agent to use the new Docker image."]}),"\n",(0,t.jsxs)(n.h2,{id:"limitations-of-the-container-mode",children:["Limitations of the ",(0,t.jsx)(n.code,{children:"container"})," Mode"]}),"\n",(0,t.jsxs)(n.p,{children:["The ",(0,t.jsx)(n.code,{children:"container"})," mode is more secure than the ",(0,t.jsx)(n.code,{children:"local"})," mode, but it also has some limitations:"]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["The startup time of the ",(0,t.jsx)(n.code,{children:"container"})," mode is longer than the ",(0,t.jsx)(n.code,{children:"local"})," mode, because it needs to start a Docker container."]}),"\n",(0,t.jsxs)(n.li,{children:["As the Jupyter Kernel is running inside a Docker container, it has limited access to the host machine. We are mapping the\n",(0,t.jsx)(n.code,{children:"project/workspace/sessions/send_to
, message
or other fields?",id:"q-why-i-see-errors-saying-the-planner-failed-to-generate-the-send_to-message-or-other-fields",level:3},{value:"Q: How do I know if TaskWeaver can see my plugin?",id:"q-how-do-i-know-if-taskweaver-can-see-my-plugin",level:3},{value:"Q: Why TaskWeaver cannot see my plugin?",id:"q-why-taskweaver-cannot-see-my-plugin",level:3},{value:"Q: Why TaskWeaver can see my plugin but cannot call it?",id:"q-why-taskweaver-can-see-my-plugin-but-cannot-call-it",level:3},{value:"Q: How to debug my plugin?",id:"q-how-to-debug-my-plugin",level:3},{value:"Q: Why I see the error message "RuntimeError: This event loop is already running"?",id:"q-why-i-see-the-error-message-runtimeerror-this-event-loop-is-already-running",level:3}];function h(e){const n={a:"a",code:"code",h1:"h1",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",ul:"ul",...(0,i.a)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.h1,{id:"faq",children:"FAQ"}),"\n",(0,o.jsx)(n.h3,{id:"q-why-it-takes-so-long-to-generate-the-output",children:"Q: Why it takes so long to generate the output?"}),"\n",(0,o.jsx)(n.p,{children:"A: In the default setting, TaskWeaver typically goes through the following steps to generate the output:"}),"\n",(0,o.jsxs)(n.ol,{children:["\n",(0,o.jsx)(n.li,{children:"The User sends a query to the Planner."}),"\n",(0,o.jsx)(n.li,{children:"The Planner generates a plan based on the query and sends the plan to the CodeInterpreter."}),"\n",(0,o.jsx)(n.li,{children:"The CodeInterpreter executes the plan and sends the execution result back to the Planner."}),"\n",(0,o.jsx)(n.li,{children:"The Planner summarizes the execution result and sends the summary to the User."}),"\n",(0,o.jsx)(n.li,{children:"The User receives the summary from the Planner."}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:"In some cases, the Planer and CodeInterpreter can go back and forth multiple times to generate the output.\nThis process can take a long time, mostly due to the latency of calling the LLMs.\nTo speed up the process, you can try the following:"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"Use a smaller LLM model, such as GPT-3.5 instead of GPT-4. However, you need to experiment with your use case to see if the smaller model can still generate the output correctly."}),"\n",(0,o.jsx)(n.li,{children:"Use the CodeInterpreter only mode, which skips the Planner and generates the code directly from the User query. This mode is faster because it skips the planning step.\nHowever, you should check if your use case needs the planning step."}),"\n"]}),"\n",(0,o.jsx)(n.h3,{id:"q-why-taskweaver-fails-and-the-logs-say-failed-to-connect-to-dockerdaemon",children:'Q: Why TaskWeaver fails and the logs say "Failed to connect to docker.daemon"?'}),"\n",(0,o.jsxs)(n.p,{children:["A: This error typically happens when TaskWeaver is running in the ",(0,o.jsx)(n.code,{children:"container"})," mode and cannot connect to the Docker daemon.\nWe have switched to the ",(0,o.jsx)(n.code,{children:"container"})," mode by default to provide a more secure environment for code execution.\nTo opt out of the ",(0,o.jsx)(n.code,{children:"container"})," mode, you can set the ",(0,o.jsx)(n.code,{children:"execution_service.kernel_mode"})," parameter to ",(0,o.jsx)(n.code,{children:"local"})," in the ",(0,o.jsx)(n.code,{children:"taskweaver_config.json"})," file.\nHowever, you should be aware that TaskWeaver can interact with the host machine directly in the ",(0,o.jsx)(n.code,{children:"local"})," mode, which may have security risks."]}),"\n",(0,o.jsxs)(n.h3,{id:"q-why-i-see-errors-saying-the-planner-failed-to-generate-the-send_to-message-or-other-fields",children:["Q: Why I see errors saying the Planner failed to generate the ",(0,o.jsx)(n.code,{children:"send_to"}),", ",(0,o.jsx)(n.code,{children:"message"})," or other fields?"]}),"\n",(0,o.jsxs)(n.p,{children:["A: This is typically due to that the LLM failed to generate its output follow our schema. In Planner's prompt,\nwe asked the LLM to generate a JSON object that contains ",(0,o.jsx)(n.code,{children:"send_to"}),", ",(0,o.jsx)(n.code,{children:"message"}),", ",(0,o.jsx)(n.code,{children:"init_plan"}),", ",(0,o.jsx)(n.code,{children:"plan"}),", and ",(0,o.jsx)(n.code,{children:"current_plan_step"}),".\nMissing any of these fields will cause the parsing error.\nThe most effective way to mitigate this issue is to use switch to more powerful LLM model, such as GPT-3.5 or GPT-4."]}),"\n",(0,o.jsx)(n.h3,{id:"q-how-do-i-know-if-taskweaver-can-see-my-plugin",children:"Q: How do I know if TaskWeaver can see my plugin?"}),"\n",(0,o.jsx)(n.p,{children:'A: A simple way to check if TaskWeaver can see your plugin is to ask "What can you do?" to TaskWeaver.\nThe typical response is to list all the available plugins like the following:'}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-markdown",children:"I can assist you with various tasks, including:\n\n- Detecting anomalies in time series data.\n- Rendering text into ASCII art.\n- Searching and comparing prices from thousands of online shops (US only).\n- Telling a joke.\n\nIf you have a specific task in mind, please let me know, and I'll do my best to assist you.\n"})}),"\n",(0,o.jsxs)(n.p,{children:["If you see your plugin in the list, it means TaskWeaver can see your plugin.\nBut this is not a reliable way to check if TaskWeaver can see your plugin because the response is generated by the LLM.\nA more reliable way is to check the prompt of the Planner. You can find the prompts\nfrom ",(0,o.jsx)(n.code,{children:"project/workspace/sessions/container
Mode",id:"limitations-of-the-container-mode",level:2},{value:"Restricting External Network Access for Docker Containers",id:"restricting-external-network-access-for-docker-containers",level:2}];function l(e){const n={a:"a",blockquote:"blockquote",br:"br",code:"code",h1:"h1",h2:"h2",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.a)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h1,{id:"code-execution",children:"Code Execution"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:["\ud83d\udca1We have set the ",(0,t.jsx)(n.code,{children:"container"})," mode as default for code execution, especially when the usage of the agent\nis open to untrusted users. Refer to ",(0,t.jsx)(n.a,{href:"https://docs.docker.com/engine/security/",children:"Docker Security"})," for better understanding\nof the security features of Docker. To opt for the ",(0,t.jsx)(n.code,{children:"local"})," mode, you need to explicitly set the ",(0,t.jsx)(n.code,{children:"execution_service.kernel_mode"}),"\nparameter in the ",(0,t.jsx)(n.code,{children:"taskweaver_config.json"})," file to ",(0,t.jsx)(n.code,{children:"local"}),"."]}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"TaskWeaver is a code-first agent framework, which means that it always converts the user request into code\nand executes the code to generate the response. In our current implementation, we use a Jupyter Kernel\nto execute the code. We choose Jupyter Kernel because it is a well-established tool for interactive computing,\nand it supports many programming languages."}),"\n",(0,t.jsx)(n.h2,{id:"two-modes-of-code-execution",children:"Two Modes of Code Execution"}),"\n",(0,t.jsxs)(n.p,{children:["TaskWeaver supports two modes of code execution: ",(0,t.jsx)(n.code,{children:"local"})," and ",(0,t.jsx)(n.code,{children:"container"}),".\nThe ",(0,t.jsx)(n.code,{children:"container"})," mode is the default mode. The key difference between the two modes is that the ",(0,t.jsx)(n.code,{children:"container"})," mode\nexecutes the code inside a Docker container, which provides a more secure environment for code execution, while\nthe ",(0,t.jsx)(n.code,{children:"local"})," mode executes the code as a subprocess of the TaskWeaver process.\nAs a result, in the ",(0,t.jsx)(n.code,{children:"local"})," mode, if the user has malicious intent, the user could potentially\ninstruct TaskWeaver to execute harmful code on the host machine. In addition, the LLM could also generate\nharmful code, leading to potential security risks."]}),"\n",(0,t.jsx)(n.h2,{id:"how-to-configure-the-code-execution-mode",children:"How to Configure the Code Execution Mode"}),"\n",(0,t.jsxs)(n.p,{children:["To configure the code execution mode, you need to set the ",(0,t.jsx)(n.code,{children:"execution_service.kernel_mode"})," parameter in the\n",(0,t.jsx)(n.code,{children:"taskweaver_config.json"})," file. The value of the parameter could be ",(0,t.jsx)(n.code,{children:"local"})," or ",(0,t.jsx)(n.code,{children:"container"}),". The default value\nis ",(0,t.jsx)(n.code,{children:"container"}),"."]}),"\n",(0,t.jsxs)(n.p,{children:["TaskWeaver supports the ",(0,t.jsx)(n.code,{children:"local"})," mode without any additional setup. However, to use the ",(0,t.jsx)(n.code,{children:"container"})," mode,\nthere are a few prerequisites:"]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"Docker is installed on the host machine."}),"\n",(0,t.jsx)(n.li,{children:"A Docker image is built and available on the host machine for code execution."}),"\n",(0,t.jsxs)(n.li,{children:["The ",(0,t.jsx)(n.code,{children:"execution_service.kernel_mode"})," parameter is set to ",(0,t.jsx)(n.code,{children:"container"})," in the ",(0,t.jsx)(n.code,{children:"taskweaver_config.json"})," file."]}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"Once the code repository is cloned to your local machine, you can build the Docker image\nby running the following command in the root directory of the code repository:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"cd scripts\n\n# based on your OS\n./build_executor.ps1 # for Windows\n./build_executor.sh # for Linux or macOS\n"})}),"\n",(0,t.jsxs)(n.p,{children:["After the Docker image is built, you can run ",(0,t.jsx)(n.code,{children:"docker images"})," to check if a Docker image\nnamed ",(0,t.jsx)(n.code,{children:"executor_container"})," is available.\nIf the prerequisite is met, you can now run TaskWeaver in the ",(0,t.jsx)(n.code,{children:"container"})," mode."]}),"\n",(0,t.jsxs)(n.p,{children:["After running TaskWeaver in the ",(0,t.jsx)(n.code,{children:"container"})," mode, you can check if the container is running by running ",(0,t.jsx)(n.code,{children:"docker ps"}),".\nYou should see a container of image ",(0,t.jsx)(n.code,{children:"taskweavercontainers/taskweaver-executor"})," running after executing some code."]}),"\n",(0,t.jsx)(n.h2,{id:"how-to-customize-the-docker-image-for-code-execution",children:"How to customize the Docker image for code execution"}),"\n",(0,t.jsxs)(n.p,{children:["You may want to customize the Docker image for code execution to include additional packages or libraries, especially\nfor your developed plugins. The current Docker image for code execution is ",(0,t.jsx)(n.code,{children:"taskweavercontainers/taskweaver-executor"}),", which\nonly includes the dependencies specified in the ",(0,t.jsx)(n.code,{children:"TaskWeaver/requirements.txt"})," file. To customize the Docker image, you need to\nmodify the ",(0,t.jsx)(n.code,{children:"Dockerfile"})," at ",(0,t.jsx)(n.code,{children:"TaskWeaver/docker/ces_container/Dockerfile"})," and rebuild the Docker image."]}),"\n",(0,t.jsxs)(n.p,{children:["When you open the ",(0,t.jsx)(n.code,{children:"Dockerfile"}),", you will see the following content, and you can add additional packages or libraries\nby adding the corresponding ",(0,t.jsx)(n.code,{children:"RUN"})," command. In this example, we add the ",(0,t.jsx)(n.code,{children:"sentence-transformers"})," package to the Docker image."]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-Dockerfile",children:"FROM python:3.10-slim\n...\n# TODO: Install additional packages for plugins\nRUN pip install --no-cache-dir --no-warn-script-location --user sentence-transformers\n...\n"})}),"\n",(0,t.jsxs)(n.p,{children:["Then, you need to rebuild the Docker image by running the ",(0,t.jsx)(n.code,{children:"build_executor.sh"})," script at ",(0,t.jsx)(n.code,{children:"TaskWeaver/scripts/build_executor.sh"}),"\nor ",(0,t.jsx)(n.code,{children:"TaskWeaver/scripts/build.ps1"})," depending on your operating system."]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"cd TaskWeaver/scripts\n./build_executor.sh\n# or ./build_executor.ps1 if you are using Windows\n"})}),"\n",(0,t.jsxs)(n.p,{children:["If you have successfully rebuilt the Docker image, you can check the new image by running ",(0,t.jsx)(n.code,{children:"docker images"}),".\nAfter building the Docker image, you need to restart the TaskWeaver agent to use the new Docker image."]}),"\n",(0,t.jsxs)(n.h2,{id:"limitations-of-the-container-mode",children:["Limitations of the ",(0,t.jsx)(n.code,{children:"container"})," Mode"]}),"\n",(0,t.jsxs)(n.p,{children:["The ",(0,t.jsx)(n.code,{children:"container"})," mode is more secure than the ",(0,t.jsx)(n.code,{children:"local"})," mode, but it also has some limitations:"]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["The startup time of the ",(0,t.jsx)(n.code,{children:"container"})," mode is longer than the ",(0,t.jsx)(n.code,{children:"local"})," mode, because it needs to start a Docker container."]}),"\n",(0,t.jsxs)(n.li,{children:["As the Jupyter Kernel is running inside a Docker container, it has limited access to the host machine. We are mapping the\n",(0,t.jsx)(n.code,{children:"project/workspace/sessions/Your Docusaurus site did not load properly.
\nA very common reason is a wrong site baseUrl configuration.
\nCurrent configured baseUrl = ${e} ${"/"===e?" (default value)":""}
\nWe suggest trying baseUrl =
\nYour Docusaurus site did not load properly.
\nA very common reason is a wrong site baseUrl configuration.
\nCurrent configured baseUrl = ${e} ${"/"===e?" (default value)":""}
\nWe suggest trying baseUrl =
\n