PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

AI Tasking Agents

Go down

AI Tasking Agents Empty AI Tasking Agents

Post by jamied_uk 27th March 2024, 10:18

AI Tasking Agents


Code:
#
# (c) J~Net 2024
# jnet.sytes.net
#
# python run.py
#
from crewai import Agent, Task, Crew
import os
from langchain_openai import ChatOpenAI
from dotenv import load_dotenv
# https://jnet.forumotion.com/t2004-ai-tasking-agents#3090
#
load_dotenv()
# Set OpenAI API Key
os.environ["OPENAI_API_KEY"]="NA"

# Initialize Crew AI
llm=ChatOpenAI(
    model="openhermes:latest",
    base_url="http://localhost:11434/v1"
)

# Researcher Agent
researcher=Agent(
    role='Researcher',
    goal='Research new AI Insights',
    backstory='You are an AI research assistant',
    verbose=True,
    allow_delegation=False,
    local_model="openhermes:latest",  # Replace with your model name if different
    base_url="http://localhost:11434/v1"
)

# Writer Agent
writer=Agent(
    role='Writer',
    goal='write compelling and engaging blog posts about AI trends',
    backstory='You are an AI blog post writer who specializes in writing about AI topics',
    verbose=True,
    allow_delegation=False,
    local_model="openhermes:latest",  # Replace with your model name if different
    base_url="http://localhost:11434/v1"

)

# Create Task 1: Investigate latest AI trends
task1=Task(
    description="Investigate latest AI trends",
    agent=researcher,
    expected_output="placeholder"  # placeholder string
)

# Create Task 2: Write a blog post on latest AI trends
task2=Task(
    description="Write a blog post on latest AI trends",
    agent=writer,
    expected_output="placeholder"  # placeholder string
)


# Instantiate your crew with a sequential process
crew=Crew(
    agents=[researcher, writer],
    tasks=[task1, task2],
    verbose=2  # You can set it to 1 or 2 for different logging levels
)

result=crew.kickoff()

print(result)
jamied_uk
jamied_uk
Admin

Posts : 2952
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum