crewAIInc / crewAI

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
https://crewai.com
MIT License
18.69k stars 2.58k forks source link

Agents are not giving response from Tools #832

Closed Neethan54 closed 1 week ago

Neethan54 commented 2 months ago

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

infinite-Joy commented 1 month ago

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.

theCyberTech commented 1 month ago

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

Neethan54 commented 1 month ago

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

theCyberTech commented 1 month ago

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

github-actions[bot] commented 2 weeks ago

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] commented 1 week ago

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