Skip to content

Commit cb09b14

Browse files
authored
Bug fix: Create command response access (#191)
# Motivation <!-- Why is this change necessary? --> Bug in the implementation for the `create` command where a variable was accessed outside the scope it was defined # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed - [ ] I have read and agree to the [Contributor License Agreement](../CLA.md)
1 parent 81d0147 commit cb09b14

File tree

1 file changed

+9
-8
lines changed
  • src/codegen/cli/commands/create

1 file changed

+9
-8
lines changed

src/codegen/cli/commands/create/main.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,24 @@ def create_command(session: CodegenSession, name: str, path: Path, description:
8686
return
8787

8888
rich.print("") # Add a newline before output
89-
89+
response = None
9090
try:
9191
if description:
9292
# Use API to generate implementation
9393
with create_spinner("Generating function (using LLM, this will take ~10s)") as status:
9494
response = RestAPI(session.token).create(name=name, query=description)
9595
code = convert_to_cli(response.code, session.language, name)
96+
prompt_path.write_text(response.context)
9697
else:
9798
# Use default implementation
9899
code = DEFAULT_CODEMOD.format(name=name)
99100

100-
# Create the target directory if needed
101-
codemod_path.parent.mkdir(parents=True, exist_ok=True)
101+
# Create the target directory if needed
102+
codemod_path.parent.mkdir(parents=True, exist_ok=True)
102103

103-
# Write the function code
104-
codemod_path.write_text(code)
105-
prompt_path.write_text(response.context)
104+
# Write the function code
105+
codemod_path.write_text(code)
106+
106107

107108
except (ServerError, ValueError) as e:
108109
raise click.ClickException(str(e))
@@ -112,8 +113,8 @@ def create_command(session: CodegenSession, name: str, path: Path, description:
112113
rich.print("")
113114
rich.print("📁 Files Created:")
114115
rich.print(f" [dim]Function:[/dim] {make_relative(codemod_path)}")
115-
if description and response.context:
116-
rich.print(f" [dim]Prompt:[/dim] {make_relative(prompt_path)}")
116+
if description and response and response.context:
117+
rich.print(f" [dim]Prompt:[/dim] {description}")
117118

118119
# Next steps
119120
rich.print("\n[bold]What's next?[/bold]\n")

0 commit comments

Comments
 (0)