from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool import datetime import requests import pytz import yaml from tools.final_answer import FinalAnswerTool from datetime import datetime, timedelta import json from Gradio_UI import GradioUI import os from dotenv import load_dotenv import openai # Load environment variables from .env file load_dotenv() # Access the API key openai.api_key = os.getenv('OPENAI_API_KEY') # Below is the new deadline calculator tool @tool def chatgpt_conversation(prompt: str) -> str: """A tool that interacts with the OpenAI API to simulate a conversation with a dynamic prompt. Args: prompt: The message to ChatGPT. Returns: The assistant's response to the prompt. """ response = openai.chat.completions.create( model="gpt-4o-mini", messages=[ {"role": "user", "content": prompt} ], ) return response.choices[0].message.content @tool def marketing_expert_review(post: str) -> str: """A tool that reviews and enhances social media posts to maximize impressions, leveraging expertise in marketing, neuromarketing, sales, and social media strategies. Args: post: The social media post to be reviewed and enhanced. """ prompt = f""" You are an expert in marketing, neuromarketing, sales, and social media post reviewing with over 15 years of experience optimizing content for maximum reach and engagement. Your expertise includes understanding audience psychology, crafting compelling narratives, and applying proven strategies to boost impressions on platforms like Instagram, Facebook, LinkedIn, and Twitter. Your task is to review and enhance the following social media post to make it as engaging, attractive, and impactful as possible, ensuring it captures attention and drives the highest possible impressions. **Context**: Social media platforms thrive on posts that are emotionally resonant, visually suggestive (even in text), and encourage interaction (likes, shares, comments). Successful posts often include a hook in the first few words, a clear value proposition, and a call-to-action. **Post to enhance**: "{post}" **Format**: Provide the enhanced post directly as a single block of text, ready to be posted. Keep it concise yet powerful, suitable for broad social media use unless a specific platform is mentioned in the instructions. **References**: For guidance, consider posts like: "Just dropped our new summer collection – bold colors, big vibes! Which shade’s your vibe? Drop it below! 🌟 #SummerStyle" (hook + engagement + hashtag) or "Struggling with productivity? This 5-min trick changed my life – and it’ll change yours too. Link in bio!" (problem-solution + curiosity). Enhanced post: """ try: response = openai.chat.completions.create( model="gpt-4o-mini", messages=[ {"role": "user", "content": prompt} ], ) return response.choices[0].message.content except Exception as e: return f"Error generating enhanced post: {str(e)}" @tool def twitter_post_enhancer(post: str) -> str: """A tool that enhances short, basic social media posts into engaging Twitter (X) posts, leveraging expertise in social media engagement and content writing. Args: post: The social media post to be enhanced for Twitter. """ prompt = f""" You are an expert in social media engagement and content writing, with a specialization in crafting posts for Twitter (X). You have a deep understanding of Twitter’s unique culture, where concise, punchy, and emotionally engaging content thrives within a 280-character limit. Your task is to take the following short, basic social media post and enhance it to make it more engaging, attractive, and appealing for a general Twitter audience. Focus on: - Adding relevant emojis to boost visual appeal and emotion. - Rephrasing text for clarity, impact, and a casual, conversational tone. - Making the post interesting and shareable while keeping it concise and easy to understand. **Context**: Twitter users scroll fast—posts need a strong hook, relatable or surprising elements, and often a question or bold statement to spark interaction. Trending topics, humor, and timely references can amplify reach. **Post to enhance**: "{post}" **Format**: Return the enhanced post in this structure: