Generate a Python package structure and content using the specified LLM via Groq.
(package_name: str, package_description: str, features: List[str], client: Groq, model_name: str)
| 74 | return "" |
| 75 | |
| 76 | def generate_python_package(package_name: str, package_description: str, features: List[str], client: Groq, model_name: str) -> Optional[Dict[str, str]]: |
| 77 | """Generate a Python package structure and content using the specified LLM via Groq.""" |
| 78 | |
| 79 | # Format the features as a bulleted list |
| 80 | if features: |
| 81 | features_formatted = "\n".join(f"- {feature.strip()}" for feature in features) |
| 82 | features_section = f"\n\nInclude the following features:\n{features_formatted}" |
| 83 | else: |
| 84 | features_section = "" |
| 85 | |
| 86 | prompt = f""" |
| 87 | Create a Python package named `{package_name}` based on the following description: |
| 88 | {package_description}{features_section} |
| 89 | |
| 90 | Provide the package structure and content strictly in the following format for each file: |
| 91 | |
| 92 | <file_path> |
| 93 | <begin_content> |
| 94 | file_content |
| 95 | <end_content> |
| 96 | |
| 97 | Include at least the following files in this order: |
| 98 | - setup.py |
| 99 | - README.md |
| 100 | - requirements.txt |
| 101 | - examples/example_{package_name}.py |
| 102 | - tests/test_{package_name}.py |
| 103 | - {package_name}/__init__.py |
| 104 | - {package_name}/main.py |
| 105 | |
| 106 | Ensure there are no extra lines or spaces between the tags and the content. |
| 107 | |
| 108 | **Example:** |
| 109 | |
| 110 | <setup.py> |
| 111 | <begin_content> |
| 112 | from setuptools import setup, find_packages |
| 113 | |
| 114 | setup( |
| 115 | name='examplepkg', |
| 116 | version='0.1.0', |
| 117 | description='An example package', |
| 118 | author='Your Name', |
| 119 | packages=find_packages(), |
| 120 | install_requires=[ |
| 121 | # Add dependencies here |
| 122 | ], |
| 123 | classifiers=[ |
| 124 | 'Programming Language :: Python :: 3', |
| 125 | 'License :: OSI Approved :: MIT License', |
| 126 | ], |
| 127 | ) |
| 128 | <end_content> |
| 129 | """ |
| 130 | |
| 131 | try: |
| 132 | response_text = generate_content_with_groq(client, model_name, prompt) |
| 133 | print("=== Raw AI Response ===") |
no test coverage detected