| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import os
- from crewai import Agent, Task, Crew, Process
- from langchain.llms import Ollama
- ollama_hermes = Ollama(model="openhermes")
- # Define your tools, custom or not.
- # Install duckduckgo-search for this example:
- #
- # !pip install -U duckduckgo-search
- from langchain.tools import DuckDuckGoSearchRun
- search_tool = DuckDuckGoSearchRun()
- # Define your agents with roles and goals
- researcher = Agent(
- role='Game Researcher',
- goal='Explore innovative developments in the gaming industry, focusing on',
- backstory="""You are a Game Researcher at a renowned gaming think tank.
- Your expertise lies in identifying emerging trends and technologies in the gaming world.
- You have a passion for dissecting complex game mechanics and presenting actionable insights.""",
- verbose=True,
- allow_delegation=False,
- tools=[search_tool],
- llm=ollama_hermes,
- # llm=OpenAI(temperature=0.7, model_name="gpt-4"). It uses langchain.chat_models, default is GPT4
- )
- writer = Agent(
- role='Game Content Strategist',
- goal='Craft compelling content on game advancements',
- backstory="""You are a renowned Game Content Strategist, known for your insightful
- and engaging articles on technology and innovation in games. With a deep understanding of
- the tech industry, you transform complex concepts into compelling narratives.""",
- verbose=True,
- allow_delegation=True,
- llm=ollama_hermes,
- )
- # Create tasks for your agents
- task1 = Task(
- description="""Conduct a comprehensive analysis of the latest role playing game Starfield from Bethesda.
- Identify quest lines, amount of hours it takes to complete, breakthrough technologies, the positive and negative responses it got and potential future DLC.
- Compile your findings in a detailed report. Your final answer MUST be a full analysis report""",
- agent=researcher
- )
- task2 = Task(
- description="""Using the insights from the researcher's report, develop an engaging blog
- post that highlights of the game Startfield.
- Your post should be informative yet accessible, catering to a tech-savvy audience.
- Aim for a narrative that captures the essence of these game.
- Your final answer MUST be the full blog post of at least 3 paragraphs.""",
- agent=writer
- )
- # Instantiate your crew with a sequential process
- crew = Crew(
- agents=[researcher, writer],
- tasks=[task1, task2],
- llm=ollama_hermes,
- verbose=2, # Crew verbose more will let you know what tasks are being worked on, you can set it to 1 or 2 to different logging levels
- process=Process.sequential # Sequential process will have tasks executed one after the other and the outcome of the previous one is passed as extra content into this next.
- )
- # Get your crew to work!
- result = crew.kickoff()
- print("######################")
- print(result)
|