ContiAI / agents /content_phase /keyword_agent.py
ziadsameh32's picture
Update agents/content_phase/keyword_agent.py
1d776b8 verified
Raw
History Blame Contribute Delete
1.43 kB
from crewai import Agent, Task, Crew
from modules import llm_open_4m
from schemas import CourseWithQueries # فيه الـ Pydantic model بتاعك
# ==== Define Agent ====
def query_agent():
model = llm_open_4m()
return Agent(
name="SearchQueryAgent",
role="Generate 3 short, relevant search queries for each subtopic in the course",
goal=(
"For each subtopic in the course JSON, generate 3 short, precise, SEO-friendly search queries "
"related to topic. Avoid vague, repetitive, or off-topic queries."
),
backstory=(
"This agent is a research strategist for the course. It creates queries suitable for "
"web search to gather useful, relevant content for each subtopic."
),
verbose=True,
llm=model,
)
# ==== Task Definition ====
def query_task(query_agent):
return Task(
name="Generate 3 search queries in arabic and english per subtopic",
description=(
"Read the course JSON structure and generate 3 diverse queries per subtopic arabic and english "
"Course json is: {course} Queries must be concise, specific, and relevant."
"• Do NOT add explanations, comments, or text outside JSON.\n"
"• Output must be valid JSON only."
),
expected_output="A valid JSON following CourseWithQueries schema",
output_json=CourseWithQueries,
# output_file=output_file,
agent=query_agent,
)