import cohere # Initialize Cohere client co = cohere.Client("nvnj") def generate_helm_chart(prompt): prompt = f"Generate a Kubernetes Helm chart for a microservice named '{service_name}' in YAML format." response = co.generate( model="command", prompt=prompt, max_tokens=300, temperature=0.7, ) return response.generations[0].text.strip() # Example Usage service_name = "example-service" helm_chart = generate_helm_chart(service_name) print(helm_chart) def save_exact_output_to_file(output, file_name): try: # Save the exact string output to the file with open(file_name, "w") as file: file.write(output) print(f"Output saved successfully to {file_name}") except Exception as e: print(f"Error saving output: {e}") # Example Usage if __name__ == "__main__": service_name = "example-service" try: # Generate the Helm chart helm_chart = generate_helm_chart(service_name) # Save the output to a YAML file file_name = f"{service_name}_helm_chart.yaml" save_exact_output_to_file(helm_chart, file_name) except Exception as e: print(f"Error: {e}")