Enhance the package description using the Groq model with retry logic. Args: client (Groq): The Groq client instance. model_name (str): The model name to use. package_description (str): Original package description. max_retries (int): Maximum number of retri
(client: Groq, model_name: str, package_description: str, max_retries: int = 5)
| 108 | return feature_descriptions |
| 109 | |
| 110 | def enhance_package_description(client: Groq, model_name: str, package_description: str, max_retries: int = 5) -> str: |
| 111 | """ |
| 112 | Enhance the package description using the Groq model with retry logic. |
| 113 | |
| 114 | Args: |
| 115 | client (Groq): The Groq client instance. |
| 116 | model_name (str): The model name to use. |
| 117 | package_description (str): Original package description. |
| 118 | max_retries (int): Maximum number of retries for the request. |
| 119 | |
| 120 | Returns: |
| 121 | str: Enhanced package description. |
| 122 | """ |
| 123 | prompt = f"Enhance the following package description to make it more comprehensive and user-friendly, focusing on implementation details and including elaborate explanations to help with code generation.\n\n{package_description}\n\nEnhanced Description:" |
| 124 | retries = 0 |
| 125 | while retries < max_retries: |
| 126 | try: |
| 127 | response = client.chat.completions.create( |
| 128 | messages=[ |
| 129 | { |
| 130 | "role": "user", |
| 131 | "content": prompt, |
| 132 | } |
| 133 | ], |
| 134 | model=model_name, |
| 135 | ) |
| 136 | enhanced_description = response.choices[0].message.content.strip() |
| 137 | return enhanced_description |
| 138 | except Exception as e: |
| 139 | retries += 1 |
| 140 | wait_time = 2 ** retries |
| 141 | print(f"Error enhancing package description: {str(e)}") |
| 142 | print(f"Retrying in {wait_time} seconds... (Attempt {retries}/{max_retries})") |
| 143 | time.sleep(wait_time) |
| 144 | else: |
| 145 | print(f"Failed to enhance package description after {max_retries} attempts.") |
| 146 | return package_description |
| 147 | |
| 148 | def generate_python_package(package_name: str, package_description: str, features: Optional[List[str]], api_provider: str, api_key: str, model_name: str) -> Optional[Dict[str, str]]: |
| 149 | """Generate a Python package structure and content using Groq or GEMINI models.""" |
no outgoing calls
no test coverage detected