This commit is contained in:
marko-kraemer 2024-11-02 19:28:11 +01:00
parent fa7e932f08
commit d77a2dad7c
14 changed files with 803 additions and 633 deletions

View File

@ -1,3 +1,4 @@
OPENAI_API_KEY= OPENAI_API_KEY=
ANTHROPIC_API_KEY= ANTHROPIC_API_KEY=
GROQ_API_KEY= GROQ_API_KEY=
AGENTOPS_API_KEY=

View File

@ -1,8 +1,8 @@
# Include all Python files in agentpress directory # Include all Python files in agentpress directory
recursive-include core *.py recursive-include agentpress *.py
# Include example files # Include example files
recursive-include core/examples * recursive-include agentpress/examples *
# Include any other necessary files # Include any other necessary files
include LICENSE include LICENSE

View File

@ -2,8 +2,11 @@ import os
import shutil import shutil
import click import click
import questionary import questionary
from typing import List, Dict from typing import List, Dict, Optional, Tuple
import time import time
import pkg_resources
import requests
from packaging import version
MODULES = { MODULES = {
"llm": { "llm": {
@ -42,15 +45,57 @@ STARTER_EXAMPLES = {
} }
} }
PACKAGE_NAME = "agentpress"
PYPI_URL = f"https://pypi.org/pypi/{PACKAGE_NAME}/json"
def check_for_updates() -> Tuple[Optional[str], Optional[str], bool]:
"""
Check if there's a newer version available on PyPI
Returns: (current_version, latest_version, update_available)
"""
try:
current_version = pkg_resources.get_distribution(PACKAGE_NAME).version
response = requests.get(PYPI_URL, timeout=2)
response.raise_for_status() # Raise exception for bad status codes
latest_version = response.json()["info"]["version"]
# Compare versions properly using packaging.version
current_ver = version.parse(current_version)
latest_ver = version.parse(latest_version)
return current_version, latest_version, latest_ver > current_ver
except requests.RequestException:
# Handle network-related errors silently
return None, None, False
except Exception as e:
# Log other unexpected errors but don't break the CLI
click.echo(f"Warning: Failed to check for updates: {str(e)}", err=True)
return None, None, False
def show_welcome(): def show_welcome():
"""Display welcome message with ASCII art""" """Display welcome message with ASCII art"""
click.clear() click.clear()
# Check for updates
current_version, latest_version, update_available = check_for_updates()
click.echo(""" click.echo("""
Welcome to AgentPress Welcome to AgentPress
Your AI Agent Building Blocks Your AI Agent Building Blocks
""") """)
if update_available and current_version and latest_version:
click.echo(
f"\n📢 Update available! "
f"{click.style(f'v{current_version}', fg='yellow')}"
f"{click.style(f'v{latest_version}', fg='green')}"
)
click.echo("Run: pip install --upgrade agentpress\n")
time.sleep(1) time.sleep(1)
def copy_module_files(src_dir: str, dest_dir: str, files: List[str]): def copy_module_files(src_dir: str, dest_dir: str, files: List[str]):
@ -82,7 +127,7 @@ def cli():
def init(): def init():
"""Initialize AgentPress modules in your project""" """Initialize AgentPress modules in your project"""
show_welcome() show_welcome()
# Set components directory name to 'agentpress' # Set components directory name to 'agentpress'
components_dir = "agentpress" components_dir = "agentpress"

1376
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -25,12 +25,14 @@ litellm = "^1.44.4"
agentops = "^0.3.10" agentops = "^0.3.10"
click = "^8.1.7" click = "^8.1.7"
questionary = "^2.0.1" questionary = "^2.0.1"
requests = "^2.31.0"
packaging = "^23.2"
[tool.poetry.scripts] [tool.poetry.scripts]
agentpress = "core.cli:main" agentpress = "agentpress.cli:main"
[[tool.poetry.packages]] [[tool.poetry.packages]]
include = "core" include = "agentpress"
[build-system] [build-system]
requires = ["poetry-core"] requires = ["poetry-core"]