removing langchain

This commit is contained in:
João Moura
2024-09-13 02:57:50 -05:00
parent 3cd464497b
commit 7120a9860b
40 changed files with 6295 additions and 2499 deletions

View File

@@ -195,7 +195,9 @@ def test_async_execution():
)
with patch.object(Agent, "execute_task", return_value="ok") as execute:
task.execute_async(agent=researcher)
execution = task.execute_async(agent=researcher)
result = execution.result()
assert result.raw == "ok"
execute.assert_called_once_with(task=task, context=None, tools=[])
@@ -239,8 +241,6 @@ def test_output_pydantic_sequential():
@pytest.mark.vcr(filter_headers=["authorization"])
def test_output_pydantic_hierarchical():
from langchain_openai import ChatOpenAI
class ScoreOutput(BaseModel):
score: int
@@ -262,11 +262,11 @@ def test_output_pydantic_hierarchical():
agents=[scorer],
tasks=[task],
process=Process.hierarchical,
manager_llm=ChatOpenAI(model="gpt-4o"),
manager_llm="gpt-4o",
)
result = crew.kickoff()
assert isinstance(result.pydantic, ScoreOutput)
assert result.to_dict() == {"score": 5}
assert result.to_dict() == {"score": 4}
@pytest.mark.vcr(filter_headers=["authorization"])
@@ -297,8 +297,6 @@ def test_output_json_sequential():
@pytest.mark.vcr(filter_headers=["authorization"])
def test_output_json_hierarchical():
from langchain_openai import ChatOpenAI
class ScoreOutput(BaseModel):
score: int
@@ -320,11 +318,11 @@ def test_output_json_hierarchical():
agents=[scorer],
tasks=[task],
process=Process.hierarchical,
manager_llm=ChatOpenAI(model="gpt-4o"),
manager_llm="gpt-4o",
)
result = crew.kickoff()
assert '{"score": 5}' == result.json
assert result.to_dict() == {"score": 5}
assert '{"score": 4}' == result.json
assert result.to_dict() == {"score": 4}
@pytest.mark.vcr(filter_headers=["authorization"])
@@ -382,8 +380,6 @@ def test_output_json_dict_sequential():
@pytest.mark.vcr(filter_headers=["authorization"])
def test_output_json_dict_hierarchical():
from langchain_openai import ChatOpenAI
class ScoreOutput(BaseModel):
score: int
@@ -405,17 +401,15 @@ def test_output_json_dict_hierarchical():
agents=[scorer],
tasks=[task],
process=Process.hierarchical,
manager_llm=ChatOpenAI(model="gpt-4o"),
manager_llm="gpt-4o",
)
result = crew.kickoff()
assert {"score": 4} == result.json_dict
assert result.to_dict() == {"score": 4}
assert {"score": 5} == result.json_dict
assert result.to_dict() == {"score": 5}
@pytest.mark.vcr(filter_headers=["authorization"])
def test_output_pydantic_to_another_task():
from langchain_openai import ChatOpenAI
class ScoreOutput(BaseModel):
score: int
@@ -424,8 +418,8 @@ def test_output_pydantic_to_another_task():
goal="Score the title",
backstory="You're an expert scorer, specialized in scoring titles.",
allow_delegation=False,
llm=ChatOpenAI(model="gpt-4-0125-preview"),
function_calling_llm=ChatOpenAI(model="gpt-3.5-turbo-0125"),
llm="gpt-4-0125-preview",
function_calling_llm="gpt-3.5-turbo-0125",
verbose=True,
)
@@ -449,7 +443,7 @@ def test_output_pydantic_to_another_task():
assert isinstance(
pydantic_result, ScoreOutput
), "Expected pydantic result to be of type ScoreOutput"
assert 5 == pydantic_result.score
assert 4 == pydantic_result.score
@pytest.mark.vcr(filter_headers=["authorization"])
@@ -601,8 +595,6 @@ def test_custom_converter_cls():
@pytest.mark.vcr(filter_headers=["authorization"])
def test_increment_delegations_for_hierarchical_process():
from langchain_openai import ChatOpenAI
scorer = Agent(
role="Scorer",
goal="Score the title",
@@ -619,7 +611,7 @@ def test_increment_delegations_for_hierarchical_process():
agents=[scorer],
tasks=[task],
process=Process.hierarchical,
manager_llm=ChatOpenAI(model="gpt-4o"),
manager_llm="gpt-4o",
)
with patch.object(Task, "increment_delegations") as increment_delegations:
@@ -665,7 +657,6 @@ def test_increment_delegations_for_sequential_process():
@pytest.mark.vcr(filter_headers=["authorization"])
def test_increment_tool_errors():
from crewai_tools import tool
from langchain_openai import ChatOpenAI
@tool
def scoring_examples() -> None:
@@ -688,13 +679,13 @@ def test_increment_tool_errors():
agents=[scorer],
tasks=[task],
process=Process.hierarchical,
manager_llm=ChatOpenAI(model="gpt-4-0125-preview"),
manager_llm="gpt-4-0125-preview",
)
with patch.object(Task, "increment_tools_errors") as increment_tools_errors:
increment_tools_errors.return_value = None
crew.kickoff()
assert len(increment_tools_errors.mock_calls) == 3
assert len(increment_tools_errors.mock_calls) == 6
def test_task_definition_based_on_dict():