-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(edge): Handle invalid input types when creating TargetHandle (#3368)
* fix(edge): Handle invalid input types when creating TargetHandle * test(edge): add test for raising error on invalid target handle * fix: mypy error union-attr --------- Co-authored-by: italojohnny <[email protected]>
- Loading branch information
1 parent
8de100e
commit c4d2dc5
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pytest | ||
|
||
from langflow.components.inputs.ChatInput import ChatInput | ||
from langflow.components.models.OpenAIModel import OpenAIModelComponent | ||
from langflow.components.outputs.ChatOutput import ChatOutput | ||
from langflow.components.prompts.Prompt import PromptComponent | ||
from langflow.graph.graph.base import Graph | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
pass | ||
|
||
|
||
def test_edge_raises_error_on_invalid_target_handle(client): | ||
template = """Answer the user as if you were a pirate. | ||
User: {user_input} | ||
Answer: | ||
""" | ||
chat_input = ChatInput() | ||
prompt_component = PromptComponent() | ||
prompt_component.set( | ||
template=template, | ||
user_input=chat_input.message_response, | ||
) | ||
|
||
openai_component = OpenAIModelComponent() | ||
openai_component.set(input_values=prompt_component.build_prompt) | ||
|
||
chat_output = ChatOutput() | ||
chat_output.set(input_value=openai_component.text_response) | ||
with pytest.raises(ValueError, match="Component OpenAI field 'input_values' might not be a valid input."): | ||
Graph(start=chat_input, end=chat_output) |