fix: Fix crashes and enhance test reliability with session IDs (#6683)
* test: Add session ID parameter to ToolCallingAgentComponent test * test: Add blocking for langchain_core runnables utility function * test: Add session ID generation to agent component test * fix: Safely delete agent message with ID check Modify error handling in LCAgentComponent to only delete agent message if it has an ID attribute, preventing potential attribute errors * test: Update ComponentToolkit test to use async start and verify results Modify the test_component_tool_with_api_key test to: - Use async_start() method for graph execution - Add session ID to graph - Improve result verification with vertex result tracking - Update import path for ChatOutput component * test: Skip cycle tests requiring LoopComponent Update test_cycles.py to: - Add skip markers for tests that now require a LoopComponent - Improve error message with snapshots for debugging - Preserve existing test logic while marking as skipped * test: Add client fixture to tool calling agent test Add usefixtures decorator to ensure client is available for the tool calling agent test, improving test setup and reliability * test: Add client fixture to component tool test with API key Enhance test_component_toolkit.py by adding the client fixture to the test_component_tool_with_api_key method, ensuring proper test setup for API key-dependent scenarios * test: Add client fixture to agent component test with calculator Add client fixture to the test_agent_component_with_calculator method to ensure proper test setup for API key-dependent scenarios * test: Disable redundant component input tests Remove commented-out test methods for checking required inputs across various components, as these tests were not providing significant value and the inputs are dynamic * test: Comment out condition to skip nodes with Tool outputs in setup.py * run formatter * test: Re-enable condition to skip nodes with Tool outputs in setup.py * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
85b2818ea0
commit
d092724d6a
6 changed files with 34 additions and 31 deletions
|
|
@ -4,7 +4,7 @@ import pytest
|
|||
from langflow.base.tools.component_tool import ComponentToolkit
|
||||
from langflow.components.langchain_utilities import ToolCallingAgentComponent
|
||||
from langflow.components.models import OpenAIModelComponent
|
||||
from langflow.components.outputs import ChatOutput
|
||||
from langflow.components.outputs.chat import ChatOutput
|
||||
from langflow.components.tools.calculator import CalculatorToolComponent
|
||||
from langflow.graph import Graph
|
||||
from langflow.schema.data import Data
|
||||
|
|
@ -41,14 +41,15 @@ async def test_component_tool_with_api_key():
|
|||
openai_llm = OpenAIModelComponent()
|
||||
openai_llm.set(api_key=os.environ["OPENAI_API_KEY"])
|
||||
tool_calling_agent = ToolCallingAgentComponent()
|
||||
tools = await chat_output.to_toolkit()
|
||||
|
||||
tool_calling_agent.set(
|
||||
llm=openai_llm.build_model,
|
||||
tools=tools,
|
||||
tools=[chat_output.to_toolkit],
|
||||
input_value="Which tools are available? Please tell its name.",
|
||||
)
|
||||
|
||||
g = Graph(start=tool_calling_agent, end=tool_calling_agent)
|
||||
g.session_id = "test"
|
||||
assert g is not None
|
||||
results = [result async for result in g.async_start()]
|
||||
assert len(results) == 4
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue