CodeFusion is a handy Python tool that allows you to compare the output of different AI models for your coding questions. The app supports models from major players like Google, Anthropic, OpenAI, and Meta, and neatly displays their answers in a vertical split view.
-
Clone the repo and navigate to the project folder:
git clone https://github.com/s-smits/code-fusion cd code-fusion
-
Create a virtual environment and activate it:
- Mac and Linux:
python3 -m venv venv_codefusion source venv_codefusion/bin/activate
- Windows:
python -m venv venv_codefusion venv_codefusion\Scripts\activate
- Mac and Linux:
-
Install the required packages:
pip install -r requirements.txt
-
Create a
.env
file in the root of your project and add your API keys:GOOGLE_API_KEY=your_google_api_key ANTHROPIC_API_KEY=your_anthropic_api_key OPENAI_API_KEY=your_openai_api_key OPENROUTER_API_KEY=your_openrouter_api_key
You only need to add the keys for the models you want to use.
Run the script:
python codefusion.py
The app does the following:
- Asks you to choose at least two AI models
- Checks if you've filled in your API keys (or asks for them if they're missing)
- Lets you ask programming questions
- Shows the answers from the chosen models in real-time
- Provides a summary of the differences between the answers
- Briefly advises which model seems best for your question
Type 'quit' to exit the app.
- Parallel querying of multiple AI models
- Live display of answers
- Automatic retry for API errors
- Summary and advice via GPT-4o-mini
- Fancy console interface with colored output
With the --best
option, you can select the most advanced and expensive models for your AI comparisons. When this option is enabled, the following models are used:
- Google:
gemini/gemini-1.5-pro-latest
- Anthropic:
anthropic/claude-3-5-sonnet-20240620
- OpenAI:
openai/gpt-4o
- Meta:
openrouter/meta-llama/llama-3.1-405b-instruct
Without the --best
option, more cost-effective models are used:
- Google:
gemini/gemini-1.5-flash
- Anthropic:
anthropic/claude-3-haiku-20240307
- OpenAI:
openai/gpt-4o-mini
- Meta:
openrouter/meta-llama/llama-3.1-8b-instruct
-
Developer Productivity Enhancement:
CodeFusion can significantly boost developer productivity by allowing them to quickly compare outputs from multiple AI models for coding questions. This saves time in researching and cross-referencing different AI assistants, enabling developers to find the most accurate or useful code snippets faster. -
AI Model Evaluation for Enterprise:
For companies considering integrating AI coding assistants into their development workflow, CodeFusion provides an easy way to evaluate and compare different models. This can help decision-makers choose the most suitable AI service for their specific needs and use cases, potentially saving significant costs in the long run. -
Educational Tool for AI and Programming:
CodeFusion can serve as an excellent educational resource for students and professionals learning about AI in programming. By comparing outputs from different models side-by-side, users can gain insights into how various AI models approach coding problems, understand their strengths and weaknesses, and learn best practices from multiple sources simultaneously.
Check requirements.txt
for the complete list. The main libraries are:
- litellm
- rich
- python-dotenv
output.mp4