chore: merge mcp components (#7167)
* take1 * depreacate stdio and sse mcp components * optionals * rodrigo fixes * session management * update init * mcp component integration test * broken * [autofix.ci] apply automated fixes * fix url input name * upated MCP * Update mcp_component.py * [autofix.ci] apply automated fixes * update to the MCP component * [autofix.ci] apply automated fixes * mostly working * [autofix.ci] apply automated fixes * Update mcp_component.py * [autofix.ci] apply automated fixes * update component * [autofix.ci] apply automated fixes * Update mcp_component.py * rename component because Simon * icon and description for simon * fix integration test * fix test * Update mcp_component.py * update and basic QoL * [autofix.ci] apply automated fixes * refactor clients to util and use flow names not IDs in mcp.py * integration test * take out traces * ✨ (edit-tools.spec.ts): add test for user to be able to edit tools in the frontend application. * session fix * fix content output * ♻️ (util.py): remove redundant constant HTTP_TEMPORARY_REDIRECT and replace its usage with httpx.codes.TEMPORARY_REDIRECT for better code readability and maintainability * [autofix.ci] apply automated fixes * 🐛 (utils.ts): fix potential null pointer error when converting words to title case by adding null check before accessing properties * 🐛 (genericIconComponent/index.tsx): Fix issue with optional chaining in mapping function 🐛 (renderIconComponent/index.tsx): Fix issue with optional chaining in mapping function 🐛 (button.tsx): Fix issue with optional chaining in mapping function 🐛 (utils.ts): Fix issue with optional chaining in mapping functions * 🐛 (language-select.tsx): Fix potential null pointer error when mapping over allLanguages array * ✨ (constants.ts): add support for multiple languages in the application by defining an array of language options ♻️ (audio-settings-dialog.tsx, language-select.tsx): refactor to import the array of all languages from constants.ts instead of duplicating it in each file * ✅ (auto-login-off.spec.ts): add a 2-second delay before continuing the test to ensure proper loading and rendering of elements on the page * ⬆️ (filterEdge-shard-0.spec.ts): reduce wait time for page interactions to improve test performance ⬆️ (playground.spec.ts): optimize wait times for page interactions to enhance test efficiency --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Edwin Jose <edwin.jose@datastax.com> Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
This commit is contained in:
parent
4527c473be
commit
59b2ed7765
25 changed files with 1200 additions and 331 deletions
|
|
@ -3,11 +3,13 @@ from types import NoneType
|
|||
from typing import Union
|
||||
|
||||
import pytest
|
||||
from langflow.inputs.inputs import BoolInput, DictInput, FloatInput, InputTypes, IntInput, MessageTextInput
|
||||
from langflow.io.schema import schema_to_langflow_inputs
|
||||
from langflow.schema.data import Data
|
||||
from langflow.template import Input, Output
|
||||
from langflow.template.field.base import UNDEFINED
|
||||
from langflow.type_extraction.type_extraction import post_process_type
|
||||
from pydantic import ValidationError
|
||||
from pydantic import BaseModel, Field, ValidationError
|
||||
|
||||
|
||||
class TestInput:
|
||||
|
|
@ -178,3 +180,65 @@ class TestPostProcessType:
|
|||
pass
|
||||
|
||||
assert set(post_process_type(Union[CustomType, int])) == {CustomType, int} # noqa: UP007
|
||||
|
||||
|
||||
def test_schema_to_langflow_inputs():
|
||||
# Define a test Pydantic model with various field types
|
||||
class TestSchema(BaseModel):
|
||||
text_field: str = Field(title="Custom Text Title", description="A text field")
|
||||
number_field: int = Field(description="A number field")
|
||||
bool_field: bool = Field(description="A boolean field")
|
||||
dict_field: dict = Field(description="A dictionary field")
|
||||
list_field: list[str] = Field(description="A list of strings")
|
||||
|
||||
# Convert schema to Langflow inputs
|
||||
inputs = schema_to_langflow_inputs(TestSchema)
|
||||
|
||||
# Verify the number of inputs matches the schema fields
|
||||
assert len(inputs) == 5
|
||||
|
||||
# Helper function to find input by name
|
||||
def find_input(name: str) -> InputTypes | None:
|
||||
for _input in inputs:
|
||||
if _input.name == name:
|
||||
return _input
|
||||
return None
|
||||
|
||||
# Test text field
|
||||
text_input = find_input("text_field")
|
||||
assert text_input.display_name == "Custom Text Title"
|
||||
assert text_input.info == "A text field"
|
||||
assert isinstance(text_input, MessageTextInput) # Check the instance type instead of field_type
|
||||
|
||||
# Test number field
|
||||
number_input = find_input("number_field")
|
||||
assert number_input.display_name == "Number Field"
|
||||
assert number_input.info == "A number field"
|
||||
assert isinstance(number_input, IntInput | FloatInput)
|
||||
|
||||
# Test boolean field
|
||||
bool_input = find_input("bool_field")
|
||||
assert isinstance(bool_input, BoolInput)
|
||||
|
||||
# Test dictionary field
|
||||
dict_input = find_input("dict_field")
|
||||
assert isinstance(dict_input, DictInput)
|
||||
|
||||
# Test list field
|
||||
list_input = find_input("list_field")
|
||||
assert list_input.is_list is True
|
||||
assert isinstance(list_input, MessageTextInput)
|
||||
|
||||
|
||||
def test_schema_to_langflow_inputs_invalid_type():
|
||||
# Define a schema with an unsupported type
|
||||
class CustomType:
|
||||
pass
|
||||
|
||||
class InvalidSchema(BaseModel):
|
||||
model_config = {"arbitrary_types_allowed": True} # Add this line
|
||||
invalid_field: CustomType
|
||||
|
||||
# Test that attempting to convert an unsupported type raises TypeError
|
||||
with pytest.raises(TypeError, match="Unsupported field type:"):
|
||||
schema_to_langflow_inputs(InvalidSchema)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue