mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-07 12:47:55 -10:00
feat: add custom tools support to research command with file and built-in tool loading
This commit is contained in:
1 parent
c8378118e7
commit
cdb42a3f08
15 files changed
+386
-215
No files matched your search
@@ -191,12 +191,20 @@ praisonai research --model deep-research-pro "Your research query"
|
||||
# Rewrite query for better results (uses QueryRewriterAgent)
|
||||
praisonai research --query-rewrite "AI trends"
|
||||
|
||||
# Use custom tools from file (gathers context before deep research)
|
||||
praisonai research --tools tools.py "Your research query"
|
||||
praisonai research -t my_tools.py "Your research query"
|
||||
|
||||
# Use built-in tools by name (comma-separated)
|
||||
praisonai research --tools "internet_search,wiki_search" "Your query"
|
||||
praisonai research -t "yfinance,calculator_tools" "Stock analysis query"
|
||||
|
||||
# Save output to file (output/research/{query}.md)
|
||||
praisonai research --save "Your research query"
|
||||
praisonai research -s "Your research query"
|
||||
|
||||
# Combine options
|
||||
praisonai research --query-rewrite --save "Your research query"
|
||||
praisonai research --query-rewrite --tools tools.py --save "Your research query"
|
||||
|
||||
# Verbose mode (show debug logs)
|
||||
praisonai research -v "Your research query"
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ RUN mkdir -p /root/.praison
|
||||
# Install Python packages (using latest versions)
|
||||
RUN pip install --no-cache-dir \
|
||||
flask \
|
||||
"praisonai>=2.2.94" \
|
||||
"praisonai>=2.2.95" \
|
||||
"praisonai[api]" \
|
||||
gunicorn \
|
||||
markdown
|
||||
|
||||
@@ -16,7 +16,7 @@ RUN mkdir -p /root/.praison
|
||||
# Install Python packages (using latest versions)
|
||||
RUN pip install --no-cache-dir \
|
||||
praisonai_tools \
|
||||
"praisonai>=2.2.94" \
|
||||
"praisonai>=2.2.95" \
|
||||
"praisonai[chat]" \
|
||||
"embedchain[github,youtube]"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ RUN mkdir -p /root/.praison
|
||||
# Install Python packages (using latest versions)
|
||||
RUN pip install --no-cache-dir \
|
||||
praisonai_tools \
|
||||
"praisonai>=2.2.94" \
|
||||
"praisonai>=2.2.95" \
|
||||
"praisonai[ui]" \
|
||||
"praisonai[chat]" \
|
||||
"praisonai[realtime]" \
|
||||
|
||||
@@ -16,7 +16,7 @@ RUN mkdir -p /root/.praison
|
||||
# Install Python packages (using latest versions)
|
||||
RUN pip install --no-cache-dir \
|
||||
praisonai_tools \
|
||||
"praisonai>=2.2.94" \
|
||||
"praisonai>=2.2.95" \
|
||||
"praisonai[ui]" \
|
||||
"praisonai[crewai]"
|
||||
|
||||
|
||||
+2
-2
@@ -121,7 +121,7 @@ healthcheck:
|
||||
## 📦 Package Versions
|
||||
|
||||
All Docker images use consistent, up-to-date versions:
|
||||
- PraisonAI: `>=2.2.94`
|
||||
- PraisonAI: `>=2.2.95`
|
||||
- PraisonAI Agents: `>=0.0.92`
|
||||
- Python: `3.11-slim`
|
||||
|
||||
@@ -218,7 +218,7 @@ docker-compose up -d
|
||||
### Version Pinning
|
||||
To use specific versions, update the Dockerfile:
|
||||
```dockerfile
|
||||
RUN pip install "praisonai==2.2.94" "praisonaiagents==0.0.92"
|
||||
RUN pip install "praisonai==2.2.95" "praisonaiagents==0.0.92"
|
||||
```
|
||||
|
||||
## 🌐 Production Deployment
|
||||
|
||||
+29
-4
@@ -1,9 +1,34 @@
|
||||
# PraisonAI Package
|
||||
|
||||
This is the PraisonAI package, which serves as a wrapper for PraisonAIAgents.
|
||||
## Development
|
||||
|
||||
It provides a simple and intuitive interface for working with AI agents and their capabilities.
|
||||
```bash
|
||||
# Install
|
||||
uv sync
|
||||
|
||||
## Directory Structure
|
||||
# Build
|
||||
uv build
|
||||
|
||||
The main package code is located in the `praisonai` subdirectory.
|
||||
# Publish
|
||||
uv publish
|
||||
```
|
||||
|
||||
## Version Bump
|
||||
|
||||
```bash
|
||||
# From project root
|
||||
python src/praisonai/scripts/bump_version.py 2.2.96
|
||||
|
||||
# With praisonaiagents dependency
|
||||
python src/praisonai/scripts/bump_version.py 2.2.96 --agents 0.0.167
|
||||
```
|
||||
|
||||
## Release
|
||||
|
||||
```bash
|
||||
# From project root (runs uv lock, build, git tag, gh release)
|
||||
python src/praisonai/scripts/release.py
|
||||
|
||||
# Then publish
|
||||
cd src/praisonai && uv publish
|
||||
```
|
||||
@@ -3,8 +3,8 @@ class Praisonai < Formula
|
||||
|
||||
desc "AI tools for various AI applications"
|
||||
homepage "https://github.com/MervinPraison/PraisonAI"
|
||||
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.94.tar.gz"
|
||||
sha256 `curl -sL https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.94.tar.gz | shasum -a 256`.split.first
|
||||
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.95.tar.gz"
|
||||
sha256 `curl -sL https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.95.tar.gz | shasum -a 256`.split.first
|
||||
license "MIT"
|
||||
|
||||
depends_on "[email protected]"
|
||||
|
||||
@@ -579,6 +579,7 @@ class PraisonAI:
|
||||
parser.add_argument("--auto-analyze", action="store_true", help="Enable automatic analysis in context engineering")
|
||||
parser.add_argument("--research", action="store_true", help="Run deep research on a topic")
|
||||
parser.add_argument("--query-rewrite", action="store_true", help="Rewrite query before research for better results")
|
||||
parser.add_argument("--tools", "-t", type=str, help="Path to tools.py file for research agent")
|
||||
parser.add_argument("--save", "-s", action="store_true", help="Save research output to file (output/research/)")
|
||||
parser.add_argument("--verbose", "-v", action="store_true", help="Enable verbose output for research")
|
||||
|
||||
@@ -723,7 +724,8 @@ class PraisonAI:
|
||||
verbose = getattr(args, 'verbose', False)
|
||||
save = getattr(args, 'save', False)
|
||||
query_rewrite = getattr(args, 'query_rewrite', False)
|
||||
self.handle_research_command(research_query, research_model, verbose, save, query_rewrite)
|
||||
tools_path = getattr(args, 'tools', None)
|
||||
self.handle_research_command(research_query, research_model, verbose, save, query_rewrite, tools_path)
|
||||
sys.exit(0)
|
||||
|
||||
# Only check framework availability for agent-related operations
|
||||
@@ -963,7 +965,7 @@ class PraisonAI:
|
||||
print(f"[red]ERROR: Context engineering failed: {e}[/red]")
|
||||
sys.exit(1)
|
||||
|
||||
def handle_research_command(self, query: str, model: str = None, verbose: bool = False, save: bool = False, query_rewrite: bool = False) -> str:
|
||||
def handle_research_command(self, query: str, model: str = None, verbose: bool = False, save: bool = False, query_rewrite: bool = False, tools_path: str = None) -> str:
|
||||
"""
|
||||
Handle the research command by creating a DeepResearchAgent and running it.
|
||||
|
||||
@@ -973,6 +975,7 @@ class PraisonAI:
|
||||
verbose: Enable verbose output (default: False)
|
||||
save: Save output to file (default: False)
|
||||
query_rewrite: Rewrite query before research (default: False)
|
||||
tools_path: Path to tools.py file with custom tools (default: None)
|
||||
|
||||
Returns:
|
||||
str: Research report
|
||||
@@ -1012,11 +1015,86 @@ class PraisonAI:
|
||||
|
||||
print(f"Model: {model}")
|
||||
|
||||
# Create DeepResearchAgent (verbose=True is default for streaming output)
|
||||
agent = DeepResearchAgent(model=model)
|
||||
# Load tools if specified
|
||||
tools_list = []
|
||||
if tools_path:
|
||||
# Check if it's a file path or comma-separated tool names
|
||||
if os.path.isfile(tools_path):
|
||||
# Load from file
|
||||
try:
|
||||
import inspect
|
||||
spec = importlib.util.spec_from_file_location("tools_module", tools_path)
|
||||
if spec and spec.loader:
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
# Get all callable functions from the module
|
||||
for name, obj in inspect.getmembers(module):
|
||||
if inspect.isfunction(obj) and not name.startswith('_'):
|
||||
tools_list.append(obj)
|
||||
if tools_list:
|
||||
print(f"[cyan]Loaded {len(tools_list)} tools from {tools_path}[/cyan]")
|
||||
except Exception as e:
|
||||
print(f"[yellow]Warning: Failed to load tools from {tools_path}: {e}[/yellow]")
|
||||
else:
|
||||
# Treat as comma-separated tool names (e.g., "internet_search,wiki_search")
|
||||
try:
|
||||
from praisonaiagents.tools import TOOL_MAPPINGS
|
||||
import praisonaiagents.tools as tools_module
|
||||
|
||||
tool_names = [t.strip() for t in tools_path.split(',')]
|
||||
for tool_name in tool_names:
|
||||
if tool_name in TOOL_MAPPINGS:
|
||||
try:
|
||||
tool = getattr(tools_module, tool_name)
|
||||
tools_list.append(tool)
|
||||
except Exception as e:
|
||||
print(f"[yellow]Warning: Failed to load tool '{tool_name}': {e}[/yellow]")
|
||||
else:
|
||||
print(f"[yellow]Warning: Unknown tool '{tool_name}'[/yellow]")
|
||||
if tools_list:
|
||||
print(f"[cyan]Loaded {len(tools_list)} built-in tools: {', '.join(tool_names)}[/cyan]")
|
||||
except ImportError:
|
||||
print("[yellow]Warning: Could not import tools module[/yellow]")
|
||||
|
||||
# Execute the research
|
||||
result = agent.research(query)
|
||||
# If tools are provided, use Agent with tools first, then DeepResearchAgent
|
||||
if tools_list:
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
|
||||
# Create a research assistant agent with tools
|
||||
research_assistant = Agent(
|
||||
name="Research Assistant",
|
||||
role="Information Gatherer",
|
||||
goal="Gather relevant information using available tools",
|
||||
backstory="You are an expert at using tools to gather information for research.",
|
||||
tools=tools_list,
|
||||
llm="gpt-4o-mini",
|
||||
verbose=False
|
||||
)
|
||||
|
||||
# Create task to gather initial information
|
||||
gather_task = Task(
|
||||
description=f"Use your tools to gather relevant information about: {query}",
|
||||
expected_output="A summary of information gathered from the tools",
|
||||
agent=research_assistant
|
||||
)
|
||||
|
||||
print("[cyan]Gathering information with tools...[/cyan]")
|
||||
agents = PraisonAIAgents(agents=[research_assistant], tasks=[gather_task], verbose=0)
|
||||
tool_results = agents.start()
|
||||
|
||||
# Enhance query with tool results
|
||||
enhanced_query = f"{query}\n\nAdditional context from tools:\n{tool_results}"
|
||||
print("[cyan]Tools context gathered, starting deep research...[/cyan]")
|
||||
|
||||
# Create DeepResearchAgent
|
||||
agent = DeepResearchAgent(model=model)
|
||||
result = agent.research(enhanced_query)
|
||||
else:
|
||||
# Create DeepResearchAgent (verbose=True is default for streaming output)
|
||||
agent = DeepResearchAgent(model=model)
|
||||
|
||||
# Execute the research
|
||||
result = agent.research(query)
|
||||
|
||||
print("\n[bold green]Research Complete![/bold green]")
|
||||
print("\n" + "="*60)
|
||||
|
||||
@@ -57,7 +57,7 @@ class CloudDeployer:
|
||||
file.write("FROM python:3.11-slim\n")
|
||||
file.write("WORKDIR /app\n")
|
||||
file.write("COPY . .\n")
|
||||
file.write("RUN pip install flask praisonai==2.2.94 gunicorn markdown\n")
|
||||
file.write("RUN pip install flask praisonai==2.2.95 gunicorn markdown\n")
|
||||
file.write("EXPOSE 8080\n")
|
||||
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "0.0.1"
|
||||
__version__ = "2.2.95"
|
||||
+10
-193
@@ -1,9 +1,9 @@
|
||||
[project]
|
||||
name = "PraisonAI"
|
||||
version = "2.2.94"
|
||||
dynamic = ["version"]
|
||||
description = "PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration."
|
||||
readme = "README.md"
|
||||
license = ""
|
||||
license = {text = "MIT"}
|
||||
requires-python = ">=3.10"
|
||||
authors = [
|
||||
{ name = "Mervin Praison" }
|
||||
@@ -100,200 +100,17 @@ autogen-v4 = [
|
||||
"crewai"
|
||||
]
|
||||
|
||||
[tool.poetry]
|
||||
name = "PraisonAI"
|
||||
version = "2.2.94"
|
||||
description = "PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration."
|
||||
authors = ["Mervin Praison"]
|
||||
license = ""
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.urls]
|
||||
[project.urls]
|
||||
Homepage = "https://docs.praison.ai"
|
||||
Repository = "https://github.com/mervinpraison/PraisonAI"
|
||||
|
||||
[tool.setuptools]
|
||||
packages = ["praisonai"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.10,<3.13"
|
||||
rich = ">=13.7"
|
||||
markdown = ">=3.5"
|
||||
pyparsing = ">=3.0.0"
|
||||
praisonaiagents = ">=0.0.166"
|
||||
python-dotenv = ">=0.19.0"
|
||||
instructor = ">=1.3.3"
|
||||
PyYAML = ">=6.0"
|
||||
mcp = ">=1.6.0"
|
||||
pyautogen = {version = "==0.2.29", optional = true}
|
||||
autogen-agentchat = {version = ">=0.4.0", optional = true}
|
||||
autogen-ext = {version = ">=0.4.0", optional = true}
|
||||
autogen-core = {version = ">=0.4.0", optional = true}
|
||||
crewai = {version = ">=0.157.0", optional = true}
|
||||
praisonai-tools = {version = ">=0.0.22", optional = true}
|
||||
chainlit = {version = "==2.5.5", optional = true}
|
||||
gradio = {version = ">=4.26.0", optional = true}
|
||||
flask = {version = ">=3.0.0", optional = true}
|
||||
agentops = {version = ">=0.3.12", optional = true}
|
||||
langchain-google-genai = {version = ">=2.1.0", optional = true}
|
||||
langchain-anthropic = {version = ">=0.3.0", optional = true}
|
||||
langchain-openai = {version = ">=0.2.1,<0.3.0", optional = true}
|
||||
langchain-cohere = {version = ">=0.3.0,<0.4.0", optional = true}
|
||||
litellm = {version = ">=1.72.6", optional = true}
|
||||
aiosqlite= {version = ">=0.20.0", optional = true}
|
||||
greenlet = {version = ">=3.0.3", optional = true}
|
||||
tavily-python = {version = "==0.5.0", optional=true}
|
||||
crawl4ai = {version = ">=0.7.0", optional = true}
|
||||
websockets = {version = ">=12.0", optional = true}
|
||||
plotly = {version = ">=5.24.0", optional = true}
|
||||
yfinance = {version = ">=0.2.44", optional = true}
|
||||
duckduckgo_search = {version = ">=6.3.0", optional = true}
|
||||
twilio = {version = ">=7.0.0", optional = true}
|
||||
fastapi = {version = ">=0.95.0", optional = true}
|
||||
uvicorn = {version = ">=0.20.0", optional = true}
|
||||
flaml = {version = ">=2.3.1", extras = ["automl"], optional = true}
|
||||
pyngrok = {version = ">=1.4.0", optional = true}
|
||||
sqlalchemy = {version = ">=2.0.36", optional = true}
|
||||
playwright = {version = ">=1.47.0", optional = true}
|
||||
openai = {version = ">=1.54.0", optional = true}
|
||||
pydantic = {version = "<=2.10.1", optional = true}
|
||||
# unsloth = {version = ">=2024.11.7", extras = ["colab-new"], optional = true}
|
||||
|
||||
[tool.poetry.group.docs.dependencies]
|
||||
mkdocs = "*"
|
||||
markdown-include = "*"
|
||||
mkdocs-material = "*"
|
||||
mkdocs-jupyter = "*"
|
||||
mkdocs-glightbox = "*"
|
||||
pymdown-extensions = "*"
|
||||
Pygments = "*"
|
||||
mkdocstrings = "*"
|
||||
mkdocs-apidoc = "*"
|
||||
mkdocstrings-python = "*"
|
||||
pdoc3 = "*"
|
||||
|
||||
[tool.poetry.group.test.dependencies]
|
||||
pytest = "8.2.2"
|
||||
pytest-asyncio = ">=0.26.0"
|
||||
pre-commit = "3.7.1"
|
||||
unittest-xml-reporting = "3.2.0"
|
||||
xmlrunner = "*"
|
||||
unittest2 = "*"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
pytest = "8.2.2"
|
||||
pytest-asyncio = ">=0.26.0"
|
||||
pre-commit = "3.7.1"
|
||||
unittest-xml-reporting = "3.2.0"
|
||||
mkdocs = "*"
|
||||
markdown-include = "*"
|
||||
mkdocs-material = "*"
|
||||
mkdocs-jupyter = "*"
|
||||
mkdocs-glightbox = "*"
|
||||
pymdown-extensions = "*"
|
||||
Pygments = "*"
|
||||
mkdocstrings = "*"
|
||||
mkdocs-apidoc = "*"
|
||||
mkdocstrings-python = "*"
|
||||
pdoc3 = "*"
|
||||
xmlrunner = "*"
|
||||
unittest2 = "*"
|
||||
chainlit = "==2.5.5"
|
||||
gradio = ">=4.26.0"
|
||||
flask = ">=3.0.0"
|
||||
agentops = ">=0.3.12"
|
||||
langchain-google-genai = ">=2.1.0"
|
||||
langchain-anthropic = ">=0.3.0"
|
||||
langchain-openai = ">=0.2.1,<0.3.0"
|
||||
langchain-cohere = ">=0.3.0,<0.4.0"
|
||||
litellm = ">=1.72.6"
|
||||
aiosqlite = ">=0.20.0"
|
||||
greenlet = ">=3.0.3"
|
||||
|
||||
[build-system]
|
||||
requires = [
|
||||
"poetry-core",
|
||||
"setuptools>=42",
|
||||
]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
requires = ["setuptools>=64"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
version = {attr = "praisonai.version.__version__"}
|
||||
|
||||
[tool.poetry.scripts]
|
||||
praisonai = "praisonai.__main__:main"
|
||||
setup-conda-env = "setup.setup_conda_env:main"
|
||||
praisonai-call = "praisonai.api.call:main"
|
||||
|
||||
[tool.poetry.extras]
|
||||
ui = [
|
||||
"chainlit",
|
||||
"aiosqlite",
|
||||
"greenlet",
|
||||
"sqlalchemy",
|
||||
"pydantic"
|
||||
]
|
||||
gradio = ["gradio"]
|
||||
api = ["flask"]
|
||||
agentops = ["agentops"]
|
||||
google = ["langchain-google-genai"]
|
||||
openai = ["langchain-openai"]
|
||||
anthropic = ["langchain-anthropic"]
|
||||
cohere = ["langchain-cohere"]
|
||||
chat = [
|
||||
"chainlit",
|
||||
"litellm",
|
||||
"aiosqlite",
|
||||
"greenlet",
|
||||
"tavily-python",
|
||||
"crawl4ai",
|
||||
"sqlalchemy",
|
||||
"playwright",
|
||||
"rich",
|
||||
"pydantic"
|
||||
]
|
||||
code = [
|
||||
"chainlit",
|
||||
"litellm",
|
||||
"aiosqlite",
|
||||
"greenlet",
|
||||
"tavily-python",
|
||||
"crawl4ai",
|
||||
"sqlalchemy",
|
||||
"playwright",
|
||||
"pydantic"
|
||||
]
|
||||
train = []
|
||||
realtime = [
|
||||
"chainlit",
|
||||
"litellm",
|
||||
"aiosqlite",
|
||||
"greenlet",
|
||||
"tavily-python",
|
||||
"crawl4ai",
|
||||
"websockets",
|
||||
"plotly",
|
||||
"yfinance",
|
||||
"duckduckgo_search",
|
||||
"sqlalchemy"
|
||||
]
|
||||
call = [
|
||||
"twilio",
|
||||
"fastapi",
|
||||
"uvicorn",
|
||||
"websockets",
|
||||
"flaml",
|
||||
"pyngrok",
|
||||
"rich",
|
||||
"openai",
|
||||
]
|
||||
crewai = ["crewai", "praisonai-tools"]
|
||||
autogen = ["pyautogen", "praisonai-tools", "crewai"]
|
||||
autogen-v4 = ["autogen-agentchat", "autogen-ext", "autogen-core", "praisonai-tools", "crewai"]
|
||||
|
||||
[tool.poetry-dynamic-versioning]
|
||||
enable = true
|
||||
vcs = "git"
|
||||
style = "semver"
|
||||
|
||||
[tool.poetry.build]
|
||||
generate-setup-file = false
|
||||
script = "praisonai/setup/post_install.py"
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["."]
|
||||
include = ["praisonai*"]
|
||||
Executable
+142
@@ -0,0 +1,142 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Version bump script for PraisonAI package.
|
||||
|
||||
This script updates the version number in all required locations:
|
||||
- praisonai/version.py (single source of truth for Python package)
|
||||
- praisonai/deploy.py (Dockerfile template)
|
||||
- ../../docker/Dockerfile, Dockerfile.chat, Dockerfile.dev, Dockerfile.ui
|
||||
- praisonai.rb (Homebrew formula)
|
||||
|
||||
Usage:
|
||||
python src/praisonai/scripts/bump_version.py 2.2.96
|
||||
|
||||
Or with optional praisonaiagents version:
|
||||
python src/praisonai/scripts/bump_version.py 2.2.96 --agents 0.0.167
|
||||
"""
|
||||
|
||||
import re
|
||||
import sys
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def get_project_root() -> Path:
|
||||
"""Get the project root directory (praisonai-package)."""
|
||||
# scripts/ -> src/praisonai/ -> src/ -> praisonai-package/
|
||||
return Path(__file__).parent.parent.parent.parent
|
||||
|
||||
|
||||
def update_file(filepath: Path, patterns: list[tuple[str, str]]) -> bool:
|
||||
"""Update a file with the given regex patterns and replacements."""
|
||||
if not filepath.exists():
|
||||
print(f" ⚠️ File not found: {filepath}")
|
||||
return False
|
||||
|
||||
content = filepath.read_text()
|
||||
original = content
|
||||
|
||||
for pattern, replacement in patterns:
|
||||
content = re.sub(pattern, replacement, content)
|
||||
|
||||
if content != original:
|
||||
filepath.write_text(content)
|
||||
print(f" ✅ Updated: {filepath.relative_to(get_project_root())}")
|
||||
return True
|
||||
else:
|
||||
print(f" ⏭️ No changes: {filepath.relative_to(get_project_root())}")
|
||||
return False
|
||||
|
||||
|
||||
def bump_version(new_version: str, agents_version: str | None = None):
|
||||
"""Bump version in all required files."""
|
||||
root = get_project_root()
|
||||
|
||||
print(f"\n🚀 Bumping PraisonAI version to {new_version}\n")
|
||||
|
||||
praisonai_dir = root / "src/praisonai"
|
||||
|
||||
# 1. Update version.py (single source of truth)
|
||||
print("📦 Python Package:")
|
||||
update_file(
|
||||
praisonai_dir / "praisonai/version.py",
|
||||
[(r'__version__ = "[^"]+"', f'__version__ = "{new_version}"')]
|
||||
)
|
||||
|
||||
# 2. Update deploy.py (Dockerfile template)
|
||||
print("\n🐳 Deploy Script:")
|
||||
update_file(
|
||||
praisonai_dir / "praisonai/deploy.py",
|
||||
[(r'praisonai==[0-9.]+', f'praisonai=={new_version}')]
|
||||
)
|
||||
|
||||
# 3. Update Dockerfiles
|
||||
print("\n🐳 Dockerfiles:")
|
||||
dockerfiles = [
|
||||
"docker/Dockerfile",
|
||||
"docker/Dockerfile.chat",
|
||||
"docker/Dockerfile.dev",
|
||||
"docker/Dockerfile.ui",
|
||||
]
|
||||
for dockerfile in dockerfiles:
|
||||
update_file(
|
||||
root / dockerfile,
|
||||
[(r'"praisonai>=[0-9.]+"', f'"praisonai>={new_version}"')]
|
||||
)
|
||||
|
||||
# 4. Update Homebrew formula
|
||||
print("\n🍺 Homebrew Formula:")
|
||||
update_file(
|
||||
praisonai_dir / "praisonai.rb",
|
||||
[(r'v[0-9]+\.[0-9]+\.[0-9]+', f'v{new_version}')]
|
||||
)
|
||||
|
||||
# 5. Update praisonaiagents dependency if specified
|
||||
if agents_version:
|
||||
print(f"\n📦 Updating praisonaiagents dependency to {agents_version}:")
|
||||
update_file(
|
||||
praisonai_dir / "pyproject.toml",
|
||||
[(r'praisonaiagents>=[0-9.]+', f'praisonaiagents>={agents_version}')]
|
||||
)
|
||||
|
||||
print("\n✨ Version bump complete!")
|
||||
print("\nNext steps:")
|
||||
print(" 1. Run: cd src/praisonai && uv lock")
|
||||
print(" 2. Run: cd src/praisonai && uv build")
|
||||
print(f" 3. Commit changes: git add -A && git commit -m 'Bump version to {new_version}'")
|
||||
print(f" 4. Tag release: git tag v{new_version}")
|
||||
print(" 5. Publish: cd src/praisonai && uv publish")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Bump PraisonAI version in all required files"
|
||||
)
|
||||
parser.add_argument(
|
||||
"version",
|
||||
help="New version number (e.g., 2.2.96)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--agents", "-a",
|
||||
help="Optional: Update praisonaiagents dependency version (e.g., 0.0.167)",
|
||||
default=None
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Validate version format
|
||||
if not re.match(r'^\d+\.\d+\.\d+$', args.version):
|
||||
print(f"❌ Invalid version format: {args.version}")
|
||||
print(" Expected format: X.Y.Z (e.g., 2.2.96)")
|
||||
sys.exit(1)
|
||||
|
||||
if args.agents and not re.match(r'^\d+\.\d+\.\d+$', args.agents):
|
||||
print(f"❌ Invalid agents version format: {args.agents}")
|
||||
print(" Expected format: X.Y.Z (e.g., 0.0.167)")
|
||||
sys.exit(1)
|
||||
|
||||
bump_version(args.version, args.agents)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+102
@@ -0,0 +1,102 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Release script for PraisonAI package.
|
||||
|
||||
Usage:
|
||||
python src/praisonai/scripts/release.py
|
||||
|
||||
This script:
|
||||
1. Reads version from praisonai/version.py
|
||||
2. Runs uv lock
|
||||
3. Runs uv build
|
||||
4. Commits changes
|
||||
5. Creates git tag
|
||||
6. Pushes to GitHub
|
||||
7. Creates GitHub release (latest)
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def get_project_root() -> Path:
|
||||
"""Get the project root directory (praisonai-package)."""
|
||||
return Path(__file__).parent.parent.parent.parent
|
||||
|
||||
|
||||
def get_praisonai_dir() -> Path:
|
||||
"""Get the praisonai package directory."""
|
||||
return get_project_root() / "src/praisonai"
|
||||
|
||||
|
||||
def get_version() -> str:
|
||||
"""Read version from version.py."""
|
||||
version_file = get_praisonai_dir() / "praisonai/version.py"
|
||||
content = version_file.read_text()
|
||||
for line in content.splitlines():
|
||||
if line.startswith("__version__"):
|
||||
return line.split('"')[1]
|
||||
raise ValueError("Could not find version in version.py")
|
||||
|
||||
|
||||
def run(cmd: list[str], cwd: Path | None = None, check: bool = True) -> subprocess.CompletedProcess:
|
||||
"""Run a command and print it."""
|
||||
print(f"$ {' '.join(cmd)}")
|
||||
result = subprocess.run(cmd, cwd=cwd, capture_output=True, text=True)
|
||||
if result.stdout:
|
||||
print(result.stdout)
|
||||
if result.stderr:
|
||||
print(result.stderr, file=sys.stderr)
|
||||
if check and result.returncode != 0:
|
||||
print(f"❌ Command failed with exit code {result.returncode}")
|
||||
sys.exit(1)
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
root = get_project_root()
|
||||
praisonai_dir = get_praisonai_dir()
|
||||
version = get_version()
|
||||
tag = f"v{version}"
|
||||
|
||||
print(f"\n🚀 Releasing PraisonAI {tag}\n")
|
||||
|
||||
# 1. uv lock
|
||||
print("📦 Running uv lock...")
|
||||
run(["uv", "lock"], cwd=praisonai_dir)
|
||||
|
||||
# 2. uv build
|
||||
print("\n🔨 Running uv build...")
|
||||
run(["uv", "build"], cwd=praisonai_dir)
|
||||
|
||||
# 3. Git add and commit
|
||||
print("\n📝 Committing changes...")
|
||||
run(["git", "add", "-A"], cwd=root)
|
||||
run(["git", "commit", "-m", f"Release {tag}"], cwd=root, check=False)
|
||||
|
||||
# 4. Create git tag
|
||||
print(f"\n🏷️ Creating tag {tag}...")
|
||||
run(["git", "tag", "-f", tag], cwd=root)
|
||||
|
||||
# 5. Push to GitHub
|
||||
print("\n⬆️ Pushing to GitHub...")
|
||||
run(["git", "push"], cwd=root)
|
||||
run(["git", "push", "--tags", "-f"], cwd=root)
|
||||
|
||||
# 6. Create GitHub release
|
||||
print(f"\n🎉 Creating GitHub release {tag}...")
|
||||
run([
|
||||
"gh", "release", "create", tag,
|
||||
"--title", f"PraisonAI {tag}",
|
||||
"--notes", f"Release {tag}",
|
||||
"--latest"
|
||||
], cwd=root)
|
||||
|
||||
print(f"\n✅ Released PraisonAI {tag}")
|
||||
print("\nNext step:")
|
||||
print(" cd src/praisonai && uv publish")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Generated
-1
@@ -4044,7 +4044,6 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "praisonai"
|
||||
version = "2.2.94"
|
||||
source = { editable = "." }
|
||||
dependencies = [
|
||||
{ name = "instructor" },
|
||||
|
||||
Reference in new issue
Block a user