MCPcopy Create free account
hub / github.com/GitsSaikat/PyGen / generate_python_package

Function generate_python_package

pygen/package_groq.py:76–145  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

74 return ""
75
76def 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"""
87Create a Python package named `{package_name}` based on the following description:
88{package_description}{features_section}
89
90Provide the package structure and content strictly in the following format for each file:
91
92<file_path>
93<begin_content>
94file_content
95<end_content>
96
97Include 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
106Ensure there are no extra lines or spaces between the tags and the content.
107
108**Example:**
109
110<setup.py>
111<begin_content>
112from setuptools import setup, find_packages
113
114setup(
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 ===")

Callers 2

mainFunction · 0.70
mainFunction · 0.70

Calls 2

parse_generated_contentFunction · 0.70

Tested by

no test coverage detected