|
| 1 | +from crewai import Agent, Task, Crew, Process, LLM |
| 2 | + |
| 3 | +llm = LLM(model="ollama/llama3.2:latest", base_url="http://localhost:11434", temperature=0.8, timeout=300) |
| 4 | + |
| 5 | +# Define the Prompt Supervisor agent |
| 6 | +prompt_supervisor = Agent( |
| 7 | + role='Prompt Supervisor', |
| 8 | + goal='Ensure all agent prompts are clear, effective, and aligned with users objectives.', |
| 9 | + backstory=( |
| 10 | + "As a Prompt Supervisor, you have a keen eye for detail and a deep understanding " |
| 11 | + "of effective communication strategies. Your mission is to review and refine prompts " |
| 12 | + "to maximize the performance of AI agents." |
| 13 | + ), |
| 14 | + llm=llm |
| 15 | +) |
| 16 | + |
| 17 | +# Define a task for the Prompt Supervisor to review and enhance the Senior Researcher's prompt |
| 18 | +prompt_supervisor_task = Task( |
| 19 | + description=( |
| 20 | + "Review the prompt provided to the {topic} Senior prompt supervisor, assessing its clarity, " |
| 21 | + "effectiveness, and alignment with the project's objectives. Provide constructive feedback " |
| 22 | + "and suggest improvements to enhance the agent's performance." |
| 23 | + ), |
| 24 | + expected_output=( |
| 25 | + "A detailed evaluation of the original prompt, including specific suggestions for improvement " |
| 26 | + "and a revised version of the prompt that optimizes clarity and effectiveness along with few shot of examples." |
| 27 | + ), |
| 28 | + agent=prompt_supervisor |
| 29 | +) |
| 30 | + |
| 31 | + |
| 32 | +def main(): |
| 33 | + # Forming the crew and kicking off the process |
| 34 | + crew = Crew( |
| 35 | + agents=[prompt_supervisor], |
| 36 | + tasks=[prompt_supervisor_task], |
| 37 | + process=Process.sequential, |
| 38 | + verbose=True |
| 39 | + ) |
| 40 | + result = crew.kickoff(inputs={'topic': 'Get Financial data for 2023'}) |
| 41 | + print(result) |
| 42 | + |
| 43 | + |
| 44 | +if __name__ == "__main__": |
| 45 | + main() |
0 commit comments