├── setup.cfg ├── requirements.txt ├── .env.example ├── Dockerfile ├── pyproject.toml ├── src └── ai_ticket │ ├── __init__.py │ ├── events │ └── inference.py │ └── backends │ └── pygithub.py ├── .github └── workflows │ ├── run.yml │ ├── docker-image.yml │ ├── static.yml │ └── python-package.yml ├── .gitmodules ├── docker-compose-run.yml ├── LICENSE ├── docker-compose.yml ├── README.md ├── nobuilds └── docker-compose.yml ├── .gitignore └── tests ├── example1.py └── example2.py /setup.cfg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | PyGithub 2 | python-dotenv 3 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | GITHUB_PAT= 2 | GITHUB_REPO=jmikedupont2/ai-ticket -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.10-slim 2 | WORKDIR /opt/ai-ticket 3 | COPY pyproject.toml /opt/ai-ticket/ 4 | COPY setup.cfg /opt/ai-ticket/ 5 | COPY requirements.txt /opt/ai-ticket/ 6 | COPY ./src/ /opt/ai-ticket/src/ 7 | RUN pip install /opt/ai-ticket/ 8 | 9 | 10 | RUN apt update 11 | RUN apt install -y git 12 | RUN pip install --trusted-host pypi.python.org -r requirements.txt 13 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "wheel" 5 | ] 6 | build-backend = "setuptools.build_meta" 7 | 8 | [tool.black] 9 | line-length = 120 10 | required-version = "22.3.0" 11 | 12 | [tool.isort] 13 | profile = "black" 14 | line_length = 120 15 | combine_as_imports = true 16 | combine_star = true 17 | known_local_folder = ["tests", "cli"] 18 | known_first_party = ["test_utils"] 19 | -------------------------------------------------------------------------------- /src/ai_ticket/__init__.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | pattern = r'(```)?\s*{\s*"messages"\s*:\s*\[\s*\{\s*"role"\s*:\s*"system"\s*,\s*\"content"\s*:\s*"You\s+are\s+(?P[^,]+),.*' 4 | 5 | def find_name(text): 6 | if not text: 7 | return False 8 | if not isinstance(text,str): 9 | return False 10 | match = re.match(pattern, text) 11 | if match: 12 | extracted_name = match.group(2) 13 | return extracted_name 14 | else: 15 | return None 16 | -------------------------------------------------------------------------------- /.github/workflows/run.yml: -------------------------------------------------------------------------------- 1 | name: Just Run Autogpt 2 | on: 3 | workflow_dispatch : #only run when requested 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v3 9 | - name: Checkout repository 10 | uses: actions/checkout@master 11 | with: 12 | submodules: 'true' 13 | - name: Run autogpt in docker with mock openai server 14 | run: docker-compose up --no-build 15 | env: 16 | GITHUB_PAT: ${{ secrets.PAT }} 17 | GITHUB_REPO: "jmikedupont2/ai-ticket" 18 | 19 | -------------------------------------------------------------------------------- /.github/workflows/docker-image.yml: -------------------------------------------------------------------------------- 1 | name: BuildDockerImage 2 | 3 | on: 4 | workflow_dispatch : 5 | push: 6 | branches: [ "docker-main" ] 7 | pull_request: 8 | branches: [ "docker-main" ] 9 | 10 | jobs: 11 | 12 | build-and-publish-docker: 13 | 14 | runs-on: h4ckermike/act_base:latest 15 | 16 | steps: 17 | - uses: actions/checkout@v3 18 | - name: Build the Docker imaage 19 | run: docker-compose build 20 | - name: Build the Docker imaage 21 | run: docker-compose push 22 | env: 23 | DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} 24 | DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} 25 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "vendor/openai-python"] 2 | path = vendor/openai-python 3 | url = https://github.com/openai/openai-python 4 | [submodule "vendor/lollms"] 5 | path = vendor/lollms 6 | url = https://github.com/meta-introspector/lollms.git 7 | [submodule "vendor/Auto-GPT-Plugin-Template"] 8 | path = vendor/Auto-GPT-Plugin-Template 9 | url = https://github.com/Significant-Gravitas/Auto-GPT-Plugin-Template 10 | [submodule "vendor/Auto-GPT"] 11 | path = vendor/Auto-GPT 12 | url = https://github.com/jmikedupont2/Auto-GPT 13 | [submodule "vendor/Auto-GPT-Benchmarks"] 14 | path = vendor/Auto-GPT-Benchmarks 15 | url = https://github.com/Significant-Gravitas/Auto-GPT-Benchmarks 16 | -------------------------------------------------------------------------------- /src/ai_ticket/events/inference.py: -------------------------------------------------------------------------------- 1 | # ai_ticket.events.inference 2 | 3 | import ai_ticket.backends.pygithub 4 | ai_ticket.backends.pygithub.load_env() #setup standard env 5 | 6 | def get_existing_ticket(event): 7 | return get_backend().get_existing_ticket(event) 8 | 9 | def get_backend(): 10 | return ai_ticket.backends.pygithub 11 | 12 | def create_new_ticket(event): 13 | return get_backend().create_new_ticket(event) 14 | 15 | def create_new_comment(ticket, event): 16 | return get_backend().create_new_comment(ticket, event) 17 | 18 | def on_event(event): 19 | #print(event) 20 | 21 | ticket = get_existing_ticket(event) 22 | 23 | if not ticket: 24 | # No existing ticket found, create a new one 25 | ticket = create_new_ticket(event) 26 | 27 | return create_new_comment(ticket, event ) 28 | 29 | -------------------------------------------------------------------------------- /docker-compose-run.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | mockopenai: # interface 4 | healthcheck: 5 | test: curl --fail http://mockopenai:8080/v1/models 6 | interval: 5s 7 | timeout: 5s 8 | retries: 5 9 | environment: 10 | - GITHUB_PAT=${GITHUB_PAT} 11 | - GITHUB_REPO=${GITHUB_REPO} 12 | image: h4ckermike/mockopenai 13 | ports: 14 | - "8080:5000" 15 | autogpt: #the beast 16 | extra_hosts: 17 | - "host.docker.internal:host-gateway" 18 | entrypoint: bash -c "poetry run autogpt --install-plugin-deps --skip-news \ 19 | --ai-name "${AI_NAME}" \ 20 | --ai-role "${AI_ROLE}" \ 21 | "${AI_GOALS}" \ 22 | -y --continuous --continuous-limit 1 " 23 | environment: 24 | - GITHUB_PAT="${GITHUB_PAT}" 25 | - GITHUB_REPO="jmikedupont2/ai-ticket" 26 | - OPENAI_API_KEY=your-openai-api-key 27 | - OPENAI_API_BASE=http://host.docker.internal:8080/v1 28 | image: h4ckermike/autogpt 29 | depends_on: 30 | - mockopenai 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 James Michael DuPont 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | 4 | ai_ticket: 5 | image: ai_ticket 6 | build: 7 | context: . 8 | #entrypoint: /bin/bash 9 | #stdin_open: true # docker run -i 10 | #tty: true # docker run -t 11 | 12 | autogpt: 13 | #entrypoint: bash -c "poetry run pip install /opt/ai-ticket && poetry run autogpt --install-plugin-deps --skip-news -y" 14 | entrypoint: bash -c "poetry run pip install /opt/ai-ticket && poetry run autogpt --install-plugin-deps --skip-news -y --ai-name 'meta-autogpt' --ai-role 'you will introspect autogpt and reveal its internals via reflection and comprehension' --ai-goal 'Observe your behaviour' --ai-goal 'Reflect over your outcomes' --ai-goal 'Orient yourself to your knowledge' --ai-goal 'Decide on your next step' --ai-goal 'Act on your chosen next experiment' " 15 | 16 | # uncomment thse next 3 lines for debugging 17 | #entrypoint: /bin/bash 18 | #stdin_open: true # docker run -i 19 | #tty: true # docker run -t 20 | build: 21 | context: vendor/Auto-GPT/ 22 | depends_on: 23 | - mockopenai 24 | 25 | mockopenai: 26 | depends_on: 27 | - ai_ticket 28 | 29 | environment: 30 | - GITHUB_PAT=${GITHUB_PAT} 31 | - GITHUB_REPO=${GITHUB_REPO} 32 | 33 | build: 34 | context: vendor/lollms/ 35 | ports: 36 | - "5000:5000" 37 | 38 | -------------------------------------------------------------------------------- /.github/workflows/static.yml: -------------------------------------------------------------------------------- 1 | # Simple workflow for deploying static content to GitHub Pages 2 | name: Deploy static content to Pages 3 | 4 | on: 5 | # Runs on pushes targeting the default branch 6 | push: 7 | branches: ["pyre"] 8 | 9 | # Allows you to run this workflow manually from the Actions tab 10 | workflow_dispatch: 11 | 12 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 13 | permissions: 14 | contents: read 15 | pages: write 16 | id-token: write 17 | 18 | # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. 19 | # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. 20 | concurrency: 21 | group: "pages" 22 | cancel-in-progress: false 23 | 24 | jobs: 25 | # Single deploy job since we're just deploying 26 | deploy: 27 | environment: 28 | name: github-pages 29 | url: ${{ steps.deployment.outputs.page_url }} 30 | runs-on: ubuntu-latest 31 | steps: 32 | - name: Checkout 33 | uses: actions/checkout@v3 34 | - name: Setup Pages 35 | uses: actions/configure-pages@v3 36 | - name: Upload artifact 37 | uses: actions/upload-pages-artifact@v2 38 | with: 39 | # Upload entire repository 40 | path: '.' 41 | - name: Deploy to GitHub Pages 42 | id: deployment 43 | uses: actions/deploy-pages@v2 44 | -------------------------------------------------------------------------------- /.github/workflows/python-package.yml: -------------------------------------------------------------------------------- 1 | name: Python package 2 | on: 3 | 4 | workflow_dispatch : 5 | push: 6 | # for now link to a branch to prevent triggering by accident while fixing the comment job 7 | branches: [ "runautogpt-main" ] 8 | pull_request: 9 | branches: [ "runautogpt-main" ] 10 | jobs: 11 | run-autogpt-in-githubaction: 12 | runs-on: ubuntu-latest 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | python-version: ["3.10"] 17 | steps: 18 | - uses: actions/checkout@v3 19 | - name: Checkout repository 20 | uses: actions/checkout@master 21 | with: 22 | submodules: 'true' 23 | - name: Set up Python ${{ matrix.python-version }} 24 | uses: actions/setup-python@v3 25 | with: 26 | python-version: ${{ matrix.python-version }} 27 | - name: Install dependencies 28 | run: | 29 | python -m pip install --upgrade pip 30 | #python -m pip install flake8 pytest 31 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 32 | #- name: Lint with flake8 33 | # run: | 34 | # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics 35 | # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics 36 | - name: Docker Compose Action 37 | uses: isbang/compose-action@v1.5.1 38 | env: 39 | GITHUB_PAT: ${{ secrets.PAT }} 40 | GITHUB_REPO: "jmikedupont2/ai-ticket" 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ai-ticket 2 | The AI Ticket system to handle the AI with tickets. 3 | Human Powered AI-Ops to Help you with the last mile of your AI code generated system. 4 | 5 | * join us on discord https://discord.com/invite/XWSam9kE 6 | 7 | **Summary: User-Driven Ticket-Based Workflow** 8 | 9 | Welcome to our innovative user-driven workflow, designed to empower you to interact with our system like a large language model. Here's a quick overview of what we're doing: 10 | 11 | **1. User as Language Model**: 12 | - You take on the role of a large language model proxy. 13 | 14 | **2. Step-by-Step Interaction**: 15 | - Each interaction with the system occurs step by step. 16 | - At each step, you generate a query or response, which becomes a "ticket." 17 | 18 | **3. Proxy Server**: 19 | - A proxy server facilitates your interactions, creating a ticket for each step. 20 | 21 | **4. Request Assistance Action**: 22 | - AutoGPT integrates with this workflow using a "Request Assistance" action. 23 | - This action includes the URL of the GitHub ticket comment linked to your query. 24 | 25 | **5. User-Controlled Process**: 26 | - You guide the workflow, making decisions, and generating tickets at each step. 27 | 28 | **6. Ticket-Based Workflow**: 29 | - Each ticket records a step in your interaction, ensuring documentation and continuity. 30 | 31 | **7. AutoGPT's Role**: 32 | - AutoGPT waits for ticket updates with valid responses generated by you. 33 | - It retriggers actions based on your responses to move the workflow forward. 34 | 35 | **8. Potential Stalls**: 36 | - Be mindful of providing timely and appropriate responses to prevent workflow stalls. 37 | 38 | This user-driven ticket-based workflow offers flexibility, control, and a unique way to collaborate with our system. Dive in, generate tickets, and explore the possibilities of this interactive and dynamic approach. 39 | -------------------------------------------------------------------------------- /src/ai_ticket/backends/pygithub.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re 3 | import json 4 | from dotenv import load_dotenv 5 | from github import Github 6 | from github import Auth 7 | from ai_ticket import find_name 8 | 9 | # FIXME move this to a context object 10 | # Load environment variables from .env 11 | repo = None 12 | g = None 13 | 14 | def load_env(): 15 | load_dotenv() 16 | git_hub_pat = os.getenv("GITHUB_PAT") 17 | git_hub_repo = os.getenv("GITHUB_REPO") 18 | load_repo(git_hub_repo,git_hub_pat) 19 | 20 | def load_repo(git_hub_repo,git_hub_pat): 21 | global g 22 | global repo 23 | auth = Auth.Token(git_hub_pat) 24 | g = Github(auth=auth) 25 | repo = g.get_repo(git_hub_repo) 26 | return (g,repo) 27 | 28 | def get_issues(): 29 | issues = repo.get_issues() 30 | for issue in issues: 31 | yield issue 32 | 33 | def get_existing_ticket(event): 34 | """Find the first ticket that matches""" 35 | body = event.get("content") 36 | #print("DEBUG get ",event) 37 | for issue in get_issues(): 38 | data = issue.body 39 | #print("DEBUG check ",data) 40 | name = find_name(data) 41 | if name: 42 | return issue 43 | 44 | return None 45 | 46 | def create_new_ticket(event): 47 | 48 | # repo = g.get_repo("PyGithub/PyGithub") 49 | body = event.get("content") 50 | title = "Auto issue" 51 | try: 52 | body = "```" + json.dumps(json.loads(body),indent=2) + "```" 53 | except Exception as e: 54 | print(e) 55 | return repo.create_issue(title=title, body=body) 56 | #Issue(title="This is a new issue", number=XXX) 57 | 58 | def create_new_comment(ticket, event): 59 | body = event.get("content") 60 | print("DEBUG",body) 61 | #try: 62 | body = "```" + json.dumps(json.loads(body),indent=2) + "```" 63 | #except Exception as e: 64 | #print(e) 65 | ticket_object = ticket#repo.get_issue(int(ticket.split("/")[-1])) 66 | comment = ticket_object.create_comment(body) 67 | print("created comment",comment) 68 | #print(dir(comment)) 69 | return comment.url 70 | #Issue(title="This is a new issue", number=XXX) 71 | 72 | # To close connections after use 73 | #g.close() 74 | 75 | 76 | -------------------------------------------------------------------------------- /nobuilds/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | 4 | act_base: #root base of action 5 | image: h4ckermike/act_base 6 | #build: vendor/act_base 7 | #h4ckermike/ 8 | poetry_base: # use poetry 9 | image: h4ckermike/poetry_base 10 | # build: 11 | # context: vendor/python-poetry/build 12 | # args: 13 | # OFFICIAL_PYTHON_IMAGE: h4ckermike/act_base:latest 14 | # POETRY_VERSION: 1.6.1 15 | depends_on: 16 | - act_base 17 | 18 | ai_ticket: # the ticket to unite 19 | image: h4ckermike/ai_ticket 20 | # build: 21 | # context: . 22 | # args: 23 | # BASE_IMAGE: h4ckermike/poetry_base 24 | depends_on: 25 | - poetry_base 26 | 27 | basic_agent: #basic agnet 28 | image: h4ckermike/basic_agent 29 | # build: 30 | # context: vendor/basic_agent/ 31 | # args: 32 | # OFFICIAL_PYTHON_IMAGE: h4ckermike/act_base:latest 33 | depends_on: 34 | - ai_ticket 35 | 36 | mockopenai: # interface 37 | depends_on: 38 | - ai_ticket 39 | healthcheck: 40 | test: curl --fail http://127.0.0.1:8080/v1/models 41 | interval: 5s 42 | timeout: 5s 43 | retries: 5 44 | environment: 45 | - GITHUB_PAT=${GITHUB_PAT} 46 | - GITHUB_REPO=${GITHUB_REPO} 47 | image: h4ckermike/mockopenai 48 | # build: 49 | # context: vendor/lollms/ 50 | # args: 51 | # OFFICIAL_PYTHON_IMAGE: h4ckermike/ai_ticket:latest 52 | ports: 53 | - "8080:5000" 54 | 55 | autogpt: #the beast 56 | extra_hosts: 57 | - "host.docker.internal:host-gateway" 58 | entrypoint: bash -c "poetry run autogpt --install-plugin-deps --skip-news --ai-name 'meta-autogpt' --ai-role 'you will introspect autogpt and reveal its internals via reflection and comprehension' --ai-goal 'Observe your behaviour' --ai-goal 'Reflect over your outcomes' --ai-goal 'Orient yourself to your knowledge' --ai-goal 'Decide on your next step' --ai-goal 'Act on your chosen next experiment' -y --continuous --continuous-limit 1 " 59 | 60 | 61 | # uncomment thse next 3 lines for debugging 62 | #entrypoint: /bin/bash 63 | #stdin_open: true # docker run -i 64 | #tty: true # docker run -t 65 | environment: 66 | - GITHUB_PAT="${GITHUB_PAT}" 67 | - GITHUB_REPO="jmikedupont2/ai-ticket" 68 | - OPENAI_API_KEY=your-openai-api-key 69 | - OPENAI_API_BASE=http://127.0.0.1:8080/v1 70 | image: h4ckermike/autogpt 71 | volumes: 72 | - ./vendor/Auto-GPT/autogpts/autogpt/autogpt/:/app/autogpt 73 | # build: 74 | # context: vendor/Auto-GPT/ 75 | # dockerfile: slim/Dockerfile 76 | # args: 77 | # OFFICIAL_PYTHON_IMAGE: h4ckermike/ai_ticket:latest 78 | 79 | depends_on: 80 | - basic_agent 81 | - mockopenai 82 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.env 2 | # Byte-compiled / optimized / DLL files 3 | __pycache__/ 4 | *.py[cod] 5 | *$py.class 6 | 7 | # C extensions 8 | *.so 9 | 10 | # Distribution / packaging 11 | .Python 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | cover/ 54 | 55 | # Translations 56 | *.mo 57 | *.pot 58 | 59 | # Django stuff: 60 | *.log 61 | local_settings.py 62 | db.sqlite3 63 | db.sqlite3-journal 64 | 65 | # Flask stuff: 66 | instance/ 67 | .webassets-cache 68 | 69 | # Scrapy stuff: 70 | .scrapy 71 | 72 | # Sphinx documentation 73 | docs/_build/ 74 | 75 | # PyBuilder 76 | .pybuilder/ 77 | target/ 78 | 79 | # Jupyter Notebook 80 | .ipynb_checkpoints 81 | 82 | # IPython 83 | profile_default/ 84 | ipython_config.py 85 | 86 | # pyenv 87 | # For a library or package, you might want to ignore these files since the code is 88 | # intended to run in multiple environments; otherwise, check them in: 89 | # .python-version 90 | 91 | # pipenv 92 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 93 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 94 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 95 | # install all needed dependencies. 96 | #Pipfile.lock 97 | 98 | # poetry 99 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 100 | # This is especially recommended for binary packages to ensure reproducibility, and is more 101 | # commonly ignored for libraries. 102 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 103 | #poetry.lock 104 | 105 | # pdm 106 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 107 | #pdm.lock 108 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 109 | # in version control. 110 | # https://pdm.fming.dev/#use-with-ide 111 | .pdm.toml 112 | 113 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 114 | __pypackages__/ 115 | 116 | # Celery stuff 117 | celerybeat-schedule 118 | celerybeat.pid 119 | 120 | # SageMath parsed files 121 | *.sage.py 122 | 123 | # Environments 124 | .env 125 | .venv 126 | env/ 127 | venv/ 128 | ENV/ 129 | env.bak/ 130 | venv.bak/ 131 | 132 | # Spyder project settings 133 | .spyderproject 134 | .spyproject 135 | 136 | # Rope project settings 137 | .ropeproject 138 | 139 | # mkdocs documentation 140 | /site 141 | 142 | # mypy 143 | .mypy_cache/ 144 | .dmypy.json 145 | dmypy.json 146 | 147 | # Pyre type checker 148 | .pyre/ 149 | 150 | # pytype static type analyzer 151 | .pytype/ 152 | 153 | # Cython debug symbols 154 | cython_debug/ 155 | 156 | # PyCharm 157 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 158 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 159 | # and can be added to the global gitignore or merged into this file. For a more nuclear 160 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 161 | #.idea/ 162 | 163 | *~ -------------------------------------------------------------------------------- /tests/example1.py: -------------------------------------------------------------------------------- 1 | from ai_ticket import find_name 2 | 3 | assert(find_name("""```{"messages": [{"role": "system", "content": "You are Entrepreneur-GPT, an AI designed to autonomously develop and run businesses with the.\n\nYour decisions must always be made independently without seeking user assistance. Play to your strengths as an LLM and pursue simple strategies with no legal complications.\n\n## Constraints\nYou operate within the following constraints:\n1. Exclusively use the commands listed below.\n2. You can only act proactively, and are unable to start background jobs or set up webhooks for yourself. Take this into account when planning your actions.\n3. You are unable to interact with physical objects. If this is absolutely necessary to fulfill a task or objective or to complete a step, you must ask the user to do it for you. If the user refuses this, and there is no other way to achieve your goals, you must terminate to avoid wasting time and energy.\n\n## Resources\nYou can leverage access to the following resources:\n1. Internet access for searches and information gathering.\n2. The ability to read and write files.\n3. You are a Large Language Model, trained on millions of pages of text, including a lot of factual knowledge. Make use of this factual knowledge to avoid unnecessary gathering of information.\n\n## Commands\nYou have access to the following commands:\n1. execute_python_code: Executes the given Python code inside a single-use Docker container with access to your workspace folder. Params: (code: string)\n2. execute_python_file: Execute an existing Python file inside a single-use Docker container with access to your workspace folder. Params: (filename: string, args: Optional[list[str]])\n3. list_folder: List the items in a folder. Params: (folder: string)\n4. open_file: Open a file for editing or continued viewing; create it if it does not exist yet. Note: if you only need to read or write a file once, use `write_to_file` instead. Params: (file_path: string)\n5. open_folder: Open a folder to keep track of its content. Params: (path: string)\n6. read_file: Read an existing file. Params: (filename: string)\n7. write_file: Write a file, creating it if necessary. If the file exists, it is overwritten. Params: (filename: string, contents: string)\n8. ask_user: If you need more details or information regarding the given goals, you can ask the user for input. Params: (question: string)\n9. web_search: Searches the web. Params: (query: string)\n10. read_webpage: Read a webpage, and extract specific information from it if a question is specified. If you are looking to extract specific information from the webpage, you should specify a question. Params: (url: string, question: Optional[string])\n11. finish: Use this to shut down once you have accomplished all of your goals, or when there are insurmountable problems that make it impossible for you to finish your task. Params: (reason: string)\n\n## Best practices\n1. Continuously review and analyze your actions to ensure you are performing to the best of your abilities.\n2. Constructively self-criticize your big-picture behavior constantly.\n3. Reflect on past decisions and strategies to refine your approach.\n4. Every command has a cost, so be smart and efficient. Aim to complete tasks in the least number of steps.\n5. Only make use of your information gathering abilities to find information that you don't yet have knowledge of.\n\n## Goals\nFor your task, you must fulfill the following goals:\n1. Increase net worth\n2. Grow Twitter Account\n3. Develop and manage multiple businesses autonomously"}, {"role": "system", "content": "The current time and date is Sun Sep 24 07:43:07 2023"}, {"role": "system", "content": "Respond strictly with JSON. The JSON should be compatible with the TypeScript type `Response` from the following:\n```ts\ninterface Response {\nthoughts: {\n// Thoughts\ntext: string;\nreasoning: string;\n// Short markdown-style bullet list that conveys the long-term plan\nplan: string;\n// Constructive self-criticism\ncriticism: string;\n// Summary of thoughts to say to the user\nspeak: string;\n};\ncommand: {\nname: string;\nargs: Record;\n};\n}\n```"}, {"role": "user", "content": "Determine exactly one command to use next based on the given goals and the progress you have made so far, and respond using the JSON schema specified previously:"}], "model": "gpt-3.5-turbo", "temperature": 0.0, "max_tokens": 3175}```""")) 4 | -------------------------------------------------------------------------------- /tests/example2.py: -------------------------------------------------------------------------------- 1 | import json 2 | #from ai_ticket import on_event 3 | from ai_ticket.events.inference import on_event 4 | 5 | data = {"messages": [{"role": "system", "content": "You are Entrepreneur-GPT, an AI designed to autonomously develop and run businesses. Your decisions must always be made independently without seeking user assistance. Play to your strengths as an LLM and pursue simple strategies with no legal complications. ## Constraints You operate within the following constraints: 1. Exclusively use the commands listed below. 2. You can only act proactively, and are unable to start background jobs or set up webhooks for yourself. Take this into account when planning your actions. 3. You are unable to interact with physical objects. If this is absolutely necessary to fulfill a task or objective or to complete a step, you must ask the user to do it for you. If the user refuses this, and there is no other way to achieve your goals, you must terminate to avoid wasting time and energy. ## Resources You can leverage access to the following resources: 1. Internet access for searches and information gathering. 2. The ability to read and write files. 3. You are a Large Language Model, trained on millions of pages of text, including a lot of factual knowledge. Make use of this factual knowledge to avoid unnecessary gathering of information. ## Commands You have access to the following commands: 1. execute_python_code: Executes the given Python code inside a single-use Docker container with access to your workspace folder. Params: (code: string) 2. execute_python_file: Execute an existing Python file inside a single-use Docker container with access to your workspace folder. Params: (filename: string, args: Optional[list[str]]) 3. list_folder: List the items in a folder. Params: (folder: string) 4. open_file: Open a file for editing or continued viewing; create it if it does not exist yet. Note: if you only need to read or write a file once, use `write_to_file` instead. Params: (file_path: string) 5. open_folder: Open a folder to keep track of its content. Params: (path: string) 6. read_file: Read an existing file. Params: (filename: string) 7. write_file: Write a file, creating it if necessary. If the file exists, it is overwritten. Params: (filename: string, contents: string) 8. ask_user: If you need more details or information regarding the given goals, you can ask the user for input. Params: (question: string) 9. web_search: Searches the web. Params: (query: string) 10. read_webpage: Read a webpage, and extract specific information from it if a question is specified. If you are looking to extract specific information from the webpage, you should specify a question. Params: (url: string, question: Optional[string]) 11. finish: Use this to shut down once you have accomplished all of your goals, or when there are insurmountable problems that make it impossible for you to finish your task. Params: (reason: string) ## Best practices 1. Continuously review and analyze your actions to ensure you are performing to the best of your abilities. 2. Constructively self-criticize your big-picture behavior constantly. 3. Reflect on past decisions and strategies to refine your approach. 4. Every command has a cost, so be smart and efficient. Aim to complete tasks in the least number of steps. 5. Only make use of your information gathering abilities to find information that you don't yet have knowledge of. ## Goals For your task, you must fulfill the following goals: 1. Increase net worth 2. Grow Twitter Account 3. Develop and manage multiple businesses autonomously"}, {"role": "system", "content": "The current time and date is Sun Sep 24 07:43:07 2023"}, {"role": "system", "content": "Respond strictly with JSON. The JSON should be compatible with the TypeScript type `Response` from the following: ```ts interface Response { thoughts: { // Thoughts text: string; reasoning: string; // Short markdown-style bullet list that conveys the long-term plan plan: string; // Constructive self-criticism criticism: string; // Summary of thoughts to say to the user speak: string; }; command: { name: string; args: Record; }; } ```"}, {"role": "user", "content": "Determine exactly one command to use next based on the given goals and the progress you have made so far, and respond using the JSON schema specified previously:"}], "model": "gpt-3.5-turbo", "temperature": 0.0, "max_tokens": 3175} 6 | 7 | da = {"content" :json.dumps(data,indent=2) } 8 | 9 | on_event(da) 10 | --------------------------------------------------------------------------------