Skip to content

NullLabTests/SelfImprovingAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

SelfImprovingAgent

SelfImprovingAgent is an AI-driven system that autonomously generates, tests, and refines Python code. The system uses language models to generate code based on a prompt, runs the code to check for correctness, and refines the code based on the feedback received from execution. Over multiple iterations, the agent "self-improves" its code, learning from its successes and failures.

Features

  • Code Generation: The agent can generate Python code based on user-provided prompts.
  • Error Handling & Feedback: The agent evaluates the generated code by executing it and refines the code based on the feedback (success or errors).
  • Iteration: The agent runs in multiple iterations, improving the generated code each time.

How It Works

  1. Prompting: The agent starts with a base prompt (e.g., write a Python function to sort a list).
  2. Code Generation: The agent sends this prompt to a language model (e.g., GPT-based models).
  3. Evaluation: The generated code is written to a file and executed.
  4. Refinement: If the code executes successfully, it continues, otherwise, the agent refines the code based on error feedback.
  5. Iteration: This process repeats multiple times for incremental improvements.

Supported Models

The agent can be used with multiple LLMs (Language Models), such as:

  • GPT-3
  • Grok (if available)
  • Custom Models (For any model that supports chat completions).

To change the model, simply set the model parameter when creating the SelfImprovingAgent object.

How to Run

  1. Clone the repository:
    git clone https://github.com/NullLabTests/SelfImprovingAgent.git
    cd SelfImprovingAgent

Install dependencies:

bash Copy Edit pip install openai Set your OpenAI API key:

bash Copy Edit export OPENAI_API_KEY="your-api-key" Run the agent:

bash Copy Edit python SelfImprover.py How to Evolve Further This agent could evolve in several ways:

Different Programming Tasks: Extend the agent's capabilities to generate solutions for other programming problems (e.g., web scraping, machine learning models). Meta-Learning: Implement meta-learning to allow the agent to adapt to new kinds of tasks without needing manual intervention. Model Switching: Allow the agent to automatically switch between different models depending on the task complexity or success rate. Relevant Papers Neural Architecture Search: A Survey Generative Models for Programming: A Study Contributing Feel free to fork and submit pull requests. Contributions are welcome!