Update agents.py
Browse files
agents.py
CHANGED
|
@@ -1,26 +1,38 @@
|
|
| 1 |
-
from phi.assistant import Assistant
|
| 2 |
-
from phi.
|
| 3 |
-
from
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
)
|
|
|
|
| 1 |
+
from phi.assistant import Assistant
|
| 2 |
+
from phi.tools.wikipedia import WikipediaTools
|
| 3 |
+
from google import genai
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
client = genai.Client(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 7 |
+
|
| 8 |
+
class GeminiWrapper:
|
| 9 |
+
"""Custom wrapper to use new Gemini SDK inside phi"""
|
| 10 |
+
|
| 11 |
+
def __init__(self, model="gemini-2.0-flash"):
|
| 12 |
+
self.model = model
|
| 13 |
+
|
| 14 |
+
def __call__(self, prompt, **kwargs):
|
| 15 |
+
response = client.models.generate_content(
|
| 16 |
+
model=self.model,
|
| 17 |
+
contents=prompt
|
| 18 |
+
)
|
| 19 |
+
return response.text
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def get_content_enhancer_agent(knowledge_base=None):
|
| 23 |
+
return Assistant(
|
| 24 |
+
llm=GeminiWrapper(),
|
| 25 |
+
tools=[WikipediaTools()],
|
| 26 |
+
knowledge_base=knowledge_base,
|
| 27 |
+
search_knowledge=True,
|
| 28 |
+
description="You are an expert multimedia content creator and writer.",
|
| 29 |
+
instructions=[
|
| 30 |
+
"You will receive a summary from a video analysis.",
|
| 31 |
+
"Enhance it using knowledge + Wikipedia.",
|
| 32 |
+
"Create a cohesive narrative.",
|
| 33 |
+
"Insert [IMAGE: caption=\"...\"] placeholders.",
|
| 34 |
+
"Make prompts vivid and visual.",
|
| 35 |
+
"Return only final text."
|
| 36 |
+
],
|
| 37 |
+
show_tool_calls=True,
|
| 38 |
)
|