File size: 1,195 Bytes
d352829
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1b213ca
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
from phi.assistant import Assistant
from phi.tools.wikipedia import WikipediaTools
from google import genai
import os

client = genai.Client(api_key=os.getenv("GOOGLE_API_KEY"))

class GeminiWrapper:
    """Custom wrapper to use new Gemini SDK inside phi"""

    def __init__(self, model="gemini-2.0-flash"):
        self.model = model

    def __call__(self, prompt, **kwargs):
        response = client.models.generate_content(
            model=self.model,
            contents=prompt
        )
        return response.text


def get_content_enhancer_agent(knowledge_base=None):
    return Assistant(
        llm=GeminiWrapper(),
        tools=[WikipediaTools()],
        knowledge_base=knowledge_base,
        search_knowledge=True,
        description="You are an expert multimedia content creator and writer.",
        instructions=[
            "You will receive a summary from a video analysis.",
            "Enhance it using knowledge + Wikipedia.",
            "Create a cohesive narrative.",
            "Insert [IMAGE: caption=\"...\"] placeholders.",
            "Make prompts vivid and visual.",
            "Return only final text."
        ],
        show_tool_calls=True,
    )