Skip to content

Add --sysinfo CLI Argument to Output System Information for Debugging #1169

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

Merged
merged 5 commits into from
Jul 7, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions gpt_engineer/applications/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
"""

import difflib
import json
import logging
import os
import platform
import subprocess
import sys

from pathlib import Path
Expand Down Expand Up @@ -237,6 +240,30 @@ def prompt_yesno() -> bool:
print("Please respond with 'y' or 'n'")


def get_system_info():
system_info = {
"os": platform.system(),
"os_version": platform.version(),
"architecture": platform.machine(),
"python_version": sys.version,
"packages": get_installed_packages(),
}
return system_info


def get_installed_packages():
try:
result = subprocess.run(
[sys.executable, "-m", "pip", "list", "--format=json"],
capture_output=True,
text=True,
)
packages = json.loads(result.stdout)
return {pkg["name"]: pkg["version"] for pkg in packages}
except Exception as e:
return str(e)


@app.command(
help="""
GPT-engineer lets you:
Expand Down Expand Up @@ -329,6 +356,11 @@ def main(
"--no_execution",
help="Run setup but to not call LLM or write any code. For testing purposes.",
),
sysinfo: bool = typer.Option(
False,
"--sysinfo",
help="Output system information for debugging",
),
):
"""
The main entry point for the CLI tool that generates or improves a project.
Expand Down Expand Up @@ -369,6 +401,8 @@ def main(
Flag indicating whether to enable verbose logging.
no_execution: bool
Run setup but to not call LLM or write any code. For testing purposes.
sysinfo: bool
Flag indicating whether to output system information for debugging.

Returns
-------
Expand All @@ -380,6 +414,12 @@ def main(

sys.excepthook = lambda *_: pdb.pm()

if sysinfo:
sys_info = get_system_info()
for key, value in sys_info.items():
print(f"{key}: {value}")
raise typer.Exit()

# Validate arguments
if improve_mode and (clarify_mode or lite_mode):
typer.echo("Error: Clarify and lite mode are not compatible with improve mode.")
Expand Down
Loading