File size: 2,931 Bytes
a2ca67f
 
 
5567345
77726b9
5567345
 
 
 
a2ca67f
 
 
5567345
 
 
 
 
 
a2ca67f
 
 
 
5567345
77726b9
5567345
 
 
 
 
 
d4e9d67
 
5567345
d4e9d67
5567345
 
 
 
a2ca67f
 
 
5567345
 
 
 
 
 
a2ca67f
 
 
 
 
 
 
 
5567345
 
 
 
 
 
a2ca67f
 
 
 
 
 
 
 
 
 
 
5567345
 
a2ca67f
 
 
 
5567345
a2ca67f
 
 
 
 
5567345
a2ca67f
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from smolagents import tool
from typing import List, Dict
import re
import yaml
from .search_tools import get_search_tool

# Load style guide
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
    """
    # First, get some background information
    search_tool = get_search_tool(max_results=2)
    try:
        search_query = f"{topic} {section_title}"
        research = search_tool.forward(search_query)
        
        # Format the content in your style
        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>"]
    }