File size: 1,426 Bytes
325b94c
1d776b8
325b94c
 
 
 
1d776b8
325b94c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55620e6
 
325b94c
 
 
 
 
 
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 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,
)