-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from e2b-dev/api-mode
Add API via e2b SDK
- Loading branch information
Showing
4 changed files
with
274 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from smol_dev.prompts import plan, specify_file_paths, generate_code | ||
|
||
from agent_protocol import ( | ||
Agent, | ||
StepResult, | ||
StepHandler, | ||
) | ||
|
||
|
||
async def smol_developer(prompt: str): | ||
shared_deps = plan(prompt) | ||
yield shared_deps | ||
|
||
file_paths = specify_file_paths(prompt, shared_deps) | ||
yield file_paths | ||
|
||
for file_path in file_paths: | ||
code = await generate_code(prompt, shared_deps, file_path) | ||
yield code | ||
|
||
|
||
async def task_handler(task_input) -> StepHandler: | ||
if not task_input: | ||
raise Exception("No task prompt") | ||
|
||
smol_developer_loop = smol_developer(prompt=task_input) | ||
|
||
async def step_handler(step_input): | ||
result = await anext(smol_developer_loop, None) | ||
if result is None: | ||
return StepResult(is_last=True) | ||
return StepResult(output=result) | ||
|
||
return step_handler | ||
|
||
|
||
Agent.handle_task(task_handler).start() |