mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
Knowledge (#1567)
* initial knowledge * WIP * Adding core knowledge sources * Improve types and better support for file paths * added additional sources * fix linting * update yaml to include optional deps * adding in lorenze feedback * ensure embeddings are persisted * improvements all around Knowledge class * return this * properly reset memory * properly reset memory+knowledge * consolodation and improvements * linted * cleanup rm unused embedder * fix test * fix duplicate * generating cassettes for knowledge test * updated default embedder * None embedder to use default on pipeline cloning * improvements * fixed text_file_knowledge * mypysrc fixes * type check fixes * added extra cassette * just mocks * linted * mock knowledge query to not spin up db * linted * verbose run * put a flag * fix * adding docs * better docs * improvements from review * more docs * linted * rm print * more fixes * clearer docs * added docstrings and type hints for cli --------- Co-authored-by: João Moura <joaomdmoura@gmail.com> Co-authored-by: Lorenze Jay <lorenzejaytech@gmail.com>
This commit is contained in:
committed by
GitHub
parent
fde1ee45f9
commit
14a36d3f5e
@@ -10,10 +10,11 @@ from crewai import Agent, Crew, Task
|
||||
from crewai.agents.cache import CacheHandler
|
||||
from crewai.agents.crew_agent_executor import CrewAgentExecutor
|
||||
from crewai.agents.parser import AgentAction, CrewAgentParser, OutputParserException
|
||||
from crewai.knowledge.source.string_knowledge_source import StringKnowledgeSource
|
||||
from crewai.llm import LLM
|
||||
from crewai.tools import tool
|
||||
from crewai.tools.tool_calling import InstructorToolCalling
|
||||
from crewai.tools.tool_usage import ToolUsage
|
||||
from crewai.tools import tool
|
||||
from crewai.tools.tool_usage_events import ToolUsageFinished
|
||||
from crewai.utilities import RPMController
|
||||
from crewai.utilities.events import Emitter
|
||||
@@ -1574,3 +1575,42 @@ def test_agent_execute_task_with_ollama():
|
||||
result = agent.execute_task(task)
|
||||
assert len(result.split(".")) == 2
|
||||
assert "AI" in result or "artificial intelligence" in result.lower()
|
||||
|
||||
|
||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||
def test_agent_with_knowledge_sources():
|
||||
# Create a knowledge source with some content
|
||||
content = "Brandon's favorite color is blue and he likes Mexican food."
|
||||
string_source = StringKnowledgeSource(
|
||||
content=content, metadata={"preference": "personal"}
|
||||
)
|
||||
|
||||
|
||||
with patch('crewai.knowledge.storage.knowledge_storage.KnowledgeStorage') as MockKnowledge:
|
||||
mock_knowledge_instance = MockKnowledge.return_value
|
||||
mock_knowledge_instance.sources = [string_source]
|
||||
mock_knowledge_instance.query.return_value = [{
|
||||
"content": content,
|
||||
"metadata": {"preference": "personal"}
|
||||
}]
|
||||
|
||||
agent = Agent(
|
||||
role="Information Agent",
|
||||
goal="Provide information based on knowledge sources",
|
||||
backstory="You have access to specific knowledge sources.",
|
||||
llm=LLM(model="gpt-4o-mini"),
|
||||
)
|
||||
|
||||
# Create a task that requires the agent to use the knowledge
|
||||
task = Task(
|
||||
description="What is Brandon's favorite color?",
|
||||
expected_output="Brandon's favorite color.",
|
||||
agent=agent,
|
||||
)
|
||||
|
||||
crew = Crew(agents=[agent], tasks=[task])
|
||||
result = crew.kickoff()
|
||||
|
||||
# Assert that the agent provides the correct information
|
||||
assert "blue" in result.raw.lower()
|
||||
|
||||
|
||||
115
tests/cassettes/test_agent_with_knowledge_sources.yaml
Normal file
115
tests/cassettes/test_agent_with_knowledge_sources.yaml
Normal file
@@ -0,0 +1,115 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '{"messages": [{"role": "system", "content": "You are Information Agent.
|
||||
You have access to specific knowledge sources.\nYour personal goal is: Provide
|
||||
information based on knowledge sources\nTo give my best complete final answer
|
||||
to the task use the exact following format:\n\nThought: I now can give a great
|
||||
answer\nFinal Answer: Your final answer must be the great and the most complete
|
||||
as possible, it must be outcome described.\n\nI MUST use these formats, my job
|
||||
depends on it!"}, {"role": "user", "content": "\nCurrent Task: What is Brandon''s
|
||||
favorite color?\n\nThis is the expect criteria for your final answer: Brandon''s
|
||||
favorite color.\nyou MUST return the actual complete content as the final answer,
|
||||
not a summary.\n\nBegin! This is VERY important to you, use the tools available
|
||||
and give your best Final Answer, your job depends on it!\n\nThought:"}], "model":
|
||||
"gpt-4o-mini", "stop": ["\nObservation:"], "stream": false}'
|
||||
headers:
|
||||
accept:
|
||||
- application/json
|
||||
accept-encoding:
|
||||
- gzip, deflate
|
||||
connection:
|
||||
- keep-alive
|
||||
content-length:
|
||||
- '931'
|
||||
content-type:
|
||||
- application/json
|
||||
host:
|
||||
- api.openai.com
|
||||
user-agent:
|
||||
- OpenAI/Python 1.52.1
|
||||
x-stainless-arch:
|
||||
- arm64
|
||||
x-stainless-async:
|
||||
- 'false'
|
||||
x-stainless-lang:
|
||||
- python
|
||||
x-stainless-os:
|
||||
- MacOS
|
||||
x-stainless-package-version:
|
||||
- 1.52.1
|
||||
x-stainless-raw-response:
|
||||
- 'true'
|
||||
x-stainless-retry-count:
|
||||
- '0'
|
||||
x-stainless-runtime:
|
||||
- CPython
|
||||
x-stainless-runtime-version:
|
||||
- 3.11.9
|
||||
method: POST
|
||||
uri: https://api.openai.com/v1/chat/completions
|
||||
response:
|
||||
body:
|
||||
string: !!binary |
|
||||
H4sIAAAAAAAAA4xSQW7bMBC86xULXnqxAtmxI1e3FEWBtJekCXJpC4GmVhIdapcgqbhN4L8HlB1L
|
||||
QVOgFwGa2RnOLPmcAAhdiQKEamVQnTXp5f3d9lsdbndh++C+757Or6/bm6uvn59WH/FGzKKCN1tU
|
||||
4VV1prizBoNmOtDKoQwYXef5+SK7WK3ny4HouEITZY0N6ZLTTpNOF9limWZ5Ol8f1S1rhV4U8CMB
|
||||
AHgevjEnVfhbFJDNXpEOvZcNiuI0BCAcm4gI6b32QVIQs5FUTAFpiH4FxDtQkqDRjwgSmhgbJPkd
|
||||
OoCf9EWTNHA5/BfwyUmqmD54qOUjOx0QFBt2oD1sTI9n02Mc1r2XsSr1xhzx/Sm34cY63vgjf8Jr
|
||||
Tdq3pUPpmWJGH9iKgd0nAL+G/fRvKgvruLOhDPyAFA3nF/nBT4zXMmHXRzJwkGaKr2bv+JUVBqmN
|
||||
n2xYKKlarEbpeB2yrzRPiGTS+u8073kfmmtq/sd+JJRCG7AqrcNKq7eNxzGH8dX+a+y05SGw8H98
|
||||
wK6sNTXorNOHN1PbMsuz1aZe5yoTyT55AQAA//8DAPaYLdRBAwAA
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 8e54a2a7d81467f7-SJC
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Wed, 20 Nov 2024 01:23:34 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=DoHo1Z11nN9bxkwZmJGnaxRhyrWE0UfyimYuUVRU6A4-1732065814-1.0.1.1-JVRvFrIJLHEq9OaFQS0qcgYcawE7t2XQ4Tpqd58n2Yfx3mvEqD34MJmooi1LtvdvjB2J8x1Rs.rCdXD.msLlKw;
|
||||
path=/; expires=Wed, 20-Nov-24 01:53:34 GMT; domain=.api.openai.com; HttpOnly;
|
||||
Secure; SameSite=None
|
||||
- _cfuvid=n3RrNhFMqC3HtJ7n3e3agyxnM1YOQ6eKESz_eeXLtZA-1732065814630-0.0.1.1-604800000;
|
||||
path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
access-control-expose-headers:
|
||||
- X-Request-ID
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
openai-organization:
|
||||
- crewai-iuxna1
|
||||
openai-processing-ms:
|
||||
- '344'
|
||||
openai-version:
|
||||
- '2020-10-01'
|
||||
strict-transport-security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
x-ratelimit-limit-requests:
|
||||
- '30000'
|
||||
x-ratelimit-limit-tokens:
|
||||
- '150000000'
|
||||
x-ratelimit-remaining-requests:
|
||||
- '29999'
|
||||
x-ratelimit-remaining-tokens:
|
||||
- '149999790'
|
||||
x-ratelimit-reset-requests:
|
||||
- 2ms
|
||||
x-ratelimit-reset-tokens:
|
||||
- 0s
|
||||
x-request-id:
|
||||
- req_8f1622677c64913753a595f679596614
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
232
tests/cassettes/test_kickoff_for_each_error_handling.yaml
Normal file
232
tests/cassettes/test_kickoff_for_each_error_handling.yaml
Normal file
@@ -0,0 +1,232 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: !!binary |
|
||||
Cv1YCiQKIgoMc2VydmljZS5uYW1lEhIKEGNyZXdBSS10ZWxlbWV0cnkS1FgKEgoQY3Jld2FpLnRl
|
||||
bGVtZXRyeRLADQoQ5TzgW9QzcBbzMl1hJozLcxIIl3adf7U81wwqDENyZXcgQ3JlYXRlZDABOaAJ
|
||||
txhffgkYQfiVuRhffgkYShoKDmNyZXdhaV92ZXJzaW9uEggKBjAuODAuMEoaCg5weXRob25fdmVy
|
||||
c2lvbhIICgYzLjEyLjVKLgoIY3Jld19rZXkSIgogM2Y4ZDVjM2FiODgyZDY4NjlkOTNjYjgxZjBl
|
||||
MmVkNGFKMQoHY3Jld19pZBImCiRjYjRiY2Q1Zi0xYWJkLTQyYmYtOGQ1OC02ZmEzMDU3ZDFjOTZK
|
||||
HAoMY3Jld19wcm9jZXNzEgwKCnNlcXVlbnRpYWxKEQoLY3Jld19tZW1vcnkSAhAAShoKFGNyZXdf
|
||||
bnVtYmVyX29mX3Rhc2tzEgIYA0obChVjcmV3X251bWJlcl9vZl9hZ2VudHMSAhgCSpIFCgtjcmV3
|
||||
X2FnZW50cxKCBQr/BFt7ImtleSI6ICI4YmQyMTM5YjU5NzUxODE1MDZlNDFmZDljNDU2M2Q3NSIs
|
||||
ICJpZCI6ICI1ZThjNTM1MS1jNWVlLTRhZGUtODY5MC1kM2RhOWI1NzI5YzciLCAicm9sZSI6ICJS
|
||||
ZXNlYXJjaGVyIiwgInZlcmJvc2U/IjogZmFsc2UsICJtYXhfaXRlciI6IDIwL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bGUi
|
||||
OiAie3RvcGljfSBSZXNlYXJjaGVyIiwgInZlcmJvc2U/IjogZmFsc2UsICJtYXhfaXRlciI6IDIw
|
||||
LCAibWF4X3JwbSI6IG51bGwsICJmdW5jdGlvbl9jYWxsaW5nX2xsbSI6ICIiLCAibGxtIjogImdw
|
||||
dC00by1taW5pIiwgImRlbGVnYXRpb25fZW5hYmxlZD8iOiBmYWxzZSwgImFsbG93X2NvZGVfZXhl
|
||||
Y3V0aW9uPyI6IGZhbHNlLCAibWF4X3JldHJ5X2xpbWl0IjogMiwgInRvb2xzX25hbWVzIjogW119
|
||||
XUqHAgoKY3Jld190YXNrcxL4AQr1AVt7ImtleSI6ICIwNmE3MzIyMGY0MTQ4YTRiYmQ1YmFjYjBk
|
||||
MGI0NGZjZSIsICJpZCI6ICJjZWZiYjE1ZS01Y2M4LTQwZTctYTViMS03ODkzYjJlZGFkYmQiLCAi
|
||||
YXN5bmNfZXhlY3V0aW9uPyI6IGZhbHNlLCAiaHVtYW5faW5wdXQ/IjogZmFsc2UsICJhZ2VudF9y
|
||||
b2xlIjogInt0b3BpY30gUmVzZWFyY2hlciIsICJhZ2VudF9rZXkiOiAiZjMzODZmNmQ4ZGE3NWFh
|
||||
NDE2YTZlMzEwMDUzZjc2OTgiLCAidG9vbHNfbmFtZXMiOiBbXX1degIYAYUBAAEAAA==
|
||||
headers:
|
||||
Accept:
|
||||
- '*/*'
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '11392'
|
||||
Content-Type:
|
||||
- application/x-protobuf
|
||||
User-Agent:
|
||||
- OTel-OTLP-Exporter-Python/1.27.0
|
||||
method: POST
|
||||
uri: https://telemetry.crewai.com:4319/v1/traces
|
||||
response:
|
||||
body:
|
||||
string: "\n\0"
|
||||
headers:
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/x-protobuf
|
||||
Date:
|
||||
- Tue, 19 Nov 2024 22:14:39 GMT
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
0
tests/knowledge/__init__.py
Normal file
0
tests/knowledge/__init__.py
Normal file
BIN
tests/knowledge/crewai_quickstart.pdf
Normal file
BIN
tests/knowledge/crewai_quickstart.pdf
Normal file
Binary file not shown.
545
tests/knowledge/knowledge_test.py
Normal file
545
tests/knowledge/knowledge_test.py
Normal file
@@ -0,0 +1,545 @@
|
||||
"""Test Knowledge creation and querying functionality."""
|
||||
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from crewai.knowledge.source.csv_knowledge_source import CSVKnowledgeSource
|
||||
from crewai.knowledge.source.excel_knowledge_source import ExcelKnowledgeSource
|
||||
from crewai.knowledge.source.json_knowledge_source import JSONKnowledgeSource
|
||||
from crewai.knowledge.source.pdf_knowledge_source import PDFKnowledgeSource
|
||||
from crewai.knowledge.source.string_knowledge_source import StringKnowledgeSource
|
||||
from crewai.knowledge.source.text_file_knowledge_source import TextFileKnowledgeSource
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_vector_db():
|
||||
"""Mock vector database operations."""
|
||||
with patch("crewai.knowledge.storage.knowledge_storage.KnowledgeStorage") as mock:
|
||||
# Mock the query method to return a predefined response
|
||||
instance = mock.return_value
|
||||
instance.query.return_value = [
|
||||
{
|
||||
"context": "Brandon's favorite color is blue and he likes Mexican food.",
|
||||
"score": 0.9,
|
||||
}
|
||||
]
|
||||
instance.reset.return_value = None
|
||||
yield instance
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def reset_knowledge_storage(mock_vector_db):
|
||||
"""Fixture to reset knowledge storage before each test."""
|
||||
yield
|
||||
|
||||
|
||||
def test_single_short_string(mock_vector_db):
|
||||
# Create a knowledge base with a single short string
|
||||
content = "Brandon's favorite color is blue and he likes Mexican food."
|
||||
string_source = StringKnowledgeSource(
|
||||
content=content, metadata={"preference": "personal"}
|
||||
)
|
||||
mock_vector_db.sources = [string_source]
|
||||
mock_vector_db.query.return_value = [{"context": content, "score": 0.9}]
|
||||
# Perform a query
|
||||
query = "What is Brandon's favorite color?"
|
||||
results = mock_vector_db.query(query)
|
||||
|
||||
# Assert that the results contain the expected information
|
||||
assert any("blue" in result["context"].lower() for result in results)
|
||||
# Verify the mock was called
|
||||
mock_vector_db.query.assert_called_once()
|
||||
|
||||
|
||||
# @pytest.mark.vcr(filter_headers=["authorization"])
|
||||
def test_single_2k_character_string(mock_vector_db):
|
||||
# Create a 2k character string with various facts about Brandon
|
||||
content = (
|
||||
"Brandon is a software engineer who lives in San Francisco. "
|
||||
"He enjoys hiking and often visits the trails in the Bay Area. "
|
||||
"Brandon has a pet dog named Max, who is a golden retriever. "
|
||||
"He loves reading science fiction books, and his favorite author is Isaac Asimov. "
|
||||
"Brandon's favorite movie is Inception, and he enjoys watching it with his friends. "
|
||||
"He is also a fan of Mexican cuisine, especially tacos and burritos. "
|
||||
"Brandon plays the guitar and often performs at local open mic nights. "
|
||||
"He is learning French and plans to visit Paris next year. "
|
||||
"Brandon is passionate about technology and often attends tech meetups in the city. "
|
||||
"He is also interested in AI and machine learning, and he is currently working on a project related to natural language processing. "
|
||||
"Brandon's favorite color is blue, and he often wears blue shirts. "
|
||||
"He enjoys cooking and often tries new recipes on weekends. "
|
||||
"Brandon is a morning person and likes to start his day with a run in the park. "
|
||||
"He is also a coffee enthusiast and enjoys trying different coffee blends. "
|
||||
"Brandon is a member of a local book club and enjoys discussing books with fellow members. "
|
||||
"He is also a fan of board games and often hosts game nights at his place. "
|
||||
"Brandon is an advocate for environmental conservation and volunteers for local clean-up drives. "
|
||||
"He is also a mentor for aspiring software developers and enjoys sharing his knowledge with others. "
|
||||
"Brandon's favorite sport is basketball, and he often plays with his friends on weekends. "
|
||||
"He is also a fan of the Golden State Warriors and enjoys watching their games. "
|
||||
)
|
||||
string_source = StringKnowledgeSource(
|
||||
content=content, metadata={"preference": "personal"}
|
||||
)
|
||||
mock_vector_db.sources = [string_source]
|
||||
mock_vector_db.query.return_value = [{"context": content, "score": 0.9}]
|
||||
|
||||
# Perform a query
|
||||
query = "What is Brandon's favorite movie?"
|
||||
results = mock_vector_db.query(query)
|
||||
|
||||
# Assert that the results contain the expected information
|
||||
assert any("inception" in result["context"].lower() for result in results)
|
||||
mock_vector_db.query.assert_called_once()
|
||||
|
||||
|
||||
def test_multiple_short_strings(mock_vector_db):
|
||||
# Create multiple short string sources
|
||||
contents = [
|
||||
"Brandon loves hiking.",
|
||||
"Brandon has a dog named Max.",
|
||||
"Brandon enjoys painting landscapes.",
|
||||
]
|
||||
string_sources = [
|
||||
StringKnowledgeSource(content=content, metadata={"preference": "personal"})
|
||||
for content in contents
|
||||
]
|
||||
|
||||
# Mock the vector db query response
|
||||
mock_vector_db.query.return_value = [
|
||||
{"context": "Brandon has a dog named Max.", "score": 0.9}
|
||||
]
|
||||
|
||||
mock_vector_db.sources = string_sources
|
||||
|
||||
# Perform a query
|
||||
query = "What is the name of Brandon's pet?"
|
||||
results = mock_vector_db.query(query)
|
||||
|
||||
# Assert that the correct information is retrieved
|
||||
assert any("max" in result["context"].lower() for result in results)
|
||||
# Verify the mock was called
|
||||
mock_vector_db.query.assert_called_once()
|
||||
|
||||
|
||||
def test_multiple_2k_character_strings(mock_vector_db):
|
||||
# Create multiple 2k character strings with various facts about Brandon
|
||||
contents = [
|
||||
(
|
||||
"Brandon is a software engineer who lives in San Francisco. "
|
||||
"He enjoys hiking and often visits the trails in the Bay Area. "
|
||||
"Brandon has a pet dog named Max, who is a golden retriever. "
|
||||
"He loves reading science fiction books, and his favorite author is Isaac Asimov. "
|
||||
"Brandon's favorite movie is Inception, and he enjoys watching it with his friends. "
|
||||
"He is also a fan of Mexican cuisine, especially tacos and burritos. "
|
||||
"Brandon plays the guitar and often performs at local open mic nights. "
|
||||
"He is learning French and plans to visit Paris next year. "
|
||||
"Brandon is passionate about technology and often attends tech meetups in the city. "
|
||||
"He is also interested in AI and machine learning, and he is currently working on a project related to natural language processing. "
|
||||
"Brandon's favorite color is blue, and he often wears blue shirts. "
|
||||
"He enjoys cooking and often tries new recipes on weekends. "
|
||||
"Brandon is a morning person and likes to start his day with a run in the park. "
|
||||
"He is also a coffee enthusiast and enjoys trying different coffee blends. "
|
||||
"Brandon is a member of a local book club and enjoys discussing books with fellow members. "
|
||||
"He is also a fan of board games and often hosts game nights at his place. "
|
||||
"Brandon is an advocate for environmental conservation and volunteers for local clean-up drives. "
|
||||
"He is also a mentor for aspiring software developers and enjoys sharing his knowledge with others. "
|
||||
"Brandon's favorite sport is basketball, and he often plays with his friends on weekends. "
|
||||
"He is also a fan of the Golden State Warriors and enjoys watching their games. "
|
||||
)
|
||||
* 2, # Repeat to ensure it's 2k characters
|
||||
(
|
||||
"Brandon loves traveling and has visited over 20 countries. "
|
||||
"He is fluent in Spanish and often practices with his friends. "
|
||||
"Brandon's favorite city is Barcelona, where he enjoys the architecture and culture. "
|
||||
"He is a foodie and loves trying new cuisines, with a particular fondness for sushi. "
|
||||
"Brandon is an avid cyclist and participates in local cycling events. "
|
||||
"He is also a photographer and enjoys capturing landscapes and cityscapes. "
|
||||
"Brandon is a tech enthusiast and follows the latest trends in gadgets and software. "
|
||||
"He is also a fan of virtual reality and owns a VR headset. "
|
||||
"Brandon's favorite book is 'The Hitchhiker's Guide to the Galaxy'. "
|
||||
"He enjoys watching documentaries and learning about history and science. "
|
||||
"Brandon is a coffee lover and has a collection of coffee mugs from different countries. "
|
||||
"He is also a fan of jazz music and often attends live performances. "
|
||||
"Brandon is a member of a local running club and participates in marathons. "
|
||||
"He is also a volunteer at a local animal shelter and helps with dog walking. "
|
||||
"Brandon's favorite holiday is Christmas, and he enjoys decorating his home. "
|
||||
"He is also a fan of classic movies and has a collection of DVDs. "
|
||||
"Brandon is a mentor for young professionals and enjoys giving career advice. "
|
||||
"He is also a fan of puzzles and enjoys solving them in his free time. "
|
||||
"Brandon's favorite sport is soccer, and he often plays with his friends. "
|
||||
"He is also a fan of FC Barcelona and enjoys watching their matches. "
|
||||
)
|
||||
* 2, # Repeat to ensure it's 2k characters
|
||||
]
|
||||
string_sources = [
|
||||
StringKnowledgeSource(content=content, metadata={"preference": "personal"})
|
||||
for content in contents
|
||||
]
|
||||
|
||||
mock_vector_db.sources = string_sources
|
||||
mock_vector_db.query.return_value = [{"context": contents[1], "score": 0.9}]
|
||||
|
||||
# Perform a query
|
||||
query = "What is Brandon's favorite book?"
|
||||
results = mock_vector_db.query(query)
|
||||
|
||||
# Assert that the correct information is retrieved
|
||||
assert any(
|
||||
"the hitchhiker's guide to the galaxy" in result["context"].lower()
|
||||
for result in results
|
||||
)
|
||||
mock_vector_db.query.assert_called_once()
|
||||
|
||||
|
||||
def test_single_short_file(mock_vector_db, tmpdir):
|
||||
# Create a single short text file
|
||||
content = "Brandon's favorite sport is basketball."
|
||||
file_path = Path(tmpdir.join("short_file.txt"))
|
||||
with open(file_path, "w") as f:
|
||||
f.write(content)
|
||||
|
||||
file_source = TextFileKnowledgeSource(
|
||||
file_path=file_path, metadata={"preference": "personal"}
|
||||
)
|
||||
mock_vector_db.sources = [file_source]
|
||||
mock_vector_db.query.return_value = [{"context": content, "score": 0.9}]
|
||||
# Perform a query
|
||||
query = "What sport does Brandon like?"
|
||||
results = mock_vector_db.query(query)
|
||||
|
||||
# Assert that the results contain the expected information
|
||||
assert any("basketball" in result["context"].lower() for result in results)
|
||||
mock_vector_db.query.assert_called_once()
|
||||
|
||||
|
||||
def test_single_2k_character_file(mock_vector_db, tmpdir):
|
||||
# Create a single 2k character text file with various facts about Brandon
|
||||
content = (
|
||||
"Brandon is a software engineer who lives in San Francisco. "
|
||||
"He enjoys hiking and often visits the trails in the Bay Area. "
|
||||
"Brandon has a pet dog named Max, who is a golden retriever. "
|
||||
"He loves reading science fiction books, and his favorite author is Isaac Asimov. "
|
||||
"Brandon's favorite movie is Inception, and he enjoys watching it with his friends. "
|
||||
"He is also a fan of Mexican cuisine, especially tacos and burritos. "
|
||||
"Brandon plays the guitar and often performs at local open mic nights. "
|
||||
"He is learning French and plans to visit Paris next year. "
|
||||
"Brandon is passionate about technology and often attends tech meetups in the city. "
|
||||
"He is also interested in AI and machine learning, and he is currently working on a project related to natural language processing. "
|
||||
"Brandon's favorite color is blue, and he often wears blue shirts. "
|
||||
"He enjoys cooking and often tries new recipes on weekends. "
|
||||
"Brandon is a morning person and likes to start his day with a run in the park. "
|
||||
"He is also a coffee enthusiast and enjoys trying different coffee blends. "
|
||||
"Brandon is a member of a local book club and enjoys discussing books with fellow members. "
|
||||
"He is also a fan of board games and often hosts game nights at his place. "
|
||||
"Brandon is an advocate for environmental conservation and volunteers for local clean-up drives. "
|
||||
"He is also a mentor for aspiring software developers and enjoys sharing his knowledge with others. "
|
||||
"Brandon's favorite sport is basketball, and he often plays with his friends on weekends. "
|
||||
"He is also a fan of the Golden State Warriors and enjoys watching their games. "
|
||||
) * 2 # Repeat to ensure it's 2k characters
|
||||
file_path = Path(tmpdir.join("long_file.txt"))
|
||||
with open(file_path, "w") as f:
|
||||
f.write(content)
|
||||
|
||||
file_source = TextFileKnowledgeSource(
|
||||
file_path=file_path, metadata={"preference": "personal"}
|
||||
)
|
||||
mock_vector_db.sources = [file_source]
|
||||
mock_vector_db.query.return_value = [{"context": content, "score": 0.9}]
|
||||
# Perform a query
|
||||
query = "What is Brandon's favorite movie?"
|
||||
results = mock_vector_db.query(query)
|
||||
|
||||
# Assert that the results contain the expected information
|
||||
assert any("inception" in result["context"].lower() for result in results)
|
||||
mock_vector_db.query.assert_called_once()
|
||||
|
||||
|
||||
def test_multiple_short_files(mock_vector_db, tmpdir):
|
||||
# Create multiple short text files
|
||||
contents = [
|
||||
{
|
||||
"content": "Brandon works as a software engineer.",
|
||||
"metadata": {"category": "profession", "source": "occupation"},
|
||||
},
|
||||
{
|
||||
"content": "Brandon lives in New York.",
|
||||
"metadata": {"category": "city", "source": "personal"},
|
||||
},
|
||||
{
|
||||
"content": "Brandon enjoys cooking Italian food.",
|
||||
"metadata": {"category": "hobby", "source": "personal"},
|
||||
},
|
||||
]
|
||||
file_paths = []
|
||||
for i, item in enumerate(contents):
|
||||
file_path = Path(tmpdir.join(f"file_{i}.txt"))
|
||||
with open(file_path, "w") as f:
|
||||
f.write(item["content"])
|
||||
file_paths.append((file_path, item["metadata"]))
|
||||
|
||||
file_sources = [
|
||||
TextFileKnowledgeSource(file_path=path, metadata=metadata)
|
||||
for path, metadata in file_paths
|
||||
]
|
||||
mock_vector_db.sources = file_sources
|
||||
mock_vector_db.query.return_value = [
|
||||
{"context": "Brandon lives in New York.", "score": 0.9}
|
||||
]
|
||||
# Perform a query
|
||||
query = "What city does he reside in?"
|
||||
results = mock_vector_db.query(query)
|
||||
# Assert that the correct information is retrieved
|
||||
assert any("new york" in result["context"].lower() for result in results)
|
||||
mock_vector_db.query.assert_called_once()
|
||||
|
||||
|
||||
def test_multiple_2k_character_files(mock_vector_db, tmpdir):
|
||||
# Create multiple 2k character text files with various facts about Brandon
|
||||
contents = [
|
||||
(
|
||||
"Brandon loves traveling and has visited over 20 countries. "
|
||||
"He is fluent in Spanish and often practices with his friends. "
|
||||
"Brandon's favorite city is Barcelona, where he enjoys the architecture and culture. "
|
||||
"He is a foodie and loves trying new cuisines, with a particular fondness for sushi. "
|
||||
"Brandon is an avid cyclist and participates in local cycling events. "
|
||||
"He is also a photographer and enjoys capturing landscapes and cityscapes. "
|
||||
"Brandon is a tech enthusiast and follows the latest trends in gadgets and software. "
|
||||
"He is also a fan of virtual reality and owns a VR headset. "
|
||||
"Brandon's favorite book is 'The Hitchhiker's Guide to the Galaxy'. "
|
||||
"He enjoys watching documentaries and learning about history and science. "
|
||||
"Brandon is a coffee lover and has a collection of coffee mugs from different countries. "
|
||||
"He is also a fan of jazz music and often attends live performances. "
|
||||
"Brandon is a member of a local running club and participates in marathons. "
|
||||
"He is also a volunteer at a local animal shelter and helps with dog walking. "
|
||||
"Brandon's favorite holiday is Christmas, and he enjoys decorating his home. "
|
||||
"He is also a fan of classic movies and has a collection of DVDs. "
|
||||
"Brandon is a mentor for young professionals and enjoys giving career advice. "
|
||||
"He is also a fan of puzzles and enjoys solving them in his free time. "
|
||||
"Brandon's favorite sport is soccer, and he often plays with his friends. "
|
||||
"He is also a fan of FC Barcelona and enjoys watching their matches. "
|
||||
)
|
||||
* 2, # Repeat to ensure it's 2k characters
|
||||
(
|
||||
"Brandon is a software engineer who lives in San Francisco. "
|
||||
"He enjoys hiking and often visits the trails in the Bay Area. "
|
||||
"Brandon has a pet dog named Max, who is a golden retriever. "
|
||||
"He loves reading science fiction books, and his favorite author is Isaac Asimov. "
|
||||
"Brandon's favorite movie is Inception, and he enjoys watching it with his friends. "
|
||||
"He is also a fan of Mexican cuisine, especially tacos and burritos. "
|
||||
"Brandon plays the guitar and often performs at local open mic nights. "
|
||||
"He is learning French and plans to visit Paris next year. "
|
||||
"Brandon is passionate about technology and often attends tech meetups in the city. "
|
||||
"He is also interested in AI and machine learning, and he is currently working on a project related to natural language processing. "
|
||||
"Brandon's favorite color is blue, and he often wears blue shirts. "
|
||||
"He enjoys cooking and often tries new recipes on weekends. "
|
||||
"Brandon is a morning person and likes to start his day with a run in the park. "
|
||||
"He is also a coffee enthusiast and enjoys trying different coffee blends. "
|
||||
"Brandon is a member of a local book club and enjoys discussing books with fellow members. "
|
||||
"He is also a fan of board games and often hosts game nights at his place. "
|
||||
"Brandon is an advocate for environmental conservation and volunteers for local clean-up drives. "
|
||||
"He is also a mentor for aspiring software developers and enjoys sharing his knowledge with others. "
|
||||
"Brandon's favorite sport is basketball, and he often plays with his friends on weekends. "
|
||||
"He is also a fan of the Golden State Warriors and enjoys watching their games. "
|
||||
)
|
||||
* 2, # Repeat to ensure it's 2k characters
|
||||
]
|
||||
file_paths = []
|
||||
for i, content in enumerate(contents):
|
||||
file_path = Path(tmpdir.join(f"long_file_{i}.txt"))
|
||||
with open(file_path, "w") as f:
|
||||
f.write(content)
|
||||
file_paths.append(file_path)
|
||||
|
||||
file_sources = [
|
||||
TextFileKnowledgeSource(file_path=path, metadata={"preference": "personal"})
|
||||
for path in file_paths
|
||||
]
|
||||
mock_vector_db.sources = file_sources
|
||||
mock_vector_db.query.return_value = [
|
||||
{
|
||||
"context": "Brandon's favorite book is 'The Hitchhiker's Guide to the Galaxy'.",
|
||||
"score": 0.9,
|
||||
}
|
||||
]
|
||||
# Perform a query
|
||||
query = "What is Brandon's favorite book?"
|
||||
results = mock_vector_db.query(query)
|
||||
|
||||
# Assert that the correct information is retrieved
|
||||
assert any(
|
||||
"the hitchhiker's guide to the galaxy" in result["context"].lower()
|
||||
for result in results
|
||||
)
|
||||
mock_vector_db.query.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||
def test_hybrid_string_and_files(mock_vector_db, tmpdir):
|
||||
# Create string sources
|
||||
string_contents = [
|
||||
"Brandon is learning French.",
|
||||
"Brandon visited Paris last summer.",
|
||||
]
|
||||
string_sources = [
|
||||
StringKnowledgeSource(content=content, metadata={"preference": "personal"})
|
||||
for content in string_contents
|
||||
]
|
||||
|
||||
# Create file sources
|
||||
file_contents = [
|
||||
"Brandon prefers tea over coffee.",
|
||||
"Brandon's favorite book is 'The Alchemist'.",
|
||||
]
|
||||
file_paths = []
|
||||
for i, content in enumerate(file_contents):
|
||||
file_path = Path(tmpdir.join(f"file_{i}.txt"))
|
||||
with open(file_path, "w") as f:
|
||||
f.write(content)
|
||||
file_paths.append(file_path)
|
||||
|
||||
file_sources = [
|
||||
TextFileKnowledgeSource(file_path=path, metadata={"preference": "personal"})
|
||||
for path in file_paths
|
||||
]
|
||||
|
||||
# Combine string and file sources
|
||||
mock_vector_db.sources = string_sources + file_sources
|
||||
mock_vector_db.query.return_value = [{"context": file_contents[1], "score": 0.9}]
|
||||
|
||||
# Perform a query
|
||||
query = "What is Brandon's favorite book?"
|
||||
results = mock_vector_db.query(query)
|
||||
|
||||
# Assert that the correct information is retrieved
|
||||
assert any("the alchemist" in result["context"].lower() for result in results)
|
||||
mock_vector_db.query.assert_called_once()
|
||||
|
||||
|
||||
def test_pdf_knowledge_source(mock_vector_db):
|
||||
# Get the directory of the current file
|
||||
current_dir = Path(__file__).parent
|
||||
# Construct the path to the PDF file
|
||||
pdf_path = current_dir / "crewai_quickstart.pdf"
|
||||
|
||||
# Create a PDFKnowledgeSource
|
||||
pdf_source = PDFKnowledgeSource(
|
||||
file_path=pdf_path, metadata={"preference": "personal"}
|
||||
)
|
||||
mock_vector_db.sources = [pdf_source]
|
||||
mock_vector_db.query.return_value = [
|
||||
{"context": "crewai create crew latest-ai-development", "score": 0.9}
|
||||
]
|
||||
|
||||
# Perform a query
|
||||
query = "How do you create a crew?"
|
||||
results = mock_vector_db.query(query)
|
||||
|
||||
# Assert that the correct information is retrieved
|
||||
assert any(
|
||||
"crewai create crew latest-ai-development" in result["context"].lower()
|
||||
for result in results
|
||||
)
|
||||
mock_vector_db.query.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||
def test_csv_knowledge_source(mock_vector_db, tmpdir):
|
||||
"""Test CSVKnowledgeSource with a simple CSV file."""
|
||||
|
||||
# Create a CSV file with sample data
|
||||
csv_content = [
|
||||
["Name", "Age", "City"],
|
||||
["Brandon", "30", "New York"],
|
||||
["Alice", "25", "Los Angeles"],
|
||||
["Bob", "35", "Chicago"],
|
||||
]
|
||||
csv_path = Path(tmpdir.join("data.csv"))
|
||||
with open(csv_path, "w", encoding="utf-8") as f:
|
||||
for row in csv_content:
|
||||
f.write(",".join(row) + "\n")
|
||||
|
||||
# Create a CSVKnowledgeSource
|
||||
csv_source = CSVKnowledgeSource(
|
||||
file_path=csv_path, metadata={"preference": "personal"}
|
||||
)
|
||||
mock_vector_db.sources = [csv_source]
|
||||
mock_vector_db.query.return_value = [
|
||||
{"context": "Brandon is 30 years old.", "score": 0.9}
|
||||
]
|
||||
|
||||
# Perform a query
|
||||
query = "How old is Brandon?"
|
||||
results = mock_vector_db.query(query)
|
||||
|
||||
# Assert that the correct information is retrieved
|
||||
assert any("30" in result["context"] for result in results)
|
||||
mock_vector_db.query.assert_called_once()
|
||||
|
||||
|
||||
def test_json_knowledge_source(mock_vector_db, tmpdir):
|
||||
"""Test JSONKnowledgeSource with a simple JSON file."""
|
||||
|
||||
# Create a JSON file with sample data
|
||||
json_data = {
|
||||
"people": [
|
||||
{"name": "Brandon", "age": 30, "city": "New York"},
|
||||
{"name": "Alice", "age": 25, "city": "Los Angeles"},
|
||||
{"name": "Bob", "age": 35, "city": "Chicago"},
|
||||
]
|
||||
}
|
||||
json_path = Path(tmpdir.join("data.json"))
|
||||
with open(json_path, "w", encoding="utf-8") as f:
|
||||
import json
|
||||
|
||||
json.dump(json_data, f)
|
||||
|
||||
# Create a JSONKnowledgeSource
|
||||
json_source = JSONKnowledgeSource(
|
||||
file_path=json_path, metadata={"preference": "personal"}
|
||||
)
|
||||
mock_vector_db.sources = [json_source]
|
||||
mock_vector_db.query.return_value = [
|
||||
{"context": "Alice lives in Los Angeles.", "score": 0.9}
|
||||
]
|
||||
|
||||
# Perform a query
|
||||
query = "Where does Alice reside?"
|
||||
results = mock_vector_db.query(query)
|
||||
|
||||
# Assert that the correct information is retrieved
|
||||
assert any("los angeles" in result["context"].lower() for result in results)
|
||||
mock_vector_db.query.assert_called_once()
|
||||
|
||||
|
||||
def test_excel_knowledge_source(mock_vector_db, tmpdir):
|
||||
"""Test ExcelKnowledgeSource with a simple Excel file."""
|
||||
|
||||
# Create an Excel file with sample data
|
||||
import pandas as pd
|
||||
|
||||
excel_data = {
|
||||
"Name": ["Brandon", "Alice", "Bob"],
|
||||
"Age": [30, 25, 35],
|
||||
"City": ["New York", "Los Angeles", "Chicago"],
|
||||
}
|
||||
df = pd.DataFrame(excel_data)
|
||||
excel_path = Path(tmpdir.join("data.xlsx"))
|
||||
df.to_excel(excel_path, index=False)
|
||||
|
||||
# Create an ExcelKnowledgeSource
|
||||
excel_source = ExcelKnowledgeSource(
|
||||
file_path=excel_path, metadata={"preference": "personal"}
|
||||
)
|
||||
mock_vector_db.sources = [excel_source]
|
||||
mock_vector_db.query.return_value = [
|
||||
{"context": "Brandon is 30 years old.", "score": 0.9}
|
||||
]
|
||||
|
||||
# Perform a query
|
||||
query = "What is Brandon's age?"
|
||||
results = mock_vector_db.query(query)
|
||||
|
||||
# Assert that the correct information is retrieved
|
||||
assert any("30" in result["context"] for result in results)
|
||||
mock_vector_db.query.assert_called_once()
|
||||
@@ -38,6 +38,7 @@ def mock_crew_factory():
|
||||
|
||||
crew = MockCrew()
|
||||
crew.name = name
|
||||
crew.knowledge = None
|
||||
|
||||
task_output = TaskOutput(
|
||||
description="Test task", raw="Task output", agent="Test Agent"
|
||||
@@ -67,6 +68,7 @@ def mock_crew_factory():
|
||||
crew.process = Process.sequential
|
||||
crew.config = None
|
||||
crew.cache = True
|
||||
crew.embedder = None
|
||||
|
||||
# Add non-empty agents and tasks
|
||||
mock_agent = MagicMock(spec=Agent)
|
||||
|
||||
Reference in New Issue
Block a user