From 60e18d8a84fdabfe204e233e7711dfde49a59b42 Mon Sep 17 00:00:00 2001 From: marko-kraemer Date: Thu, 31 Oct 2024 22:26:30 +0100 Subject: [PATCH] pip install agentpress --- .github/workflows/bump-version.yml | 51 +++++++++++++++++++++++++ .github/workflows/ci.yml | 28 ++++++++++++++ .github/workflows/publish.yml | 36 ++++++++++++++++++ README.md | 61 ++++++++++++++++-------------- agentpress/__init__.py | 13 ++++++- pyproject.toml | 15 +++++++- 6 files changed, 173 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/bump-version.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml new file mode 100644 index 00000000..f19ea3c7 --- /dev/null +++ b/.github/workflows/bump-version.yml @@ -0,0 +1,51 @@ +name: Bump Version + +on: + workflow_dispatch: + inputs: + version_part: + description: 'Part of version to bump (major, minor, patch)' + required: true + default: 'patch' + type: choice + options: + - major + - minor + - patch + +jobs: + bump-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Install Poetry + run: | + curl -sSL https://install.python-poetry.org | python3 - + + - name: Configure Git + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Bump version + run: | + poetry version ${{ github.event.inputs.version_part }} + NEW_VERSION=$(poetry version -s) + echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + commit-message: "chore: bump version to ${{ env.NEW_VERSION }}" + title: "Bump version to ${{ env.NEW_VERSION }}" + body: "Automated version bump to ${{ env.NEW_VERSION }}" + branch: "bump-version-${{ env.NEW_VERSION }}" + base: "main" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..23298fbf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,28 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Install Poetry + run: | + curl -sSL https://install.python-poetry.org | python3 - + + - name: Install dependencies + run: poetry install + + - name: Run tests + run: poetry run pytest \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..b63f371f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,36 @@ +name: Publish to PyPI + +on: + release: + types: [published] + + # Allows manual trigger from GitHub Actions tab + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Install Poetry + run: | + curl -sSL https://install.python-poetry.org | python3 - + + - name: Configure Poetry + run: | + poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} + + - name: Install dependencies + run: poetry install + + - name: Build package + run: poetry build + + - name: Publish to PyPI + run: poetry publish \ No newline at end of file diff --git a/README.md b/README.md index 7d4ec4d2..d465a3dc 100644 --- a/README.md +++ b/README.md @@ -9,33 +9,17 @@ AgentPress is a lightweight, powerful utility for kickstarting your LLM App or A - **Flexible LLM Integration**: Uses LiteLLM under the hood, allowing easy switching between different LLM providers. - **State Management**: JSON-based state persistence for storing information, tool data, and runtime state. +## Installation + +```bash +pip install agentpress +``` ## Quick Start -1. Clone the repository: - ``` - git clone https://github.com/kortix-ai/agentpress - cd agentpress - ``` +1. Set up your environment variables (API keys, etc.) in a `.env` file. -2. Install Poetry (if not already installed): - ``` - pip install poetry - ``` - -3. Install dependencies using Poetry: - ``` - poetry install - ``` - -4. Run with poetry: - ``` - poetry run python agent.py - ``` - -5. Set up your environment variables (API keys, etc.) in a `.env` file. - -6. Create a simple tool: +2. Create a simple tool: ```python from agentpress.tool import Tool, ToolResult, tool_schema @@ -56,7 +40,7 @@ AgentPress is a lightweight, powerful utility for kickstarting your LLM App or A return self.success_response(f"The sum is {a + b}") ``` -7. Use the ThreadManager to run a conversation: +3. Use the ThreadManager to run a conversation: ```python import asyncio from agentpress.thread_manager import ThreadManager @@ -78,8 +62,7 @@ AgentPress is a lightweight, powerful utility for kickstarting your LLM App or A asyncio.run(main()) ``` - -8. Create an autonomous agent with multiple iterations: +4. Create an autonomous agent with multiple iterations: ```python import asyncio from agentpress.thread_manager import ThreadManager @@ -95,7 +78,7 @@ AgentPress is a lightweight, powerful utility for kickstarting your LLM App or A for iteration in range(max_iterations): print(f"Iteration {iteration + 1}/{max_iterations}") - await thread_manager.add_message(thread_id, {"role": "user", "content": "Continue!"}) + await thread_manager.add_message(thread_id, {"role": "user", "content": "Continue!"}) response = await thread_manager.run_thread( thread_id=thread_id, @@ -111,8 +94,30 @@ AgentPress is a lightweight, powerful utility for kickstarting your LLM App or A if __name__ == "__main__": asyncio.run(run_autonomous_agent()) ``` + This example demonstrates how to create an autonomous agent that runs for a specified number of iterations. It uses the `FilesTool` to + interact with the file system and showcases how to control the behavior of `run_thread` by adjusting parameters like `temperature`, + `max_tokens`, and `tool_choice`. The agent creates files autonomously. + +## Development Setup + +If you want to contribute or modify the package: + +1. Clone the repository: + ```bash + git clone https://github.com/kortix-ai/agentpress + cd agentpress + ``` + +2. Install Poetry (if not already installed): + ```bash + pip install poetry + ``` + +3. Install dependencies: + ```bash + poetry install + ``` - This example demonstrates how to create an autonomous agent that runs for a specified number of iterations. It uses the `FilesTool` to interact with the file system and showcases how to control the behavior of `run_thread` by adjusting parameters like `temperature`, `max_tokens`, and `tool_choice`. The agent creates files autonomously. ## Contributing diff --git a/agentpress/__init__.py b/agentpress/__init__.py index 70d30f8b..628afb06 100644 --- a/agentpress/__init__.py +++ b/agentpress/__init__.py @@ -1,6 +1,17 @@ from .llm import make_llm_api_call from .thread_manager import ThreadManager +from .tool import Tool, ToolResult, tool_schema +from .state_manager import StateManager +from .tool_registry import ToolRegistry + +__version__ = "0.1.0" __all__ = [ - 'make_llm_api_call', 'ThreadManager' + 'make_llm_api_call', + 'ThreadManager', + 'Tool', + 'ToolResult', + 'tool_schema', + 'StateManager', + 'ToolRegistry' ] \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 347d2e43..a8210f85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,24 @@ [tool.poetry] name = "agentpress" version = "0.1.0" -description = "LLM Messages[] API on Steroids called \"Threads\" with easy Tool Definition & Tool Execution" +description = "LLM Messages[] API on Steroids called \"Threads\" with easy Tool Execution and State Management" authors = ["marko-kraemer "] readme = "README.md" packages = [ { include = "agentpress" }, ] +license = "MIT" +homepage = "https://github.com/kortix-ai/agentpress" +repository = "https://github.com/kortix-ai/agentpress" +keywords = ["llm", "ai", "agents", "ai agents", "ai agent framework"] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development :: Libraries :: Python Modules", +] [tool.poetry.dependencies] python = "^3.12" @@ -15,7 +27,6 @@ python-dotenv = "^1.0.1" litellm = "^1.44.4" agentops = "^0.3.10" - [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" \ No newline at end of file