Skip to content

Commit

Permalink
v0.2.27
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaslau committed Nov 23, 2024
1 parent 9baccf0 commit d357fbe
Show file tree
Hide file tree
Showing 11 changed files with 272 additions and 165 deletions.
77 changes: 33 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Pynions 🚀
# Pynions

A lean open-source Python framework for building AI-powered automation workflows that run on your machine. Built for marketers who want to automate research, monitoring, and content tasks without cloud dependencies or complex setups.

Expand All @@ -16,13 +16,13 @@ Pynions helps marketers automate:

## Key Features

- 🚀 Start small, ship fast
- 🔌 Easy API connections to your existing tools
- 🤖 AI-first but not AI-only
- 📦 Zero bloat, minimal dependencies
- 🛠 Built for real marketing workflows
- Quick to prototype and iterate
- 🌐 Local-first, no cloud dependencies
- Start small, ship fast
- Easy API connections to your existing tools
- AI-first but not AI-only
- Zero bloat, minimal dependencies
- Built for real marketing workflows
- Quick to prototype and iterate
- Local-first, no cloud dependencies

## Technology Stack

Expand All @@ -38,42 +38,36 @@ Pynions helps marketers automate:
## Quick Start

```bash
# Create project directory
mkdir pynions && cd pynions

# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate

# Install required packages
pip install -r requirements.txt
# Install Pynions
pip install .

# Set up configuration
mkdir -p pynions/config
cp .env.example pynions/config/.env
cp settings.example.json pynions/config/settings.json
# The installer will automatically:
# 1. Create .env from .env.example
# 2. Create pynions.json from pynions.example.json

# Add your API keys to .env
nano pynions/config/.env
nano .env
```

## Example Workflow

```python
import asyncio
from pynions.core.workflow import Workflow, WorkflowStep
from pynions.core import Workflow, WorkflowStep
from pynions.plugins import SerperWebSearch, JinaAIReader
from pynions.core.config import load_config
from pynions.core.datastore import save_result
from pynions.plugins.serper import SerperWebSearch
from pynions.plugins.jina import JinaAIReader

async def main():
# Load configuration
# Load configuration (automatically reads from root .env and pynions.json)
config = load_config()

# Initialize plugins
serper = SerperWebSearch(config["plugins"]["serper"])
jina = JinaAIReader(config["plugins"]["jina"])
serper = SerperWebSearch() # Automatically uses API key from .env
jina = JinaAIReader() # Automatically uses API key from .env

# Create workflow
workflow = Workflow(
Expand Down Expand Up @@ -140,24 +134,19 @@ if __name__ == "__main__":

## Configuration

### Environment Variables (pynions/config/.env)
### Environment Variables (.env)

```bash
# Search API
SERPER_API_KEY=your_serper_key_here
Required:
- `OPENAI_API_KEY`: Your OpenAI API key

# AI Models
OPENAI_API_KEY=your_openai_key_here
ANTHROPIC_API_KEY=your_anthropic_key_here

# Content Processing
JINA_API_KEY=your_jina_key_here
FRASE_API_KEY=your_frase_key_here
```
Optional:
- `SERPER_API_KEY`: For search functionality
- `ANTHROPIC_API_KEY`: For Claude models
- `JINA_API_KEY`: For embeddings

### Application Config (pynions/config/settings.json)
### Application Config (pynions.json)

See [settings.example.json](pynions/config/settings.example.json) for all available options.
See [pynions.example.json](pynions.example.json) for all available options.

## Philosophy

Expand Down Expand Up @@ -240,10 +229,10 @@ Workers are standalone task executors that combine multiple plugins for specific

### Features

- 🎯 Task-specific implementations
- 🔄 Automated data extraction
- 📊 Structured output
- 🛠 Plugin integration
- Efficient processing
- Task-specific implementations
- Automated data extraction
- Structured output
- Plugin integration
- Efficient processing

See [Workers Documentation](docs/workers.md) for more details.
45 changes: 44 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,54 @@
---
title: "Changelog"
publishedAt: "2024-11-03"
updatedAt: "2024-11-22"
updatedAt: "2024-11-23"
summary: "Updates, bug fixes and improvements."
kind: "detailed"
---

## v0.2.27 - Nov 23, 2024

### Changed
- Enhanced configuration management
- Moved `.env` and `pynions.json` to project root
- Removed nested config directory structure
- Added proper typing support for configuration
- Improved singleton pattern implementation
- Added comprehensive test coverage
- Standardized on gpt-4o-mini as default model
- Improved configuration API
- Added `set()` method for runtime configuration
- Added `clear()` method for resetting configuration
- Added `load()` method for custom file paths
- Enhanced environment variable handling
- Updated documentation
- Added new configuration examples
- Updated API documentation
- Added comprehensive test coverage information
- Updated all examples to use gpt-4o-mini
- Simplified example workflow code

### Added
- New configuration methods:
- `set()` for runtime configuration
- `clear()` for resetting state
- `load()` for custom file paths
- Complete test suite for configuration
- Type hints for better IDE support

### Fixed
- Environment variable handling in tests
- Configuration inheritance issues
- Missing type hints
- Inconsistent model defaults across codebase

### Security
- Improved API key management
- Enhanced environment variable handling

### Performance
- Standardized on gpt-4o-mini for better cost-performance ratio

## v0.2.26 - Nov 22, 2024

### Changed
Expand Down
28 changes: 18 additions & 10 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Configuration"
publishedAt: "2024-10-30"
updatedAt: "2024-11-10"
updatedAt: "2024-11-23"
summary: "Simple configuration guide for marketers using Pynions"
kind: "detailed"
---
Expand Down Expand Up @@ -62,26 +62,34 @@ Access configuration in your scripts:
```python
from pynions.core.config import config

