Now fully write all the config files
- User
Now fully write all the config files
- Assistant
Now fully write all the config files
Below is a complete implementation of the config files from the config/ directory in the file structure. I've fully fleshed them out based on the project's requirements, including reasonable defaults and placeholders where sensitive or customizable values are needed. These are designed to be practical, scalable, and aligned with the system's goals (e.g., RL training, text generation, browser automation, rewards, and dashboard management).
I'll provide:
pyyaml..env file for sensitive information (e.g., Instagram credentials, encryption keys). This should never be committed to version control (add it to .gitignore). Use a library like python-dotenv to load it.I've included comments in the files for clarity, explanations of each section, and how they tie into the system. If you need adjustments (e.g., specific RL algorithm params), let me know!
This file is loaded by scripts like train.py and run_agent.py to configure the RL agent, language model, rewards, browser automation, and dashboard. It uses YAML for hierarchical structure.
# Main configuration file for the Instagram RL AI system.
# All paths are relative to the project root unless specified otherwise.
# Edit this file to tune hyperparameters, rewards, etc.
# RL Agent Settings
rl_settings:
algorithm: "PPO" # Options: "DQN", "PPO", "A2C", etc. (implement in ai_agent/policy.py)
learning_rate: 0.0003 # Learning rate for the policy optimizer
gamma: 0.99 # Discount factor for future rewards
epsilon_start: 1.0 # Initial exploration rate (for epsilon-greedy if using DQN)
epsilon_decay: 0.995 # Decay rate per episode
epsilon_min: 0.01 # Minimum exploration rate
batch_size: 64 # For experience replay
memory_size: 10000 # Size of replay buffer (in ai_agent/memory.py)
update_frequency: 4 # How often to update the target network (steps)
max_episodes_per_day: 10 # Limit to prevent Instagram rate-limiting
save_interval: 100 # Save model every N episodes
# Reward Configuration
# Weights for different metrics. Positive for rewards, negative for punishments.
# Extracted via browser_control/metrics_extractor.py.
# Easy to add more: just add a key and weight.
reward_metrics:
link_clicks: 10.0 # Reward per click on bio link
purchases: 100.0 # High reward for actual sales (tracked via link analytics if integrated)
follower_gains: 5.0 # Per new follower
view_gains: 1.0 # Per additional view on posts/stories
engagement_rate: 2.0 # Likes + comments per post
negative_spam_detection: -50.0 # Punishment if Instagram flags as spam
negative_offensive_content: -100.0 # If filters.py detects issues post-facto
# Add custom metrics here, e.g.:
# story_completions: 3.0
# Language Model Settings
# Config for the local text generation model (in language_model/).
language_model:
model_path: "./language_model/cache/my-llama-7b" # Path to your downloaded model weights (e.g., Hugging Face or GGUF format)
tokenizer_path: "./language_model/cache/my-llama-7b" # Path to tokenizer (if separate)
max_length: 128 # Max tokens for generated text (e.g., captions)
temperature: 0.8 # Controls randomness (higher = more creative)
top_p: 0.95 # Nucleus sampling parameter
top_k: 50 # Top-k sampling
repetition_penalty: 1.2 # Penalize repetitive text
stop_tokens: ["\n\n", "###"] # Tokens to stop generation
device: "cuda" # "cuda" for GPU, "cpu" for CPU, "mps" for Apple Silicon
prompt_templates:
caption: "Write an engaging Instagram caption for {product_name}. Include emojis and hashtags. Keep it under 150 characters."
comment: "Reply positively to this comment: '{user_comment}' about {product_name}. Promote the bio link subtly."
# Add more templates as needed in language_model/prompt_templates.py
# Browser Control Settings
browser_settings:
browser_type: "chrome" # "chrome", "firefox", or "edge" (using Selenium/Playwright)
headless: true # Run browser without UI (set to false for debugging)
window_size: "1920x1080" # Resolution for the browser window
user_agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" # Spoof user agent to avoid detection
max_accounts: 5 # Max simultaneous Instagram accounts to manage
action_delay_min: 5 # Min seconds between actions (to mimic human behavior)
action_delay_max: 15 # Max seconds between actions
metrics_refresh_interval: 3600 # Seconds between scraping Instagram dashboard metrics (e.g., 1 hour)
proxy: null # Optional: "http://proxy:port" for IP rotation
# Dashboard Settings
dashboard:
host: "localhost" # Or "0.0.0.0" for external access
port: 8000 # Port for the local dashboard server
log_level: "info" # "debug", "info", "warning", "error"
auto_refresh_interval: 60 # Seconds for frontend to poll metrics
database_path: "./data/dashboard.db" # SQLite path for storing metrics (if using ORM in dashboard/backend/models.py)
# Data Paths
data_paths:
products: "./data/products.json"
accounts: "./data/accounts.json"
logs: "./data/logs/"
experiences: "./data/experiences/"
# Miscellaneous
misc:
budget: 0 # Starting budget (as per your description; can be used for ad spend later)
log_retention_days: 30 # Auto-delete old logs
safety_filter_threshold: 0.7 # Toxicity score above which text is rejected (in ai_agent/filters.py)
This is a .env file (loaded via dotenv in Python scripts). It contains sensitive info like passwords and keys. Do not share or commit this file. Use placeholders below and replace with real values.
# Secrets file for sensitive information.
# Load with python-dotenv in scripts (e.g., run_agent.py).
# Format: KEY=VALUE (no quotes unless needed).
# Instagram Account Credentials
# Format: One line per account, e.g., IG_USERNAME_1=yourusername
# Accounts are indexed starting from 1. Add more as needed.
IG_USERNAME_1=your_instagram_username
IG_PASSWORD_1=your_instagram_password
IG_USERNAME_2=another_username
IG_PASSWORD_2=another_password
# ... add up to max_accounts from config.yaml
# Encryption Keys (for securing data/accounts.json if encrypted)
ENCRYPTION_KEY=your_secret_encryption_key_here # e.g., a 32-byte hex string for Fernet
# Optional: If integrating external analytics for purchases/clicks (e.g., Google Analytics or affiliate API)
ANALYTICS_API_KEY=your_google_analytics_key
AFFILIATE_TRACKING_ID=your_affiliate_id
# Optional: Proxy Authentication (if using proxies in browser_settings)
PROXY_USERNAME=proxy_user
PROXY_PASSWORD=proxy_pass
# Database Credentials (if dashboard uses a real DB instead of SQLite)
DB_HOST=localhost
DB_USER=admin
DB_PASSWORD=securepassword
DB_NAME=instagram_ai_db
ai_agent/agent.py will load these and use them in browser_control/controller.py for login.data/accounts.json or other files (recommended for security), this key is used.scripts/run_agent.py), load them like this:
import yaml
from dotenv import load_dotenv
import os
load_dotenv('config/secrets.env')
with open('config/config.yaml', 'r') as f:
config = yaml.safe_load(f)
secrets.env is in .gitignore. For production, consider a secrets manager like HashiCorp Vault.torch>=2.0.0 # For RL and local LLM
transformers>=4.30.0 # For loading local models
selenium>=4.0.0 # Or playwright
fastapi>=0.100.0 # For dashboard backend
uvicorn>=0.20.0
python-dotenv>=1.0.0
pyyaml>=6.0.0
# Add RL libs: stable-baselines3 or custom
stable-baselines3>=2.0.0
# For filters: detoxify or profanity-check
detoxify>=0.5.0
If you'd like me to write code for a specific module (e.g., language_model/loader.py) or adjust these configs, just say the word!