-
Notifications
You must be signed in to change notification settings - Fork 71
feat: Onboarding guidance with .env setup #107
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
WalkthroughAdds onboarding for agents-core: expanded README Quick Start, a .env template, a post-install CLI/setup script, automatic .env scaffolding on package import (with safeguards), and a pyproject console-script entry; also exposes Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Package as vision_agents\n(__init__.py)
participant FSys as File System
participant CLI as vision-agents-setup\n(post_install.py)
rect rgba(0,150,100,0.08)
note over Package,FSys: Auto-setup on import (guarded)
User->>Package: import vision_agents
Package->>FSys: Determine package dir & CWD
alt running outside site-packages & .env missing
Package->>FSys: Locate env_template.txt
Package->>FSys: Copy template to .env
Package->>User: Print setup guidance
else in site-packages or .env exists
Package->>Package: Skip creation
end
end
rect rgba(0,100,200,0.06)
note over User,CLI: Manual CLI setup flow
User->>CLI: vision-agents-setup [--dir] [--force] [--guide]
alt --guide
CLI->>User: Display setup guide
else normal
CLI->>FSys: Resolve target dir & .env path
alt .env exists & not --force
CLI->>User: Report exists, exit
else
CLI->>FSys: Copy template → .env
CLI->>User: Print location & next steps
end
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 5
🧹 Nitpick comments (2)
agents-core/vision_agents/post_install.py (2)
71-91: Consider enhancing docstring (optional).The function is simple and effective. While the current docstring is adequate, you could optionally enhance it to be more explicit about the function's purpose and side effects.
-def show_setup_guide(): - """Show comprehensive setup guide.""" +def show_setup_guide(): + """Display comprehensive setup guide to stdout. + + Prints setup instructions, example usage, commands, and documentation links. + """
94-141: Enhance docstring to follow Google style guide.The CLI implementation is well-structured with clear argument handling and appropriate error reporting. The docstring could be enhanced to follow the Google style guide.
As per coding guidelines.
Apply this diff:
-def main(): - """Main entry point for setup script.""" +def main(): + """Main entry point for setup script. + + Parses command-line arguments and executes the appropriate setup action. + Creates .env file from template or displays setup guide based on flags. + + Raises: + SystemExit: Exits with code 1 if setup fails. + """
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
agents-core/README.md(1 hunks)agents-core/pyproject.toml(1 hunks)agents-core/vision_agents/__init__.py(1 hunks)agents-core/vision_agents/env_template.txt(1 hunks)agents-core/vision_agents/post_install.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (.cursor/rules/python.mdc)
**/*.py: Never adjust sys.path (e.g., sys.path.append/insert/assignment)
Docstrings must follow the Google style guide
Files:
agents-core/vision_agents/post_install.pyagents-core/vision_agents/__init__.py
🧬 Code graph analysis (1)
agents-core/vision_agents/__init__.py (2)
agents-core/vision_agents/core/agents/agents.py (1)
Agent(53-1021)agents-core/vision_agents/core/edge/types.py (1)
User(15-18)
🪛 LanguageTool
agents-core/README.md
[grammar] ~25-~25: There might be a mistake here.
Context: ...dd your API keys: ### Required API Keys - Stream (required): STREAM_API_KEY, `...
(QB_NEW_EN)
🔇 Additional comments (6)
agents-core/pyproject.toml (1)
84-85: LGTM!The console script configuration is correct and follows standard conventions. The entry point properly references
vision_agents.post_install:main.agents-core/README.md (3)
13-23: LGTM!The Quick Start instructions accurately reflect the auto-setup behavior implemented in
__init__.py. The import command will trigger the.envfile creation as expected.
25-30: LGTM!The API key requirements are clearly documented and align with the
env_template.txtfile. The categorization into required and optional services is helpful for users.
32-37: LGTM!The setup commands accurately document the CLI interface defined in
post_install.py:main().agents-core/vision_agents/env_template.txt (1)
1-129: LGTM!The environment template is comprehensive and well-organized. The section structure, helpful comments with API key URLs, and consistent placeholder format make this an excellent onboarding resource.
agents-core/vision_agents/__init__.py (1)
59-63: LGTM!The public API exports are clean and properly expose the core components (
Agent,User,__version__).
| ## Example Usage | ||
|
|
||
| ```python | ||
| from vision_agents import Agent | ||
| from vision_agents.plugins import openai, deepgram, cartesia | ||
|
|
||
| agent = Agent( | ||
| edge=getstream.Edge(), | ||
| agent_user=User(name="AI Assistant", id="agent"), | ||
| instructions="You're a helpful AI assistant.", | ||
| llm=openai.LLM(model="gpt-4o-mini"), | ||
| tts=cartesia.TTS(), | ||
| stt=deepgram.STT(), | ||
| ) | ||
| ``` |
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.
Add missing import for getstream.
The example code references getstream.Edge() on line 46 but doesn't import getstream. Users following this example will encounter a NameError.
Apply this diff to fix the import:
from vision_agents import Agent
-from vision_agents.plugins import openai, deepgram, cartesia
+from vision_agents.plugins import openai, deepgram, cartesia, getstream
agent = Agent(
edge=getstream.Edge(),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ## Example Usage | |
| ```python | |
| from vision_agents import Agent | |
| from vision_agents.plugins import openai, deepgram, cartesia | |
| agent = Agent( | |
| edge=getstream.Edge(), | |
| agent_user=User(name="AI Assistant", id="agent"), | |
| instructions="You're a helpful AI assistant.", | |
| llm=openai.LLM(model="gpt-4o-mini"), | |
| tts=cartesia.TTS(), | |
| stt=deepgram.STT(), | |
| ) | |
| ``` | |
| from vision_agents import Agent | |
| from vision_agents.plugins import openai, deepgram, cartesia, getstream | |
| agent = Agent( | |
| edge=getstream.Edge(), | |
| agent_user=User(name="AI Assistant", id="agent"), | |
| instructions="You're a helpful AI assistant.", | |
| llm=openai.LLM(model="gpt-4o-mini"), | |
| tts=cartesia.TTS(), | |
| stt=deepgram.STT(), | |
| ) |
🤖 Prompt for AI Agents
In agents-core/README.md around lines 39 to 53, the example references
getstream.Edge() but never imports getstream; add a top-level import for the
getstream module (e.g., add "import getstream") so the example runs without a
NameError, placing the import with the other example imports at the top of the
code block.
| def _setup_env_file(): | ||
| """Automatically create .env file from template if it doesn't exist.""" | ||
| try: | ||
| # Get the package directory | ||
| package_dir = Path(__file__).parent | ||
|
|
||
| # Template file path | ||
| template_path = package_dir / "env_template.txt" | ||
|
|
||
| # Target .env file path (in current working directory) | ||
| env_path = Path.cwd() / ".env" | ||
|
|
||
| # Check if .env already exists | ||
| if env_path.exists(): | ||
| return | ||
|
|
||
| # Check if template exists | ||
| if not template_path.exists(): | ||
| return | ||
|
|
||
| # Only create .env if we're in a project directory (not in site-packages) | ||
| # This prevents creating .env files in unexpected places | ||
| if "site-packages" in str(package_dir) or "dist-packages" in str(package_dir): | ||
| return | ||
|
|
||
| # Copy template to .env | ||
| import shutil | ||
| shutil.copy2(template_path, env_path) | ||
|
|
||
| # Print helpful message | ||
| print("🎉 Vision Agents: Created .env file with example configuration!") | ||
| print() | ||
| print("📁 File location:") | ||
| print(f" {env_path.absolute()}") | ||
| print() | ||
| print("📝 Please edit the .env file and add your actual API keys") | ||
| print("🔗 See the comments in the .env file for where to get API keys") | ||
| print("💡 Run 'vision-agents-setup' command for more setup options") | ||
|
|
||
| except Exception: | ||
| # Silently fail - don't break the import if env setup fails | ||
| pass | ||
|
|
||
| # Run the setup function | ||
| _setup_env_file() |
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.
Reconsider import-time side effects.
Creating files and printing to stdout during module import is a significant anti-pattern that can cause multiple issues:
- Tool breakage: Breaks introspection tools (mypy, sphinx, IDEs) that import modules for analysis
- CI/CD issues: Unexpected file creation in containerized or test environments
- Principle of least surprise: Users don't expect imports to modify the filesystem
- Silent failures: The broad
except Exception: passon line 52 hides all errors including permission issues
Consider refactoring to make setup explicit rather than automatic. Options:
- Require users to call
vision-agents-setupexplicitly (documented in README) - Only print a one-line reminder if .env is missing, without creating it
- Move the setup logic to a clearly-named function that users call explicitly
If you want to keep automatic setup, at minimum:
- Add a way to disable it (environment variable like
VISION_AGENTS_NO_AUTO_SETUP) - Make the message much shorter (one line max)
- Log specific exceptions instead of silently suppressing them
- Document this behavior prominently in the README
# Auto-create .env file on first import if it doesn't exist
def _setup_env_file():
- """Automatically create .env file from template if it doesn't exist."""
+ """Automatically create .env file from template if it doesn't exist.
+
+ This function runs at import time. It can be disabled by setting
+ the VISION_AGENTS_NO_AUTO_SETUP environment variable.
+
+ Returns:
+ bool: True if .env was created, False otherwise.
+ """
+ # Allow users to disable auto-setup
+ if os.environ.get("VISION_AGENTS_NO_AUTO_SETUP"):
+ return False
+
try:
# Get the package directory
package_dir = Path(__file__).parentCommittable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In agents-core/vision_agents/__init__.py around lines 13 to 57, remove the
import-time side effects by not running _setup_env_file() at module import;
instead expose a clearly named function (e.g., setup_env_file()) and a small
helper (e.g.,
ensure_env_file_exists(disable_auto=os.environ.get("VISION_AGENTS_NO_AUTO_SETUP"))),
remove automatic file creation and prints on import, and implement explicit
control: check VISION_AGENTS_NO_AUTO_SETUP before doing anything, make any
messages a single short log line (use logging.warning/info), and replace the
broad except Exception: pass with catching and logging specific exceptions
(IOError/OSError and Exception with logged error details) so callers can opt
into setup (e.g., via a CLI command or README instruction) and errors are
visible.
| # Only create .env if we're in a project directory (not in site-packages) | ||
| # This prevents creating .env files in unexpected places | ||
| if "site-packages" in str(package_dir) or "dist-packages" in str(package_dir): | ||
| return |
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.
Site-packages detection is fragile.
The string-matching approach for detecting site-packages installations is fragile and may fail for:
- Editable installs (
pip install -e .) - Conda environments with non-standard paths
- Custom installation directories
- Project directories that happen to contain "site-packages" or "dist-packages" in their path
Consider a more robust check:
- # Only create .env if we're in a project directory (not in site-packages)
- # This prevents creating .env files in unexpected places
- if "site-packages" in str(package_dir) or "dist-packages" in str(package_dir):
- return
+ # Only create .env if we're in a project directory (not in site-packages)
+ # This prevents creating .env files in unexpected places
+ try:
+ # Check if package is in the same directory as cwd or is in a stdlib/site location
+ package_dir.relative_to(Path.cwd())
+ except ValueError:
+ # Package is not under cwd, likely installed in site-packages
+ returnCommittable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In agents-core/vision_agents/__init__.py around lines 33 to 36, the current
string-match check for "site-packages"/"dist-packages" is fragile; replace it
with a robust containment check by resolving package_dir to an absolute Path and
comparing it against the actual site-packages / dist-packages locations returned
by site.getsitepackages(), sysconfig.get_paths() (e.g. "purelib"/"platlib"), and
optionally site.getusersitepackages(); treat any of those canonical paths as
targets and check whether package_dir.resolve() is inside any of them
(Path(...).resolve().is_relative_to(...) or equivalent loop over parents) so
editable installs, conda/custom prefixes, and symlinked paths are handled
correctly.
| except Exception: | ||
| # Silently fail - don't break the import if env setup fails | ||
| pass |
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.
Log exceptions instead of silently suppressing them.
While not breaking the import is reasonable, silently suppressing all exceptions means users won't know why setup failed (permissions, missing template, etc.).
Apply this diff to at least log failures:
+ import logging
+
except Exception:
- # Silently fail - don't break the import if env setup fails
- pass
+ # Don't break the import, but log the failure
+ logging.getLogger(__name__).debug(
+ "Failed to auto-create .env file", exc_info=True
+ )Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In agents-core/vision_agents/__init__.py around lines 52 to 54, the code
currently catches Exception and silently passes; change this to catch Exception
as e and log the error (including e and the traceback) using the module's logger
(or the standard logging.getLogger(__name__)) with a clear message like
"vision_agents initialization failed" so import doesn't break but failures are
recorded for debugging; ensure the logging import exists and that the exception
handler does not re-raise.
| def create_env_file(target_dir=None, force=False): | ||
| """Create .env file from template if it doesn't exist.""" | ||
| # Get the package directory | ||
| package_dir = Path(__file__).parent | ||
|
|
||
| # Template file path | ||
| template_path = package_dir / "env_template.txt" | ||
|
|
||
| # Target directory | ||
| if target_dir is None: | ||
| target_dir = Path.cwd() | ||
| else: | ||
| target_dir = Path(target_dir) | ||
|
|
||
| # Target .env file path | ||
| env_path = target_dir / ".env" | ||
|
|
||
| # Check if .env already exists | ||
| if env_path.exists() and not force: | ||
| print(f"✓ .env file already exists at {env_path}") | ||
| print("💡 Use --force to overwrite existing .env file") | ||
| return True | ||
|
|
||
| # Check if template exists | ||
| if not template_path.exists(): | ||
| print(f"❌ Template file not found at {template_path}") | ||
| return False | ||
|
|
||
| try: | ||
| # Ensure target directory exists | ||
| target_dir.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| # Copy template to .env | ||
| shutil.copy2(template_path, env_path) | ||
| print(f"✓ Created .env file at: {env_path}") | ||
| print() | ||
| print("📁 File location:") | ||
| print(f" {env_path.absolute()}") | ||
| print() | ||
| print("📝 Next steps:") | ||
| print("1. Edit the .env file and add your actual API keys") | ||
| print("2. See the comments in the .env file for where to get API keys") | ||
| print("3. Start building your vision agent!") | ||
| print() | ||
| print("🔗 Quick links for API keys:") | ||
| print(" • Stream: https://getstream.io/") | ||
| print(" • OpenAI: https://platform.openai.com/api-keys") | ||
| print(" • Deepgram: https://console.deepgram.com/") | ||
| print(" • Cartesia: https://cartesia.ai/") | ||
| print(" • FAL (Smart Turn): https://fal.ai/") | ||
| return True | ||
|
|
||
| except Exception as e: | ||
| print(f"❌ Failed to create .env file: {e}") | ||
| return False |
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.
🛠️ Refactor suggestion | 🟠 Major
Enhance docstring to follow Google style guide.
The function logic is solid with appropriate error handling and helpful user messaging. However, the docstring doesn't follow the Google style guide as required by the coding guidelines.
As per coding guidelines.
Apply this diff to improve the docstring:
-def create_env_file(target_dir=None, force=False):
- """Create .env file from template if it doesn't exist."""
+def create_env_file(target_dir=None, force=False):
+ """Create .env file from template if it doesn't exist.
+
+ Args:
+ target_dir: Directory to create .env file in. Defaults to current working directory.
+ force: If True, overwrite existing .env file.
+
+ Returns:
+ bool: True if .env file was created or already exists, False on failure.
+ """🤖 Prompt for AI Agents
In agents-core/vision_agents/post_install.py around lines 14 to 68, the function
docstring for create_env_file should be converted to Google style: replace the
current one-line description with a multiline docstring that includes a short
summary, a longer description of behavior, and sections for Args (target_dir:
Optional path to create .env in; force: bool whether to overwrite), Returns
(bool indicating success), and Raises (propagate or document exceptions if any
are expected), keeping it concise and formatted per Google Python docstring
conventions.
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.
Actionable comments posted: 2
♻️ Duplicate comments (2)
agents-core/vision_agents/__init__.py (1)
11-52: Import-time side effects and related issues already flagged.The major concerns with this approach—creating files at import time, fragile site-packages detection, and silent exception suppression—were thoroughly documented in previous review comments.
Additionally, the docstring doesn't follow Google style guide, though this is minor compared to the architectural concerns already raised.
As per coding guidelines.
agents-core/vision_agents/post_install.py (1)
13-67: Docstring still needs Google style formatting.The docstring remains a single line and doesn't follow the Google style guide required by the coding guidelines. This issue was previously identified.
As per coding guidelines.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
agents-core/vision_agents/__init__.py(1 hunks)agents-core/vision_agents/post_install.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (.cursor/rules/python.mdc)
**/*.py: Never adjust sys.path (e.g., sys.path.append/insert/assignment)
Docstrings must follow the Google style guide
Files:
agents-core/vision_agents/post_install.pyagents-core/vision_agents/__init__.py
🧬 Code graph analysis (1)
agents-core/vision_agents/__init__.py (2)
agents-core/vision_agents/core/agents/agents.py (1)
Agent(53-1021)agents-core/vision_agents/core/edge/types.py (1)
User(15-18)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: unit / Test "not integration"
🔇 Additional comments (3)
agents-core/vision_agents/post_install.py (1)
1-11: Imports and module structure look solid.The imports are appropriate, and no sys.path manipulation is present.
agents-core/vision_agents/__init__.py (2)
1-9: Module header is clean and appropriate.The version placeholder and imports are correctly structured.
57-61: Public API exports are well-defined.The exposed components (
Agent,User,__version__) provide a clean interface, and the__all__declaration makes the public API explicit.
| def show_setup_guide(): | ||
| """Show comprehensive setup guide.""" | ||
| print("🚀 Vision Agents Setup Guide") | ||
| print("=" * 50) | ||
| print() | ||
| print("✅ Package already installed!") | ||
| print() | ||
| print("📝 Next steps:") | ||
| print("1. Add your API keys to the .env file") | ||
| print("2. Start building your vision agent:") | ||
| print() | ||
| print(" from vision_agents import Agent") | ||
| print(" from vision_agents.plugins import openai, deepgram, cartesia") | ||
| print() | ||
| print("🔧 Setup commands:") | ||
| print(" vision-agents-setup # Create .env file") | ||
| print(" vision-agents-setup --force # Overwrite existing .env") | ||
| print(" vision-agents-setup --guide # Show this guide") | ||
| print() | ||
| print("📚 Documentation: https://visionagents.ai/") | ||
| print("💬 Examples: https://github.com/GetStream/Vision-Agents/tree/main/examples") | ||
|
|
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.
🛠️ Refactor suggestion | 🟠 Major
Enhance docstring to follow Google style guide.
The function's docstring should be expanded to follow Google style.
As per coding guidelines.
Apply this diff:
-def show_setup_guide():
- """Show comprehensive setup guide."""
+def show_setup_guide():
+ """Show comprehensive setup guide.
+
+ Prints setup instructions, commands, and documentation links to stdout.
+ """🤖 Prompt for AI Agents
In agents-core/vision_agents/post_install.py around lines 70 to 91, the
show_setup_guide() function currently has a one-line docstring; update it to a
multi-line Google-style docstring that includes a short summary, a longer
description of what the function prints, an "Args" section indicating there are
no parameters, a "Returns" section stating None, an optional "Raises" section if
relevant (or state that no exceptions are raised), and an "Examples" section
showing how to call the function; keep the docstring concise and follow Google
docstring formatting conventions.
| def main(): | ||
| """Main entry point for setup script.""" | ||
| parser = argparse.ArgumentParser( | ||
| description="Vision Agents setup script", | ||
| formatter_class=argparse.RawDescriptionHelpFormatter, | ||
| epilog=""" | ||
| Examples: | ||
| vision-agents-setup # Create .env in current directory | ||
| vision-agents-setup --dir /path/to/project # Create .env in specific directory | ||
| vision-agents-setup --force # Overwrite existing .env file | ||
| vision-agents-setup --guide # Show setup guide | ||
| """ | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--dir", "-d", | ||
| help="Directory to create .env file in (default: current directory)" | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--force", "-f", | ||
| action="store_true", | ||
| help="Overwrite existing .env file" | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--guide", "-g", | ||
| action="store_true", | ||
| help="Show setup guide" | ||
| ) | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| if args.guide: | ||
| show_setup_guide() | ||
| return | ||
|
|
||
| try: | ||
| success = create_env_file(target_dir=args.dir, force=args.force) | ||
| if not success: | ||
| sys.exit(1) | ||
| except Exception as e: | ||
| print(f"❌ Setup script failed: {e}") | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
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.
🛠️ Refactor suggestion | 🟠 Major
Enhance docstring to follow Google style guide.
The main function's implementation is solid with proper argument parsing and error handling. However, the docstring needs expansion.
As per coding guidelines.
Apply this diff:
-def main():
- """Main entry point for setup script."""
+def main():
+ """Main entry point for setup script.
+
+ Parses CLI arguments and executes the requested action:
+ - Creates .env file in specified or current directory
+ - Shows setup guide if --guide flag is provided
+ - Supports --force to overwrite existing .env files
+
+ Exits with code 1 on failure, 0 on success.
+ """📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| def main(): | |
| """Main entry point for setup script.""" | |
| parser = argparse.ArgumentParser( | |
| description="Vision Agents setup script", | |
| formatter_class=argparse.RawDescriptionHelpFormatter, | |
| epilog=""" | |
| Examples: | |
| vision-agents-setup # Create .env in current directory | |
| vision-agents-setup --dir /path/to/project # Create .env in specific directory | |
| vision-agents-setup --force # Overwrite existing .env file | |
| vision-agents-setup --guide # Show setup guide | |
| """ | |
| ) | |
| parser.add_argument( | |
| "--dir", "-d", | |
| help="Directory to create .env file in (default: current directory)" | |
| ) | |
| parser.add_argument( | |
| "--force", "-f", | |
| action="store_true", | |
| help="Overwrite existing .env file" | |
| ) | |
| parser.add_argument( | |
| "--guide", "-g", | |
| action="store_true", | |
| help="Show setup guide" | |
| ) | |
| args = parser.parse_args() | |
| if args.guide: | |
| show_setup_guide() | |
| return | |
| try: | |
| success = create_env_file(target_dir=args.dir, force=args.force) | |
| if not success: | |
| sys.exit(1) | |
| except Exception as e: | |
| print(f"❌ Setup script failed: {e}") | |
| sys.exit(1) | |
| if __name__ == "__main__": | |
| main() | |
| def main(): | |
| """Main entry point for setup script. | |
| Parses CLI arguments and executes the requested action: | |
| - Creates .env file in specified or current directory | |
| - Shows setup guide if --guide flag is provided | |
| - Supports --force to overwrite existing .env files | |
| Exits with code 1 on failure, 0 on success. | |
| """ | |
| parser = argparse.ArgumentParser( | |
| description="Vision Agents setup script", | |
| formatter_class=argparse.RawDescriptionHelpFormatter, | |
| epilog=""" | |
| Examples: | |
| vision-agents-setup # Create .env in current directory | |
| vision-agents-setup --dir /path/to/project # Create .env in specific directory | |
| vision-agents-setup --force # Overwrite existing .env file | |
| vision-agents-setup --guide # Show setup guide | |
| """ | |
| ) | |
| parser.add_argument( | |
| "--dir", "-d", | |
| help="Directory to create .env file in (default: current directory)" | |
| ) | |
| parser.add_argument( | |
| "--force", "-f", | |
| action="store_true", | |
| help="Overwrite existing .env file" | |
| ) | |
| parser.add_argument( | |
| "--guide", "-g", | |
| action="store_true", | |
| help="Show setup guide" | |
| ) | |
| args = parser.parse_args() | |
| if args.guide: | |
| show_setup_guide() | |
| return | |
| try: | |
| success = create_env_file(target_dir=args.dir, force=args.force) | |
| if not success: | |
| sys.exit(1) | |
| except Exception as e: | |
| print(f"❌ Setup script failed: {e}") | |
| sys.exit(1) | |
| if __name__ == "__main__": | |
| main() |
🤖 Prompt for AI Agents
In agents-core/vision_agents/post_install.py around lines 93 to 140, the
module-level main() docstring is too brief; replace it with a Google-style
docstring that documents the function purpose and parameters: add a short
summary line, an Args section describing none (or that CLI args are parsed via
argparse), a Returns section (e.g., None), and a Raises section listing
SystemExit on failure or Exception if propagated; ensure formatting follows
Google style (sections labeled Args:, Returns:, Raises:) and keep it concise.
| if not template_path.exists(): | ||
| return |
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.
Is this a possibility? The files comes in the repo.
| __version__ = "0.0.0" | ||
|
|
||
| # Auto-create .env file on first import if it doesn't exist | ||
| def _setup_env_file(): |
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.
Wouldn't this run every time the project starts? "Onboarding script" feels fancy but as a user, I'd prefer a simple copy-paste over a script over a fancy alternative. I'd recommend providing the template and instructing the users to copy that to .env when it's necessary.
| except Exception: | ||
| # Silently fail - don't break the import if env setup fails | ||
| pass |
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.
Is there any expected failures?
What does this PR do?
Provides a .env template for new users that is automatically created when starting and exploring the project. It will provide the .env shell so that users only will need to fill in the missing API keys.
Why does this PR do it?
To help users onboard.
How does it work?
The .env file will be created/checked upon importing the agent, e.g.

from vision_agents import Agent. If it doesn't exist, it'll be created with help and next steps:Summary by CodeRabbit
New Features
Documentation