Skip to content

Commit

Permalink
Merge branch 'main' into rpatel/pydantic-arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
rushilpatel0 authored Jan 17, 2025
2 parents b83b1cd + 3a1d060 commit 66707ef
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default_language_version:
fail_fast: true
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.1
rev: v0.9.2
hooks:
# Run the linter.
- id: ruff
Expand Down Expand Up @@ -55,7 +55,7 @@ repos:
- tomli

- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 39.111.0
rev: 39.113.0
hooks:
- id: renovate-config-validator
- repo: https://github.com/astral-sh/uv-pre-commit
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/cli/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ def ask_expert(self, query: str) -> AskExpertResponse:
AskExpertResponse,
)

def create(self, query: str) -> CreateResponse:
def create(self, name: str, query: str) -> CreateResponse:
"""Get AI-generated starter code for a codemod."""
session = CodegenSession()
return self._make_request(
"GET",
CREATE_ENDPOINT,
CreateInput(input=CreateInput.BaseCreateInput(query=query, repo_full_name=session.repo_name)),
CreateInput(input=CreateInput.BaseCreateInput(name=name, query=query, repo_full_name=session.repo_name)),
CreateResponse,
)

Expand Down
1 change: 1 addition & 0 deletions src/codegen/cli/api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class DocsResponse(SafeBaseModel):

class CreateInput(SafeBaseModel):
class BaseCreateInput(SafeBaseModel):
name: str
query: str | None = None
repo_full_name: str | None = None

Expand Down
6 changes: 3 additions & 3 deletions src/codegen/cli/commands/create/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def create_command(session: CodegenSession, name: str, path: Path, description:
# Check if file exists
if target_path.exists() and not overwrite:
rel_path = make_relative(target_path)
pretty_print_error(f"File already exists at {format_path(rel_path)}\n\n" "To overwrite the file:\n" f"{format_command(f'codegen create {name} {rel_path} --overwrite')}")
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

if description:
Expand All @@ -91,7 +91,7 @@ def create_command(session: CodegenSession, name: str, path: Path, description:
with create_spinner(status_message) as status:
try:
# Get code from API
response = RestAPI(session.token).create(description if description else None)
response = RestAPI(session.token).create(name=name, query=description if description else None)

# Convert the code to include the decorator
code = convert_to_cli(response.code, session.config.programming_language or ProgrammingLanguage.PYTHON, name)
Expand Down Expand Up @@ -120,7 +120,7 @@ def create_command(session: CodegenSession, name: str, path: Path, description:
rich.print("📁 Files Created:")
rich.print(f" [dim]Function:[/dim] {make_relative(target_path)}")
if response.context:
rich.print(f" [dim]Prompt:[/dim] {make_relative(get_prompts_dir() / f'{name.lower().replace(' ', '-')}-system-prompt.md')}")
rich.print(f" [dim]Prompt:[/dim] {make_relative(get_prompts_dir() / f'{name.lower().replace(" ", "-")}-system-prompt.md')}")

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

0 comments on commit 66707ef

Please sign in to comment.