# Check API key
if not config.check_api_key():
print("Add your OpenAI API key to .env file")
exit()

# Get settings (with defaults)
output_dir = config.get("output_folder", "data")
save_to_file = config.get("save_results", True)
model = config.get("model", "gpt-4o-mini")
temperature = config.get("temperature", 0.7)

# Set runtime configuration
config.set("max_tokens", 2000)

# Load custom configuration files
config.load(
env_path=Path("custom/.env"),
config_path=Path("custom/pynions.json")
)

# Clear configuration if needed
config.clear()
```

## AI Configuration

Pynions uses [LiteLLM](https://docs.litellm.ai/docs/) for AI features. You don't need to configure AI settings - they're handled automatically.
Pynions uses [LiteLLM](https://docs.litellm.ai/docs/) for AI features. The configuration system automatically manages API keys and model settings.

Example usage:
```python
from litellm import completion

response = completion(
model="gpt-4o-mini",
model=config.get("model", "gpt-4o-mini"),
temperature=config.get("temperature", 0.7),
messages=[{"role": "user", "content": "Hello!"}]
)
```
Expand Down
98 changes: 24 additions & 74 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,95 +24,45 @@ python3 --version # Should show 3.9 or higher
git --version
```

## Project Setup

1. Create project structure:

```bash
# Create main directory
mkdir -p ~/Documents/pynions && cd ~/Documents/pynions

# Initialize git repository
git init
Create core directories
mkdir -p pynions/{plugins,utils,config} docs/{examples,plugins,workflows} tests/test_plugins data/{raw,output}

#Create core Python files
touch pynions/init.py pynions/core.py
touch pynions/plugins/init.py pynions/plugins/{serper,litellm,playwright,jina}plugin.py
touch pynions/utils/init.py pynions/utils/helpers.py

#Create example files
touch examples/init.py examples/{serp_analysis,content_workflow}.py

# Create test files
touch tests/init.py tests/test_core.py tests/test_plugins/test_serper_plugin.py

# Create configuration files
touch .env.example config.example.json requirements.txt pytest.ini
touch README.md .gitignore

# Create documentation files
touch docs/{project-structure,installation,configuration,plugins,workflows,debugging}.md
```

2. Set up Python environment:
## Installation

1. Create and activate a virtual environment:
```bash
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Install Playwright browsers
playwright install
```

## Configuration

### Environment Setup

1. Copy configuration templates:

2. Install Pynions:
```bash
cp .env.example pynions/config/.env
cp settings.example.json pynions/config/settings.json
pip install .
```

2. Configure API keys in `.env`:
The installer will automatically:
- Create `.env` from `.env.example` in your project root
- Create `pynions.json` from `pynions.example.json` in your project root

3. Configure your API keys:
```bash
# Required API Keys
SERPER_API_KEY=your_key_here
OPENAI_API_KEY=your_key_here

# Optional API Keys
ANTHROPIC_API_KEY=your_key_here
JINA_API_KEY=your_key_here
FRASE_API_KEY=your_key_here
```

### Configuration Loading
# Open .env in your favorite editor
nano .env

The system loads configuration in this order:

1. System environment variables
2. `.env` file variables
3. `settings.json` settings
# Add your API keys:
OPENAI_API_KEY=your_key_here # Required
SERPER_API_KEY=your_key_here # Optional, for search
ANTHROPIC_API_KEY=your_key_here # Optional, for Claude
JINA_API_KEY=your_key_here # Optional, for embeddings
```

Environment variables are automatically loaded by the base Plugin class.
## Troubleshooting

### Security Best Practices
Common issues:

- Never commit `.env` file
- Keep API keys secure
- Regularly rotate keys
- Use minimum required permissions
- Verify `.env` is in `.gitignore`
- Remove quotes from API keys in `.env`
- Don't include actual API keys in settings.json
- Missing API keys
- Check if `.env` exists in your project root
- Ensure you've added your OpenAI API key
- Configuration issues
- Verify `pynions.json` exists in your project root
- Check file permissions

## Verify Installation

Expand Down
14 changes: 13 additions & 1 deletion docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ from pynions.plugins.litellm_plugin import LiteLLM

llm = LiteLLM({
"api_key": "your_key_here",
"model": "gpt-4"
"model": "gpt-4o-mini"
})

response = await llm.execute({
Expand Down Expand Up @@ -258,3 +258,15 @@ class WeatherPlugin(Plugin):
"""Validate required configuration"""
return bool(self.api_key)
```

```json
{
"plugins": {
"litellm": {
"enabled": true,
"api_key": "your-api-key",
"model": "gpt-4o-mini",
"temperature": 0.7
}
}
}
2 changes: 1 addition & 1 deletion docs/plugins/litellm_plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ OPENAI_API_KEY=your_key_here
from pynions.plugins.litellm_plugin import LiteLLM
Initialize LLM with any supported model
llm = LiteLLM({
"model": "gpt-4", # or any other supported model
"model": "gpt-4o-mini", # or any other supported model
"temperature": 0.7,
"max_tokens": 2000
})
Expand Down
Loading

0 comments on commit d357fbe

Please sign in to comment.