Skip to content
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

This prompt does not generate any code #6

Open
ballidev opened this issue Aug 7, 2024 · 0 comments
Open

This prompt does not generate any code #6

ballidev opened this issue Aug 7, 2024 · 0 comments

Comments

@ballidev
Copy link

ballidev commented Aug 7, 2024

When running this prompt, the process seems to stop quickly and for no apparent reason. No code is generated.

I've been successfully generating code before this, but not with prompts with as much detail as this one.

I have tried it twice and it seems to behave the same both times

This is the generate_codebase call:

codebase: dict = generate_codebase(
    f"""

## Python OpenAPI Spec Filter and Trimmer

**Objective:** 

Build a user-friendly command-line tool in Python to filter and optionally trim OpenAPI specifications in YAML format.

**Functionality:**

1. **Input:**
   - Accepts a URL or local file path to an OpenAPI spec (YAML) as a positional argument.
   - Downloads and saves the file locally if a URL is provided.
   - Verifies file existence for a local file path.

2. **Validation:**
   - Validates the input file against the OpenAPI specification using a suitable Python library (e.g., `openapi-spec-validator`, `connexion`).

3. **Trimming (Optional):**
   - Enabled using the `--trim` flag.
   - Create a "trimmed" version of the spec file:
     - Remove all `example` fields throughout the specification (parameters, request/response bodies, objects, properties, etc.).
     - Remove the entire `components/examples` section, if present.
     - Save the trimmed version with a "trimmed_" prefix.
   - Attempt to validate the trimmed file.
   - If validation fails, display a user-friendly error message including a formatted stack trace and exit.

4. **Path Filtering (Optional):**
   - Enabled using the `--filter` flag.
   - **Regex Input:**
      - If `--filter-pattern='<REGEX_PATTERN>'` is provided, use the given regex.
      - If `--filter-pattern` is not provided:
         - Display all paths from the OpenAPI spec to the user.
         - Prompt the user to enter a regex pattern.
         - Validate the regex and re-prompt if invalid.
         - Display the filtered path list.
         - Allow the user to refine the regex until satisfied. 
   - Filter the paths in the OpenAPI spec to include only those matching the provided or user-defined regex.
   - Display the filtered list of paths to the user. 

5. **Output Generation:**
   - If neither `--filter` nor `--trim` is provided, default to `--help`.
   - Create a new OpenAPI spec file (YAML):
     - Use the prefix "filtered_" if filtering is applied.
     - Use the prefix "trimmed_" if trimming is applied (and filtering is not applied).
     - Use the prefix "trimmed_filtered_" if both trimming and filtering are applied. 
   - Include only the paths matching the regex (if filtering is enabled).
   - Include only the models and components referenced by the included paths.

6. **Error Handling:**
   - Implement user-friendly error messages for:
     - Invalid file paths or URLs.
     - Invalid OpenAPI spec format.
     - Regex validation errors.
     - Missing or invalid command-line arguments.
   - Use a Python library to format stack traces readably for debugging.

7. **Help (`--help`):**
   - Display a clear and concise help message explaining the usage of the tool:
     - Describe the purpose of the tool.
     - List and explain all command-line flags and options:
       - `--trim`: Enable trimming of examples.
       - `--filter`: Enable path filtering.
       - `--filter-pattern='<REGEX_PATTERN>'`: Provide a regex pattern for filtering. 
     - Provide examples of valid command usage. 

**Testing:**

- Create a test suite with at least 10 test cases covering various scenarios:
  - Valid and invalid input files.
  - Trimming with and without filtering.
  - Different regex patterns for filtering.
  - User interaction for regex input.
  - Help message display. 
- Generate fixture files containing:
   - Valid OpenAPI specifications in YAML format.
   - Corresponding "trimmed" versions of those specifications.
   - Expected "filtered" versions based on different regex patterns.
- Write tests to:
    - Validate that the trimming logic correctly removes examples and unused components.
    - Confirm the filtering logic produces the expected output based on different regex inputs and fixture files.
    - Ensure error handling, user prompts, command-line argument parsing, and help message display function correctly.

**Code Style:**

- Adhere to PEP 8 style guidelines.
- Use clear and concise variable and function names.
- Include comments to explain complex logic.
- Use type hints for function parameters and return values. 


""",
    steps=20
)
@ballidev ballidev changed the title This prompt This prompt does not generate any code Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant