[Python] CREW AI tool not using ChatGroq

Discussão em 'Python' iniciado por Stack, Setembro 25, 2024.

  1. Stack

    Stack Membro Participativo

    Here is my tools.py file

    import os
    from dotenv import load_dotenv
    from langchain_groq import ChatGroq
    from crewai_tools import PDFSearchTool, SerperDevTool

    load_dotenv()

    # Initialize the ChatGroq model
    llm = ChatGroq(
    model="llama-3.1-70b-versatile",
    temperature=0.7,
    groq_api_key=os.getenv('GROQ_API_KEY'),
    verbose=True
    )


    os.environ['SERPER_API_KEY'] = os.getenv('SERPER_API_KEY')

    # Initialize the tool allowing for any PDF content search if the path is provided during execution
    pdf_tool = PDFSearchTool()

    # Initialize the tool for internet searching capabilities
    serper_tool = SerperDevTool()


    also I have added

    llm = ChatGroq(
    model="llama-3.1-70b-versatile",
    temperature=0.7,
    groq_api_key=os.getenv('GROQ_API_KEY'),
    verbose=True
    )


    in my agents.py also and mentioned in every Agent.

    But when I run

    python crew.py


    the error comes:


    UserWarning: Valid config keys have changed in V2:
    ​
    • 'allow_population_by_field_name' has been renamed to 'populate_by_name'
    • 'smart_union' has been removed warnings.warn(message, UserWarning) Traceback (most recent call last): File "D:\code\machine learning\Testing Models\Advance Multi Agent RAG\crew.py", line 2, in <module> from tasks import pdf_research_task, web_research_task, assistant_task File "D:\code\machine learning\Testing Models\Advance Multi Agent RAG\tasks.py", line 2, in <module> from tools import pdf_tool, serper_tool File "D:\code\machine learning\Testing Models\Advance Multi Agent RAG\tools.py", line 20, in <module> pdf_tool = PDFSearchTool() File "D:\code\machine learning\Testing Models\Advance Multi Agent RAG\myenv\lib\site-packages\crewai_tools\tools\pdf_search_tool\pdf_search_tool.py", line 32, in init super().init(**kwargs) File "D:\code\machine learning\Testing Models\Advance Multi Agent RAG\myenv\lib\site-packages\pydantic\main.py", line 193, in init self.pydantic_validator.validate_python(data, self_instance=self) File "D:\code\machine learning\Testing Models\Advance Multi Agent RAG\myenv\lib\site-packages\crewai_tools\tools\pdf_search_tool\pdf_search_tool.py", line 48, in _set_default_adapter app = App.from_config(config=self.config) if self.config else App() File "D:\code\machine learning\Testing Models\Advance Multi Agent RAG\myenv\lib\site-packages\embedchain\app.py", line 117, in init self.embedding_model = embedding_model or OpenAIEmbedder() File "D:\code\machine learning\Testing Models\Advance Multi Agent RAG\myenv\lib\site-packages\embedchain\embedder\openai.py", line 19, in init
      api_key = self.config.api_key or os.environ["OPENAI_API_KEY"] File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\os.py", line 680, in getitem raise KeyError(key) from None KeyError: 'OPENAI_API_KEY'

    Please help me

    I know about the document from crewai that I should try this way

    tool = PDFSearchTool(
    config=dict(
    llm=dict(
    provider="ollama", # or google, openai, anthropic, llama2, ...
    config=dict(
    model="llama2",
    # temperature=0.5,
    # top_p=1,
    # stream=true,
    ),
    ),
    embedder=dict(
    provider="google", # or openai, ollama, ...
    config=dict(
    model="models/embedding-001",
    task_type="retrieval_document",
    # title="Embeddings",
    ),
    ),
    )
    )


    But how to use ChatGroq with it.

    Continue reading...

Compartilhe esta Página