title
stringlengths 6
24
| size
int64 42
4.1k
| path
stringlengths 22
75
| document
stringlengths 42
4.1k
|
---|---|---|---|
container.py | 1,762 | flamethrower/src/flamethrower/containers/container.py | import sys
from dependency_injector import containers, providers
from flamethrower.shell.command_handler import CommandHandler
from flamethrower.context.conv_manager import ConversationManager
from flamethrower.context.prompt import PromptGenerator
from flamethrower.agents.operator import Operator
from flamethrower.utils.token_counter import TokenCounter
from flamethrower.shell.shell_manager import ShellManager
from flamethrower.shell.printer import Printer
from flamethrower.containers.lm_container import lm_container
class Container(containers.DeclarativeContainer):
token_counter = providers.Dependency(instance_of=TokenCounter)
conv_manager = providers.Singleton(ConversationManager)
tty_settings = providers.Dependency(instance_of=list)
shell_manager = providers.Singleton(
ShellManager,
old_settings=tty_settings
)
leader_fd = providers.Dependency(instance_of=int)
printer = providers.Singleton(
Printer,
leader_fd=leader_fd,
stdout_fd=sys.stdout.fileno(),
conv_manager=conv_manager,
shell_manager=shell_manager,
token_counter=token_counter
)
prompt_generator = providers.Singleton(
PromptGenerator,
conv_manager=conv_manager,
token_counter=token_counter,
printer=printer
)
base_dir = providers.Dependency(instance_of=str)
operator = providers.Singleton(
Operator,
base_dir=base_dir,
conv_manager=conv_manager,
prompt_generator=prompt_generator,
printer=printer
)
command_handler = providers.Singleton(
CommandHandler,
conv_manager=conv_manager,
operator=operator,
printer=printer,
)
container = Container() |
test_container.py | 3,020 | flamethrower/src/flamethrower/containers/tests/test_container.py | from unittest.mock import patch, mock_open
from flamethrower.containers.container import Container
from flamethrower.shell.command_handler import CommandHandler
from flamethrower.context.conv_manager import ConversationManager
from flamethrower.context.prompt import PromptGenerator
from flamethrower.agents.operator import Operator
from flamethrower.utils.token_counter import TokenCounter
from flamethrower.shell.shell_manager import ShellManager
from flamethrower.shell.printer import Printer
from flamethrower.test_utils.mocks.mock_token_counter import mock_token_counter as mock_tc
"""
Don't use pytest.fixtures as mock_open only works for 1 level of abstraction?
Need to look more into this.
"""
def mock_container() -> Container:
with patch('flamethrower.containers.container.lm_container') as mock_lm_container:
mock_token_counter = mock_tc()
mock_lm_container.token_counter.return_value = mock_token_counter
container = Container()
container.token_counter.override(mock_token_counter)
container.tty_settings.override([])
container.leader_fd.override(1)
container.base_dir.override('/user/tester')
return container
def test_container_init() -> None:
with patch('builtins.open', mock_open()):
container = mock_container()
assert isinstance(container.conv_manager(), ConversationManager)
assert isinstance(container.token_counter(), TokenCounter)
assert isinstance(container.shell_manager(), ShellManager)
assert isinstance(container.printer(), Printer)
assert isinstance(container.prompt_generator(), PromptGenerator)
assert isinstance(container.operator(), Operator)
assert isinstance(container.command_handler(), CommandHandler)
def test_container_wiring() -> None:
with patch('builtins.open', mock_open()):
container = mock_container()
shell_manager = container.shell_manager()
assert shell_manager.old_settings == container.tty_settings()
printer = container.printer()
assert printer.conv_manager is container.conv_manager()
assert printer.shell_manager is container.shell_manager()
assert isinstance(printer.token_counter, TokenCounter) # best effort
prompt_generator = container.prompt_generator()
assert prompt_generator.conv_manager is container.conv_manager()
assert prompt_generator.printer is container.printer()
operator = container.operator()
assert operator.base_dir == container.base_dir()
assert operator.conv_manager is container.conv_manager()
assert operator.prompt_generator is container.prompt_generator()
assert operator.printer is container.printer()
command_handler = container.command_handler()
assert command_handler.conv_manager is container.conv_manager()
assert command_handler.operator is container.operator()
assert command_handler.printer is container.printer()
|
test_lm_container.py | 323 | flamethrower/src/flamethrower/containers/tests/test_lm_container.py | from flamethrower.containers.lm_container import LMContainer
from flamethrower.utils.token_counter import TokenCounter
def mock_lm_container() -> LMContainer:
return LMContainer()
def test_lm_container_init() -> None:
container = mock_lm_container()
assert isinstance(container.token_counter(), TokenCounter)
|
README.md | 4,096 | flamethrower/src/flamethrower/data/README.md | <h1 align='center'>π₯ flamethrower</h1>
No bugs can survive the test of <span style='color: orange'>fire</span>; not even the ones you wrote into your codebase πͺ².
[![GitHub Repo](https://img.shields.io/badge/scottsus-flamethrower-red?&logo=github)](https://github.com/scottsus/flamethrower)
![PyPI](https://img.shields.io/pypi/v/flamethrower.svg)
![Code Size](https://img.shields.io/github/languages/code-size/scottsus/flamethrower.svg)
[![Discord](https://img.shields.io/discord/XP4vVUQKPf.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/XP4vVUQKPf)
![License](https://img.shields.io/github/license/scottsus/flamethrower.svg)
[![Twitter](https://img.shields.io/twitter/follow/susantoscott.svg)](https://twitter.com/susantoscott)
## What is this?
π₯ flamethrower is an open source, multi-agent, context-intelligent, debugger that utilizes AI superpowers to automate the painful task of debugging. Think a combination of GitHub Copilot's context-awareness in [KillianLucas' Open Interpreter](https://github.com/KillianLucas/open-interpreter) packed into a beautiful shell that works out of the box with any existing repo.
Automate: [ Write Code β Run Action β Check Logs β Repeat ] ππ
**Main Differentiators**
- π₯ Automate the most painful part of writing code: print statements & error logs
- βοΈ Specialized context agent for operating within existing repo
- π€ Debugging agent optimized to iteratively brute-force locate and fix bugs
- π¦ Out of the box support for any unix machine (no VS Code or VS Code alternatives)
- π¨ Seamless integration into any existing repo; just type `flamethrower`
## Demo
https://github.com/scottsus/flamethrower/assets/88414565/e3c979c0-40ff-4976-aa30-2503a2827742
## Quick Start
<img src='https://github.com/scottsus/flamethrower/assets/88414565/4be238a7-642a-4149-a1ed-98ff7c61f9b8' alt='Quick Start' width='500px'/>
### Install π₯ flamethrower
```
pip install flamethrower
```
Or, if you have an existing version and are looking to upgrade to the latest version
```
pip install --upgrade flamethrower
```
### Terminal
Navigate to your current workspace, and simply run `flamethrower`, or `ft` for the pros.
```
cd ./unbelievably/complicated/workspace
flamethrower
```
### Example Usage
Use lowercase letters for commands you run in the shell, like `python main.py` or `node server.ts`
```
π₯ flamethrower: Debugging on Autopilot
Instructions:
- β¨οΈ Regular shell Use commands like ls, cd, python hello.py
- π€ LLM assistance Start command with a Capital letter, try Who are you?
- π Context Intelligent context-awareness from command, files, and stdout logs
- πͺ΅ Terminal logs All conversation & code output inside flamethrower is logged
...
$ python main.py -> SOME_ERROR
$ Wtf???? # Literally type this in the terminal
```
An implementation run is initiated with a natural language query that begins with an `uppercase letter`.
## Features
### π€ AFK Debugging
If you say 'Yes', π₯ flamethrower will debug in the background while you focus on other tasks at hand. It acts similarly to any other human engineer: adding `print` statements to find the root cause of the issue (which, as we know is the most annoying part). We find this pattern strikingly effective, and is where we believe LAMs have the strongest use case.
If it looks like π₯ flamethrower is obviously headed in the direction of doom, simply press `CTRL+C` and give it more suggestions or context.
<img src='https://github.com/scottsus/flamethrower/assets/88414565/11886370-1da4-478e-8fac-853fd305621a' alt='AFK' width='500px'/>
### ποΈ Conversation History
As long as any shell command or natural language query happens within the context of π₯ flamethrower, then it is by default captured in the conversation history. That means you can:
- ask about an error that just happened, or happened 2 dialogues ago
- follow up on a previous response provided by π₯ flamethrower
### π Prompt Transparency
Prompts sent to LLM are transparent and easy to observe. All π₯ flamethrower metadata are neat |
README.md | 2,530 | flamethrower/src/flamethrower/data/README.md | d305621a' alt='AFK' width='500px'/>
### ποΈ Conversation History
As long as any shell command or natural language query happens within the context of π₯ flamethrower, then it is by default captured in the conversation history. That means you can:
- ask about an error that just happened, or happened 2 dialogues ago
- follow up on a previous response provided by π₯ flamethrower
### π Prompt Transparency
Prompts sent to LLM are transparent and easy to observe. All π₯ flamethrower metadata are neatly kept in a `.flamethrower` subdirectory, including prompts, conversations, logs, directory info, summaries, and other metadata.
<img src='https://github.com/scottsus/flamethrower/assets/88414565/8905018d-41f5-48e8-92f5-da2b0512af3d' alt='Transparency' width='500px'/>
### πββοΈ Real Time File Tracking
Everytime you send a query, the latest version of your files are sent over, meaning π₯ flamethrower understands that you changed your files, and are ready to process those changes.
<img src='https://github.com/scottsus/flamethrower/assets/88414565/f3f49b91-1cc8-452c-8625-54d88dcb2a42' alt='Context' width='500px'/>
## Motivation for π₯ flamethrower
### π©ββοΈ GitHub Copilot
Closed source GitHub Copilot draws context very effectively, and `Quick Fix` is a neat feature that explains error from stdout logs if the last command returned a non-zero return code.
### π€ Open Interpreter
The Open Interpreter, an open-source gem, specializes in crafting new code from the ground up. It's a favorite among data scientists and those needing sophisticated chart plotting, thanks to its iterative approach to achieving desired results.
### π¬ Research
π₯ flamethrower combines the agency afforded by Large Action Models (LAM) with the workspace awareness of Copilot, allowing it to take context-specific suggestions and continue iteration until a successful outcome. π₯ flamethrower is workspace-first, and aims to serve software engineers in complex tasks that need a lot of context management.
## π₯ Contributing
π₯ flamethrower is everyone's debugger. Fork it for your own use case, and, one PR at a time we can make the world a more bug-free place β¨ just ping me at scottsus@usc.edu and I'll help you get started.
## π« Project Roadmap
- [x] π§ͺ Better testing
- [ ] π Telemetry and the ability to opt in/out
- [ ] π₯½ LLM Vision to debug visual elements
- [ ] π¦ Running CodeLlama locally
- [ ] π€ Other models besides OpenAI
- [ ] π¦Ύ Default model finetuned on telemetry data
- [ ] ποΈ VS Code integration
- [ ] π» Browser interface
|