crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

Adding human input example to README and docs

Open joaomdmoura opened this issue 1 year ago • 5 comments

One can easily use human input as tool by using the langchain tool but would be nice to add proper docs around it as it seem a usual use case

from langchain.agents import load_tool
tools = load_tools(["human"])

joaomdmoura avatar Jan 05 '24 16:01 joaomdmoura

Hey, I am looking to solve this issue. Can you assign it to me. and also help me contribute to it.

siddartha-10 avatar Jan 05 '24 17:01 siddartha-10

Sure thing, just did! Maybe we start just adding a section on the readme with a small example and a link on top. Also something we could add to the wiki. @greysonlalonde is working on a new docs so he might be able to help as well :)

joaomdmoura avatar Jan 05 '24 17:01 joaomdmoura

Hey quick question

from langchain.agents import load_tool
tools = load_tools(["human"])

after doing this we just have add this as tool in our agent right?

Example

```python
researcher = Agent(
  role='Senior Research Analyst',
  goal='Uncover cutting-edge developments in AI and data science in',
  backstory="""You are a Senior Research Analyst at a leading tech think tank.
  Your expertise lies in identifying emerging trends and technologies in AI and
  data science. You have a knack for dissecting complex data and presenting
  actionable insights.""",
  verbose=True,
  allow_delegation=False,
  tools=tools,
  llm=ChatOpenAI(temperature=0.7, model_name="gpt-4") #It uses langchain.chat_models, default is GPT4
)


siddartha-10 avatar Jan 05 '24 18:01 siddartha-10

Hi @siddartha-10 , tools are located in langchain.agents.load_tools in langchain v0.0.354:

from langchain.agents.load_tools import load_tools

As @joaomdmoura mentioned, happy to help with anything else!

greysonlalonde avatar Jan 05 '24 18:01 greysonlalonde

Hey @greysonlalonde This an example of using human as an agent.

from langchain.agents import load_tools
from langchain_community.chat_models import ChatOpenAI
from langchain_community.llms import OpenAI
import os
from crewai import Agent, Task, Crew, Process

os.environ["OPENAI_API_KEY"] = ""

llm = ChatOpenAI(temperature=0.0,model="gpt-3.5-turbo")
tools = load_tools(
    ["human"]
)


agent = Agent(
  role='Human',
  goal='Provide context when the Agents need me',
  backstory="I am a human, I am here to help the Agents",
  tools=tools
)

task1 = Task(
  description="""Give me a hook to write a story? and ask the human to give you a hook to write a story""",
  agent=agent
)

task2 = Task(
  description="""what is the name of the characters? you should ask the human to give you the name of the char""",
  agent=agent
)

task3 = Task(
    description="""Include the character names and involve them in your story.""",
    agent=agent,
)

crew = Crew(
  agents=[agent],
  tasks=[task1,task2,task3],
  verbose=3, # 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.
)

print(crew.kickoff())

I have cloned the wiki pages locally and do you want me to add this to the document? https://python.langchain.com/docs/integrations/tools/human_tools and also add this link on top of the document

siddartha-10 avatar Jan 05 '24 19:01 siddartha-10

Added, thanks @siddartha-10 for prompting us to do it and coming up with an initial version!

joaomdmoura avatar Jan 06 '24 04:01 joaomdmoura

Hey @joaomdmoura I am learning a lot these days and interested in using agents for different applications and use cases, I am a master's student, It would be great if you can mentor and help me be on the right path.

siddartha-10 avatar Jan 06 '24 04:01 siddartha-10