Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/codegen/cli/commands/create/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from codegen.cli.api.client import RestAPI
from codegen.cli.auth.constants import PROMPTS_DIR
from codegen.cli.auth.decorators import requires_auth
from codegen.cli.auth.session import CodegenSession
from codegen.cli.auth.token_manager import get_current_token
from codegen.cli.codemod.convert import convert_to_cli
Expand All @@ -14,6 +13,7 @@
from codegen.cli.rich.pretty_print import pretty_print_error
from codegen.cli.rich.spinners import create_spinner
from codegen.cli.utils.default_code import DEFAULT_CODEMOD
from codegen.cli.workspace.decorators import requires_init


def get_prompts_dir() -> Path:
Expand Down Expand Up @@ -66,7 +66,7 @@


@click.command(name="create")
@requires_auth
@requires_init
@click.argument("name", type=str)
@click.argument("path", type=click.Path(path_type=Path), default=Path.cwd())
@click.option("--description", "-d", default=None, help="Description of what this codemod does.")
Expand All @@ -86,15 +86,14 @@
pretty_print_error(f"File already exists at {format_path(rel_path)}\n\nTo overwrite the file:\n{format_command(f'codegen create {name} {rel_path} --overwrite')}")
return

rich.print("") # Add a newline before output
response = None
code = None
try:
if description:
# Use API to generate implementation
with create_spinner("Generating function (using LLM, this will take ~10s)") as status:
response = RestAPI(get_current_token()).create(name=name, query=description)

Check failure on line 95 in src/codegen/cli/commands/create/main.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument 1 to "RestAPI" has incompatible type "str | None"; expected "str" [arg-type]
code = convert_to_cli(response.code, session.config.repository.language, name)

Check failure on line 96 in src/codegen/cli/commands/create/main.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument 2 to "convert_to_cli" has incompatible type "str | None"; expected "str" [arg-type]
prompt_path.parent.mkdir(parents=True, exist_ok=True)
prompt_path.write_text(response.context)
else:
Expand Down
Loading