Skip to content

Instantly share code, notes, and snippets.

@lorenzejay
Last active February 19, 2025 19:39
Show Gist options
  • Select an option

  • Save lorenzejay/7a15c7a5fffa279709129f4a139253ed to your computer and use it in GitHub Desktop.

Select an option

Save lorenzejay/7a15c7a5fffa279709129f4a139253ed to your computer and use it in GitHub Desktop.
CrewAI Rag tool set a custom vectordb
from crewai_tools import RagTool
from dotenv import load_dotenv
from crewai import Agent, Crew, Process, Task
load_dotenv()
rag_tool = RagTool(
config={
"vectordb": {
"provider": "weaviate", # add your provider: we support embedchain support vectordb providers: https://docs.embedchain.ai/components/vector-databases/
"config": {
"collection_name": "contracts_business_latest", # ENSURE YOU HAVE THE APPROPRIATE KEYS IN LOADED IN ENV like API_KEY, ENDPOINT, etc
},
}
}
)
agent = Agent(
role="Contract Analyst Agent",
goal="You know everything about the text. Ensure the {question} gets passed to the rag_tool as query and get the answer.",
backstory="""You are a master at understanding text and its details.""",
verbose=True,
allow_delegation=False,
tools=[rag_tool],
llm="gpt-4o",
)
task = Task(
description="Answer the following questions about the text: {question}.",
expected_output="An answer to the question",
agent=agent,
output_file="output.txt",
)
crew = Crew(
agents=[agent],
tasks=[task],
verbose=True,
process=Process.sequential,
memory=True,
)
result = crew.kickoff(
inputs={
"question": "What are the differences in how contracts define warranties within creditcardscominc and digitalcinemadestination, provide the sources for each of them as well",
},
)
print("result", result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment