diff --git a/.devcontainer/.devcontainer.json b/.devcontainer/.devcontainer.json new file mode 100644 index 00000000..0e3eaddd --- /dev/null +++ b/.devcontainer/.devcontainer.json @@ -0,0 +1,8 @@ +{ + "name": "Swarms Project", + "dockerFile": "Dockerfile", + "forwardPorts": [ + 8000 + ], + "postCreateCommand": "pip install -r requirements.txt" +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..17be703c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.8-slim-buster + +WORKDIR /app + +ADD . /app + +RUN pip install --no-cache-dir -r requirements.txt + +EXPOSE 8000 + +CMD ["python", "example.py"] diff --git a/docs/devenviroment.md b/docs/devenviroment.md new file mode 100644 index 00000000..dccc392c --- /dev/null +++ b/docs/devenviroment.md @@ -0,0 +1,21 @@ +# Swarms Project Development Environment + +This repository uses [VS Code's Dev Containers](https://code.visualstudio.com/docs/remote/containers) to standardize the development environment. To get started, follow these steps: + +1. Install [Docker Desktop](https://www.docker.com/products/docker-desktop). + +2. Install [Visual Studio Code](https://code.visualstudio.com/). + +3. Install the [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension in VS Code. + +4. Clone this repository and open it in VS Code. + +5. When prompted to reopen the project in a container, click "Reopen in Container". + + If you missed the prompt, you can open the command palette (F1) and run the "Remote-Containers: Reopen Folder in Container" command. + +6. Wait for the container to build. This can take a few minutes the first time. + +7. You're now developing inside a Docker container! Any changes you make will be reflected in the container. + +For more information, see the [VS Code Dev Containers documentation](https://code.visualstudio.com/docs/remote/containers). diff --git a/swarms/models/__init__.py b/swarms/models/__init__.py index 328dd013..e082c30e 100644 --- a/swarms/models/__init__.py +++ b/swarms/models/__init__.py @@ -20,8 +20,9 @@ from swarms.models.layoutlm_document_qa import LayoutLMDocumentQA # from swarms.models.fuyu import Fuyu # Not working, wait until they update import sys -log_file = open("errors.txt", "w") -sys.stderr = log_file +# Uncomment for clean ouput +# log_file = open("errors.txt", "w") +# sys.stderr = log_file __all__ = [ diff --git a/swarms/structs/flow.py b/swarms/structs/flow.py index 8d7a09ed..4964d57a 100644 --- a/swarms/structs/flow.py +++ b/swarms/structs/flow.py @@ -94,8 +94,8 @@ class Flow: def __init__( self, - llm: Any, # template: str, + llm: Any, max_loops: int = 5, stopping_condition: Optional[Callable[[str], bool]] = None, loop_interval: int = 1, @@ -107,8 +107,8 @@ class Flow: dynamic_temperature: bool = False, **kwargs: Any, ): - self.llm = llm # self.template = template + self.llm = llm self.max_loops = max_loops self.stopping_condition = stopping_condition self.loop_interval = loop_interval @@ -121,7 +121,21 @@ class Flow: self.interactive = interactive self.dashboard = dashboard self.dynamic_temperature = dynamic_temperature - self.tools = tools + self.tools = tools or [] + + def load_tools(self, task: str, **kwargs): + for i in range(self.max_loops): + for tool in self.tools: + tool_prompt = f"\n\nTool: {tool.__name__}\n{tool.__doc__}" + reponse = self.llm( + f""" + {FLOW_SYSTEM_PROMPT} + {tool_prompt} + + History: {reponse} + + """, **kwargs + ) def provide_feedback(self, feedback: str) -> None: """Allow users to provide feedback on the responses."""