Skip to content

Commit

Permalink
simplified configuration system
Browse files Browse the repository at this point in the history
improved setup experience
  • Loading branch information
tomaslau committed Nov 22, 2024
1 parent 1863b04 commit a78d6db
Show file tree
Hide file tree
Showing 14 changed files with 538 additions and 747 deletions.
7 changes: 5 additions & 2 deletions pynions/config/.env.example → .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
SERPER_API_KEY=your_key_here
# Required API Keys
OPENAI_API_KEY=your_key_here

# Optional API Keys (only if you use these services)
SERPER_API_KEY=your_key_here
ANTHROPIC_API_KEY=your_key_here
JINA_API_KEY=your_key_here
FRASE_API_KEY=your_key_here
FRASE_API_KEY=your_key_here
30 changes: 29 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
---
title: "Changelog"
publishedAt: "2024-11-03"
updatedAt: "2024-11-20"
updatedAt: "2024-11-22"
summary: "Updates, bug fixes and improvements."
kind: "detailed"
---

## v0.2.26 - Nov 22, 2024

### Changed
- Simplified configuration management system
- Moved configuration files to project root
- Removed nested config folder structure
- Improved direct litellm integration
- Updated advanced example with async support
- Enhanced error handling and output formatting

### Added
- Root-level `.env` for API keys
- Root-level `pynions.json` for settings
- Clearer setup instructions in installation
- Example file copying during installation

### Removed
- Complex nested configuration system
- ~/.pynions directory requirement
- Outdated example configurations

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

### Dependencies
- Updated minimum Python version to 3.8+

## v0.2.25 - Nov 20, 2024

### Security
Expand Down
132 changes: 54 additions & 78 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,112 +2,88 @@
title: "Configuration"
publishedAt: "2024-10-30"
updatedAt: "2024-11-10"
summary: "Learn how to configure Pynions with API keys and settings."
summary: "Simple configuration guide for marketers using Pynions"
kind: "detailed"
---

## Configuration Structure
## Quick Setup

Pynions uses a two-part configuration system:
1. Copy `.env.example` to `.env` and add your API key:
```bash
cp .env.example .env
nano .env # Add your OpenAI API key
```

1. `pynions/config/settings.json` - Main application settings
2. `pynions/config/.env` - Environment variables and API keys
2. (Optional) Create `pynions.json` if you need custom settings:
```bash
cp pynions.example.json pynions.json
```

### Settings (settings.json)
That's it! You're ready to start using Pynions.

Main configuration file located at `pynions/config/settings.json`:
## Configuration Files

```json
{
"workflow": {
"status_types": {
"research": {
"description": "Initial research and data gathering",
"extensions": ["md", "txt"]
},
"brief": {
"description": "Content brief or outline",
"extensions": ["md"]
},
"draft": {
"description": "First version of content",
"extensions": ["md"]
}
}
},
"storage": {
"data_dir": "data",
"raw_dir": "data/raw",
"output_dir": "data/output"
},
"plugins": {
"serper": {
"max_results": 10
}
}
}
```
### 1. API Keys (.env)

### Environment Variables (.env)

Sensitive configuration like API keys are stored in `pynions/config/.env`:
Put your API keys in `.env` file in the root directory:

```bash
# Search API
SERPER_API_KEY=your_serper_key_here

# AI Models
OPENAI_API_KEY=your_openai_key_here
ANTHROPIC_API_KEY=your_anthropic_key_here
# Required
OPENAI_API_KEY=your_key_here

# Content Processing
JINA_API_KEY=your_jina_key_here
FRASE_API_KEY=your_actual_frase_key
# Optional (only if you use these features)
SERPER_API_KEY=your_key_here
ANTHROPIC_API_KEY=your_key_here
```

## Setup Steps
### 2. Optional Settings (pynions.json)

1. Create config directory:
If you need to customize settings, create `pynions.json` in the root directory:

```bash
mkdir -p pynions/config
```json
{
"save_results": true, // Save generated content to files
"output_folder": "data", // Where to save files
"plugins": {
"serper": {
"results": 10, // Number of search results
"country": "us" // Search region
}
}
}
```

2. Copy example settings:

```bash
cp settings.example.json pynions/config/settings.json
```
All settings are optional and have sensible defaults.

3. Create environment file:
## Using in Scripts

```bash
cp .env.example pynions/config/.env
```
Access configuration in your scripts:

4. Edit your settings and API keys:
```python
from pynions.core.config import config

```bash
# Edit settings
nano pynions/config/settings.json
# Check API key
if not config.check_api_key():
print("Add your OpenAI API key to .env file")
exit()

# Add your API keys
nano pynions/config/.env
# Get settings (with defaults)
output_dir = config.get("output_folder", "data")
save_to_file = config.get("save_results", True)
```

## Configuration Access
## AI Configuration

Access settings in your code:
Pynions uses [LiteLLM](https://docs.litellm.ai/docs/) for AI features. You don't need to configure AI settings - they're handled automatically.

Example usage:
```python
from pynions.config import load_config

# Load full config
config = load_config()
from litellm import completion

# Access settings
model_name = config["model"]["name"]
max_results = config["plugins"]["serper"]["max_results"]
response = completion(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello!"}]
)
```

*Note:* Environment variables are automatically loaded by the Plugin system. You don't need to manually load them in your code when using plugins.
See [LiteLLM documentation](https://docs.litellm.ai/docs/) for more options.
Loading

0 comments on commit a78d6db

Please sign in to comment.