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
20.62k stars 2.86k forks source link

Issue in reading through csv file using OLLAMA #586

Closed mustangs0786 closed 2 months ago

mustangs0786 commented 5 months ago

from crewai_tools import CSVSearchTool tool = CSVSearchTool(csv='record.csv', config=dict( llm=dict( provider="ollama", config=dict( model="llama2",

temperature=0.5,

            # top_p=1,
            # stream=true,
        ),
    ),
    embedder=dict(
        provider="ollama",
        config=dict(
            model="llama2",
            #task_type="retrieval_document",
            # title="Embeddings",
        ),
    ),
)

)

Trip planner

import os from crewai import Agent, Task, Crew, Process from crewai_tools import SerperDevTool

from langchain.llms import Ollama ollama_llm = Ollama(model="llama2",temperature=0)

Define your agents with roles and goals

csv_agent = Agent( role='Master in analyzing csv file', goal='Select all information about given emp_id ', backstory='An expert in analyzing csv files', verbose=True, allow_delegation=True, tools=[tool], llm = ollama_llm, system_template = )

identify_task = Task(

description=f"""

extract all information related to search_query : 2633 """,

expected_output="""concise summary.""",

agent=csv_agent,

)

Instantiate your crew with a sequential process

crew = Crew( agents=[ csv_agent ], tasks=[identify_task], verbose=True )

Get your crew to work!

result = crew.kickoff()

########## Output

ction: Search a CSV's content(search_query: '2633') Action Input: {'emp_id': 2633}

Action 'Search a CSV's content(search_query: '2633')' don't exist, these are the only available Actions: Search a CSV's content: Search a CSV's content(search_query: 'string') - A tool that can be used to semantic search a query the cpml_updated.csv CSV's content.

Please help me where i am doing wrong... thanks

slavakurilyak commented 5 months ago

You need to attach the LLM to the Agent, not the Tool

Refer to crewAI docs to learn more

mustangs0786 commented 5 months ago

Thanks for replying but i am attaching LLM to agent only , can you please elaborate more thanks. hoping for faster reply. thanks

slavakurilyak commented 5 months ago

You only need csv as input for this tool, as per crewAI-tools

config is not necessary for crewAI tools

mustangs0786 commented 5 months ago

why i put config because it is require otherwise by defualt it will use gpt.

can you please provide a sample working example.. thanks

danielgen commented 5 months ago

@mustangs0786 just use a modelfile following documentation and then reference the model, e.g.:

from langchain_openai import ChatOpenAI
import os 

os.environ["OPENAI_API_KEY"] = ""

ollama_llm = ChatOpenAI(
                 model_name='crewai-llama2',
                 base_url = "http://localhost:11434/v1"
          ) 
mustangs0786 commented 5 months ago

from langchain.llms import Ollama ollama_llm = Ollama(model="llama2",temperature=0)

from langchain.llms import Ollama ollama_llm = Ollama(model="llama2",temperature=0)

is above way of using ollama model and what you mentioned is different or same??

github-actions[bot] commented 2 months 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 2 months ago

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