| | from smolagents import tool |
| | from typing import List, Dict |
| | import re |
| | import yaml |
| | from .search_tools import get_search_tool |
| |
|
| | |
| | with open("style_guide.yaml", 'r') as f: |
| | style_guide = yaml.safe_load(f) |
| |
|
| | @tool |
| | def generate_blog_section(topic: str, section_title: str) -> str: |
| | """Generates content for a specific section of the blog post, following Joséphine's style: |
| | - Direct and conversational tone |
| | - Short, clear sentences |
| | - Personal but professional |
| | - Draws from AI product experience when relevant |
| | |
| | Args: |
| | topic: The main topic of the blog post |
| | section_title: The title of the section to generate |
| | """ |
| | |
| | search_tool = get_search_tool(max_results=2) |
| | try: |
| | search_query = f"{topic} {section_title}" |
| | research = search_tool.forward(search_query) |
| | |
| | |
| | content = f"# {section_title}\n\n" |
| | content += f"Here's my take on {topic}, focusing on {section_title}. " |
| | content += f"From my experience in AI products:\n\n" |
| | content += f"{research}\n\n" |
| | content += "Questions? Let's discuss." |
| | |
| | return content |
| | except Exception as e: |
| | return f"Error generating content: {str(e)}" |
| |
|
| | @tool |
| | def improve_writing_style(text: str, style: str = "professional") -> str: |
| | """Improves the writing style while maintaining Joséphine's voice: |
| | - Keeps direct, conversational tone |
| | - Removes AI clichés |
| | - Ensures natural flow |
| | - Maintains authenticity |
| | |
| | Args: |
| | text: The text to improve |
| | style: The desired writing style (e.g., professional, casual, academic) |
| | """ |
| | return f"Improved version of the text in {style} style" |
| |
|
| | @tool |
| | def check_readability(text: str) -> Dict: |
| | """Analyzes the readability of the text, focusing on: |
| | - Sentence length and clarity |
| | - Natural flow |
| | - Direct communication |
| | - Professional but personal tone |
| | |
| | Args: |
| | text: The text to analyze |
| | """ |
| | words = len(text.split()) |
| | sentences = len(re.split(r'[.!?]+', text)) |
| | avg_words_per_sentence = words / max(sentences, 1) |
| | |
| | return { |
| | "word_count": words, |
| | "sentence_count": sentences, |
| | "avg_words_per_sentence": avg_words_per_sentence, |
| | "readability_score": "Good" if avg_words_per_sentence < 15 else "Consider shorter sentences", |
| | "style_notes": "Check for direct tone and clear communication" |
| | } |
| |
|
| | @tool |
| | def generate_seo_metadata(title: str, content: str) -> Dict: |
| | """Generates SEO metadata while maintaining authentic voice |
| | Args: |
| | title: The blog post title |
| | content: The blog post content |
| | """ |
| | return { |
| | "meta_description": f"A practical look at {title}", |
| | "keywords": [word.lower() for word in title.split()], |
| | "suggested_title_tags": [f"<h1>{title}</h1>"] |
| | } |
| |
|