# core/cohere_engine.py import cohere import os # Grab your API key from environment or use a placeholder COHERE_API_KEY = os.getenv("COHERE_API_KEY", "your-cohere-api-key-here") co = cohere.Client(COHERE_API_KEY) def generate_post(topic, tone, platform, length): print(f"[DEBUG] Generating post with: {topic=}, {tone=}, {platform=}, {length=}") try: # Example: Cohere call logic response = co.generate( model='command-r-plus', prompt=f"Write a {tone} {platform} post about {topic}. Keep it {length}.", max_tokens=300, temperature=0.7 ) print("[DEBUG] Cohere response:", response) return response.generations[0].text except Exception as e: print("[ERROR] Cohere generation failed:", e) return "Oops! Something went wrong while generating the post. Please try again later."