refactor(api): Decouple ParameterExtractorNode from LLMNode (#20843)
- Extract methods used by `ParameterExtractorNode` from `LLMNode` into a separate file. - Convert `ParameterExtractorNode` into a subclass of `BaseNode`. - Refactor code referencing the extracted methods to ensure functionality and clarity. - Fixes the issue that `ParameterExtractorNode` returns error when executed. - Fix relevant test cases. Closes #20840.
This commit is contained in:
parent
a97ff587d2
commit
c439e82038
8 changed files with 226 additions and 171 deletions
|
|
@ -353,7 +353,7 @@ def test_extract_json_from_tool_call():
|
|||
assert result["location"] == "kawaii"
|
||||
|
||||
|
||||
def test_chat_parameter_extractor_with_memory(setup_model_mock):
|
||||
def test_chat_parameter_extractor_with_memory(setup_model_mock, monkeypatch):
|
||||
"""
|
||||
Test chat parameter extractor with memory.
|
||||
"""
|
||||
|
|
@ -384,7 +384,8 @@ def test_chat_parameter_extractor_with_memory(setup_model_mock):
|
|||
mode="chat",
|
||||
credentials={"openai_api_key": os.environ.get("OPENAI_API_KEY")},
|
||||
)
|
||||
node._fetch_memory = get_mocked_fetch_memory("customized memory")
|
||||
# Test the mock before running the actual test
|
||||
monkeypatch.setattr("core.workflow.nodes.llm.llm_utils.fetch_memory", get_mocked_fetch_memory("customized memory"))
|
||||
db.session.close = MagicMock()
|
||||
|
||||
result = node._run()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue