From 43d5c52478734838f2ed783610870e51e87a74c7 Mon Sep 17 00:00:00 2001 From: codegen-bot Date: Fri, 14 Mar 2025 17:41:07 +0000 Subject: [PATCH 1/2] Add feature to suggest starting prompts for codegen --- src/codegen/cli/commands/agent/main.py | 51 +++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/src/codegen/cli/commands/agent/main.py b/src/codegen/cli/commands/agent/main.py index 9862c1e5a..78282e189 100644 --- a/src/codegen/cli/commands/agent/main.py +++ b/src/codegen/cli/commands/agent/main.py @@ -6,6 +6,8 @@ from rich.console import Console from rich.markdown import Markdown from rich.prompt import Prompt +from rich.panel import Panel +from rich.text import Text from codegen.extensions.langchain.agent import create_agent_with_tools from codegen.extensions.langchain.tools import ( @@ -39,14 +41,32 @@ [/bold blue] """ +# List of suggested starting prompts +SUGGESTED_PROMPTS = [ + "What repositories can you see?", + "Show me the structure of this codebase", + "Find all files containing the function 'create_agent'", + "What capabilities do you have?", + "Help me understand the architecture of this project", + "Show me the main entry points of this application", +] + @click.command(name="agent") @click.option("--query", "-q", default=None, help="Initial query for the agent.") -def agent_command(query: str): +@click.option("--help-prompts", is_flag=True, help="Show suggested prompts and exit.") +def agent_command(query: str, help_prompts: bool): """Start an interactive chat session with the Codegen AI agent.""" # Show welcome message console.print(WELCOME_ART) + # If help-prompts flag is set, show suggested prompts and exit + if help_prompts: + console.print("[bold]Suggested Starting Prompts:[/bold]") + for i, prompt in enumerate(SUGGESTED_PROMPTS, 1): + console.print(f" {i}. [cyan]{prompt}[/cyan]") + return + # Initialize codebase from current directory with console.status("[bold green]Initializing codebase...[/bold green]"): codebase = Codebase("./") @@ -85,9 +105,29 @@ def say(message: str): console.print("I'm an AI assistant that can help you explore and modify code in this repository.") console.print("I can help with tasks like viewing files, searching code, making edits, and more.") console.print() + + # Display suggested prompts in a panel + prompt_text = Text() + prompt_text.append("Try asking me:\n", style="bold") + for i, prompt in enumerate(SUGGESTED_PROMPTS[:3], 1): # Show only first 3 suggestions + prompt_text.append(f"{i}. ", style="bold cyan") + prompt_text.append(f"{prompt}\n", style="cyan") + prompt_text.append("\nOr type 'help' to see more suggested prompts", style="dim") + + console.print(Panel(prompt_text, title="Suggested Prompts", border_style="blue")) + console.print() + console.print("What would you like help with today?") console.print() query = Prompt.ask("[bold]>[/bold]") # Simple arrow prompt + + # Handle 'help' command to show more suggested prompts + if query.lower() in ["help", "--help", "man", "?", "examples"]: + console.print("[bold]Suggested Starting Prompts:[/bold]") + for i, prompt in enumerate(SUGGESTED_PROMPTS, 1): + console.print(f" {i}. [cyan]{prompt}[/cyan]") + console.print() + query = Prompt.ask("[bold]>[/bold]") # Ask again after showing help # Create the agent agent = create_agent_with_tools(codebase=codebase, tools=tools, system_message=system_message) @@ -102,6 +142,13 @@ def say(message: str): if user_input.lower() in ["exit", "quit"]: break + + # Handle 'help' command to show suggested prompts + if user_input.lower() in ["help", "--help", "man", "?", "examples"]: + console.print("[bold]Suggested Starting Prompts:[/bold]") + for i, prompt in enumerate(SUGGESTED_PROMPTS, 1): + console.print(f" {i}. [cyan]{prompt}[/cyan]") + continue # Invoke the agent with console.status("[bold green]Agent is thinking...") as status: @@ -118,4 +165,4 @@ def say(message: str): say(result) except Exception as e: console.print(f"[bold red]Error during agent execution:[/bold red] {e}") - break + break \ No newline at end of file From 07e65b40a01c6629bc76c225ed7a25d2527451ec Mon Sep 17 00:00:00 2001 From: "codegen-sh[bot]" <131295404+codegen-sh[bot]@users.noreply.github.com> Date: Fri, 14 Mar 2025 17:41:51 +0000 Subject: [PATCH 2/2] Automated pre-commit update --- src/codegen/cli/commands/agent/main.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/codegen/cli/commands/agent/main.py b/src/codegen/cli/commands/agent/main.py index 78282e189..0c59247e1 100644 --- a/src/codegen/cli/commands/agent/main.py +++ b/src/codegen/cli/commands/agent/main.py @@ -5,8 +5,8 @@ from langchain_core.messages import SystemMessage from rich.console import Console from rich.markdown import Markdown -from rich.prompt import Prompt from rich.panel import Panel +from rich.prompt import Prompt from rich.text import Text from codegen.extensions.langchain.agent import create_agent_with_tools @@ -105,7 +105,7 @@ def say(message: str): console.print("I'm an AI assistant that can help you explore and modify code in this repository.") console.print("I can help with tasks like viewing files, searching code, making edits, and more.") console.print() - + # Display suggested prompts in a panel prompt_text = Text() prompt_text.append("Try asking me:\n", style="bold") @@ -113,14 +113,14 @@ def say(message: str): prompt_text.append(f"{i}. ", style="bold cyan") prompt_text.append(f"{prompt}\n", style="cyan") prompt_text.append("\nOr type 'help' to see more suggested prompts", style="dim") - + console.print(Panel(prompt_text, title="Suggested Prompts", border_style="blue")) console.print() - + console.print("What would you like help with today?") console.print() query = Prompt.ask("[bold]>[/bold]") # Simple arrow prompt - + # Handle 'help' command to show more suggested prompts if query.lower() in ["help", "--help", "man", "?", "examples"]: console.print("[bold]Suggested Starting Prompts:[/bold]") @@ -142,7 +142,7 @@ def say(message: str): if user_input.lower() in ["exit", "quit"]: break - + # Handle 'help' command to show suggested prompts if user_input.lower() in ["help", "--help", "man", "?", "examples"]: console.print("[bold]Suggested Starting Prompts:[/bold]") @@ -165,4 +165,4 @@ def say(message: str): say(result) except Exception as e: console.print(f"[bold red]Error during agent execution:[/bold red] {e}") - break \ No newline at end of file + break