crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

Agents are not giving response from Tools

Open Neethan54 opened this issue 1 year ago • 5 comments

Hi , I am using LANGCHAIN Tool as tools for agents.

And the final agent is not answering from the Tools. It is giving results generally, those results are not available in any of the documents uploaded.

ret_qa=RetrievalQA.from_chain_type(llm=llm ,retriever=retriever,chain_type="stuff",chain_type_kwargs=chain_type_kwargs,return_source_documents=True)

search_tool=Tool(
        name='Directory Vector Database',
        description=f"Contains all the information from the user uploaded documents.",
        func=ret_qa)


# Create a content retriever agent
retriever = Agent(
    role='Content Retriever',
    goal='Retrieve relevant content about "{topic}" from the base documents using tool. Make sure extracted content should be from the documents from Tools',  #The retriever agent should retrieve information about {topic} from the base documents using RAG tool.
    verbose=True,
    memory=True,
    backstory=(
        "You are skilled at extracting the right information from documents. "
        "Your ability to find and retrieve relevant content ensures accurate and comprehensive reports."
    ),
    tools=[search_tool],
    llm=llm
)

# Create a content writer agent
writer = Agent(
    role='Content Writer',
    goal='Write a detailed report on the on {topic} using the extracted content',
    verbose=True,
    memory=True,
    backstory=(
        "With a knack for creating detailed and informative reports, you excel at writing content "
        "that is both engaging and comprehensive. You utilize the extracted content to provide "
        "well-rounded reports."
    ),
    tools=[search_tool],
    llm=llm
)

# Define the retriever task
retriever_task = Task(
    description=(
        "Retrieve relevant content from the provided documents based on '{topic}' using Tools. "
        "Ensure that the extracted content is comprehensive and relevant to the topic."
        "Make sure the extracted content is  only from the tools."
    ),
    expected_output='Extracted content relevant to the topic',
    tools=[search_tool],
    agent=retriever,
    output_file='detailed_report1.txt'
)

# Define the writer task
writer_task = Task(
    description=(
        "Write a detailed report on {topic} using the extracted content provided by the retriever agent. "
        "If no possible answers say '{topic} is not mentioned in uploaded documents'."
        "The report should be informative and cover all the necessary aspects of the topic."
        "Make sure the details in the report belongs to documents provided from the tools."
        "Provide the source of information at the end."
        "Dont mention words like, 'The document includes'"
    ),
    expected_output='A detailed report on the topic',
    tools=[search_tool],
    agent=writer,
    async_execution=False,
    output_file='detailed_report2.txt'  # Example of output customization
)

# Form the crew with both agents and tasks
crew = Crew(
    agents=[retriever, writer],
    tasks=[retriever_task, writer_task],
    process=Process.sequential
)

# Kickoff the crew with user input for the topic

topic= 'Types of Orifice Plates'      

result = crew.kickoff(inputs={'topic': topic})

Let me know how to make agents give answers only from the Tools or uploaded Documents.

Thanks

Neethan54 avatar Jun 29 '24 07:06 Neethan54

I am also getting similar issue. The agents are not giving answers from the tools. I don't even know if the agents are using the tools or not.

infinite-Joy avatar Jul 07 '24 14:07 infinite-Joy

Can you update to the latest version of crewai

pip uninstall crewai crew-tools

pip install --no-cache-dir crewai crew-tools

And let us know if that fixes it

theCyberTech avatar Jul 07 '24 15:07 theCyberTech

Hi @theCyberTech , I tried with latest version also, Still im getting the results out of the Tools provided.

This is the version currently im using. crewai==0.36.0 crewai-tools==0.4.7

Neethan54 avatar Jul 08 '24 04:07 Neethan54

Hi @theCyberTech , I tried with latest version also, Still im getting the results out of the Tools provided.

This is the version currently im using. crewai==0.36.0 crewai-tools==0.4.7

Just to be sure you have done the following:

pip uninstall crewai crew-tools

pip install --no-cache-dir crewai crew-tools

If you have then you might want to revisit your prompts for the agents role goal backstory and the tasks description.

Can you upload your Whole code as I would like to see your imports ect

theCyberTech avatar Jul 08 '24 04:07 theCyberTech

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Aug 10 '24 12:08 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Aug 16 '24 12:08 github-actions[bot]