A general purpose interative Python coding assistant implemented with Council. Runnable as a standalone Python script or as a Flask/JavaScript app with a UI.
There is a custom controller, which is a development version of LLMInstructController
src/python_agent/controller.py
If you just want to see how this Agent works, check out the following video where we use the Python Agent to help build a particle simulator!
To run the demo as-is, you'll need an OpenAI API Key. Though it's possible to use GPT 3.5 Turbo, we highly recommend using GPT-4 for this demo.
We define an Agent with the following structure:
graph TB
User[User] -->|Messages| LLMInstructController
subgraph Agent[Agent]
LLMInstructController[LLMInstructController]
BasicEvaluator[BasicEvaluator]
subgraph Chains
Chain1[code_generation_chain]
Chain2[code_execution_chain]
Chain3[error_correction_chain]
Chain4[general_chain]
Chain5[direct_to_user_chain]
end
LLMInstructController -->|"chain;score;instructions"| Chains
Chains --> BasicEvaluator
BasicEvaluator --> LLMInstructController
end
Before running the demo, you'll need to:
- Install Council -
pip install council-ai==0.0.9
- Create a Python virtual environment for code execution (see below)
- Populate your
.env
file with your virtual environment path and your OpenAI API key
You need to create a Python virtual environment.
- In your Terminal, cd to
src/python_agent
- Run
python -m venv code_sandbox
- Run
source code_sandbox/bin/activate
- Install any packages you plan to use in your interactive coding, e.g.
pip install pygame
- Take note of the full path to your virtual environment's
bin
directory (e.g.your-home-directory/council-python-agent/src/python_agent/code_sandbox/bin
)
To run the demo,
- Navigate to the
src
directory in your Terminal - Run
python app.py
- Open the
src
directory in your file browser (e.g. Finder) then openindex.html
in your browser. - If you see
"No code to display."
in the code window and"Ready."
in the log window below, your app is working and ready.
- Keep the Terminal window running
app.py
open and visible. If there are unhandled errors, it will let you know. - If you get unhandled errors (e.g.
500
errors) you may need to restart bothapp.py
and your browser. We're working on improving this in future revisions.