-
Notifications
You must be signed in to change notification settings - Fork 832
Add to_cli()
method to Agent
#1642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR Change SummaryExposed the existing CLI functionality as a method on the Agent, allowing users to utilize CLI with custom Agents.
Modified Files
How can I customize these reviews?Check out the Hyperlint AI Reviewer docs for more information on how to customize the review. If you just want to ignore it on this PR, you can add the Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add |
@samuelcolvin @Kludex any concerns merging this before #1504? This PR is a minor refactor, mainly just allows |
pydantic_ai_slim/pydantic_ai/_cli.py
Outdated
@@ -83,7 +84,7 @@ def cli_system_prompt() -> str: | |||
The user is running {sys.platform}.""" | |||
|
|||
|
|||
def cli(args_list: Sequence[str] | None = None) -> int: | |||
def cli(args_list: Sequence[str] | None = None, agent: Agent[None, str] = cli_agent) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agent
doesn't need to be a parameter here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also remove run_cli() and just align on --agent mymodule.submodule:my_agent
as the interface if that's preferable, let me know your thoughts.
Overview
Exposes existing CLI functionality as a method on Agent. This allows users to use CLI with custom Agents.
Related issue: #1595
Demo for
Agent.run_cli()
Script
Result
Demo for
pai --agent