Set your OpenAI API key as an environment variable:
Copy
export OPENAI_API_KEY=your_api_key_here
3
Create Script
Create a new file code_assistant.py:
Copy
from praisonaiagents import Agent, Toolsfrom praisonaiagents.tools import execute_code, analyze_code, format_code, lint_code, disassemble_code # Code Toolsfrom praisonaiagents.tools import execute_command, list_processes, kill_process, get_system_info # Shell Toolsfrom praisonaiagents.tools import duckduckgo # Web Search Toolagent = Agent( instructions="You are a Programming Agent", self_reflect=True, min_reflect=5, max_reflect=10, tools=[execute_code, analyze_code, format_code, lint_code, disassemble_code, execute_command, list_processes, kill_process, get_system_info, duckduckgo])agent.start( "Write a python script using yfinance to find the stock price of Tesla" "First check if required packages are installed" "Run it using execute_code" "execute_command if you want to run any terminal command" "search internet using duckduckgo if you want to know update python package information" "Analyse the output using analyze_code and fix error if required" "if no package is installed, install it" "then run the code")
# Example: Create and run a data analysis scriptresponse = agent.start(""" 1. Create a script that: - Uses pandas for data analysis - Reads a CSV file - Performs basic statistics - Creates a visualization 2. Check and install required packages 3. Execute and analyze the results""")