Merge branch 'NodeModal' of personal:logspace-ai/langflow into NodeModal

This commit is contained in:
anovazzi1 2023-04-28 19:41:26 -03:00
commit cfe74e6765
6 changed files with 112 additions and 2 deletions

View file

@ -23,7 +23,7 @@ class TemplateFieldCreator(BaseModel, ABC):
options: list[str] = []
name: str = ""
display_name: Optional[str] = None
advanced: bool = False
advanced: bool = True
def to_dict(self):
result = self.dict()
@ -241,4 +241,4 @@ class FrontendNode(BaseModel):
# If the field.name contains api or api and key, then it might be an api key
# other conditions are to make sure that it is not an input or output variable
if "api" in key.lower() and "key" in key.lower():
field.required = False
field.required = False

View file

@ -448,6 +448,7 @@ class LLMFrontendNode(FrontendNode):
# Required should be False to support
# loading the API key from environment variables
field.required = False
field.advanced = False
if field.name == "task":
field.required = True
@ -461,3 +462,7 @@ class LLMFrontendNode(FrontendNode):
if field.name == "model_kwargs":
field.field_type = "code"
field.advanced = True
field.show = True
elif field.name in ["model_name", "temperature"]:
field.advanced = False
field.show = True

View file

@ -36,6 +36,7 @@ def test_zero_shot_agent(client: TestClient):
"name": "llm_chain",
"type": "LLMChain",
"list": False,
"advanced": True,
}
assert template["allowed_tools"] == {
"required": False,
@ -46,6 +47,7 @@ def test_zero_shot_agent(client: TestClient):
"name": "allowed_tools",
"type": "Tool",
"list": True,
"advanced": True,
}
@ -68,6 +70,7 @@ def test_json_agent(client: TestClient):
"name": "toolkit",
"type": "BaseToolkit",
"list": False,
"advanced": True,
}
assert template["llm"] == {
"required": True,
@ -78,6 +81,7 @@ def test_json_agent(client: TestClient):
"name": "llm",
"type": "BaseLanguageModel",
"list": False,
"advanced": True,
}
@ -104,6 +108,7 @@ def test_csv_agent(client: TestClient):
"type": "file",
"list": False,
"content": None,
"advanced": True,
}
assert template["llm"] == {
"required": True,
@ -114,6 +119,7 @@ def test_csv_agent(client: TestClient):
"name": "llm",
"type": "BaseLanguageModel",
"list": False,
"advanced": True,
}
@ -143,6 +149,7 @@ def test_initialize_agent(client: TestClient):
"name": "agent",
"type": "str",
"list": True,
"advanced": True,
}
assert template["memory"] == {
"required": False,
@ -153,6 +160,7 @@ def test_initialize_agent(client: TestClient):
"name": "memory",
"type": "BaseChatMemory",
"list": False,
"advanced": True,
}
assert template["tools"] == {
"required": False,
@ -163,6 +171,7 @@ def test_initialize_agent(client: TestClient):
"name": "tools",
"type": "Tool",
"list": True,
"advanced": True,
}
assert template["llm"] == {
"required": True,
@ -173,4 +182,5 @@ def test_initialize_agent(client: TestClient):
"name": "llm",
"type": "BaseLanguageModel",
"list": False,
"advanced": True,
}

View file

@ -31,6 +31,7 @@ def test_conversation_chain(client: TestClient):
"name": "memory",
"type": "BaseMemory",
"list": False,
"advanced": True,
}
assert template["verbose"] == {
"required": False,
@ -41,6 +42,7 @@ def test_conversation_chain(client: TestClient):
"name": "verbose",
"type": "bool",
"list": False,
"advanced": True,
}
assert template["llm"] == {
"required": True,
@ -51,6 +53,7 @@ def test_conversation_chain(client: TestClient):
"name": "llm",
"type": "BaseLanguageModel",
"list": False,
"advanced": True,
}
assert template["input_key"] == {
"required": True,
@ -62,6 +65,7 @@ def test_conversation_chain(client: TestClient):
"name": "input_key",
"type": "str",
"list": False,
"advanced": True,
}
assert template["output_key"] == {
"required": True,
@ -73,6 +77,7 @@ def test_conversation_chain(client: TestClient):
"name": "output_key",
"type": "str",
"list": False,
"advanced": True,
}
assert template["_type"] == "ConversationChain"
@ -102,6 +107,7 @@ def test_llm_chain(client: TestClient):
"name": "memory",
"type": "BaseMemory",
"list": False,
"advanced": True,
}
assert template["verbose"] == {
"required": False,
@ -113,6 +119,7 @@ def test_llm_chain(client: TestClient):
"name": "verbose",
"type": "bool",
"list": False,
"advanced": True,
}
assert template["llm"] == {
"required": True,
@ -123,6 +130,7 @@ def test_llm_chain(client: TestClient):
"name": "llm",
"type": "BaseLanguageModel",
"list": False,
"advanced": True,
}
assert template["output_key"] == {
"required": True,
@ -134,6 +142,7 @@ def test_llm_chain(client: TestClient):
"name": "output_key",
"type": "str",
"list": False,
"advanced": True,
}
@ -156,6 +165,7 @@ def test_llm_checker_chain(client: TestClient):
"name": "memory",
"type": "BaseMemory",
"list": False,
"advanced": True,
}
assert template["verbose"] == {
"required": False,
@ -167,6 +177,7 @@ def test_llm_checker_chain(client: TestClient):
"name": "verbose",
"type": "bool",
"list": False,
"advanced": True,
}
assert template["llm"] == {
"required": True,
@ -177,6 +188,7 @@ def test_llm_checker_chain(client: TestClient):
"name": "llm",
"type": "BaseLLM",
"list": False,
"advanced": True,
}
assert template["input_key"] == {
"required": True,
@ -188,6 +200,7 @@ def test_llm_checker_chain(client: TestClient):
"name": "input_key",
"type": "str",
"list": False,
"advanced": True,
}
assert template["output_key"] == {
"required": True,
@ -199,6 +212,7 @@ def test_llm_checker_chain(client: TestClient):
"name": "output_key",
"type": "str",
"list": False,
"advanced": True,
}
assert template["_type"] == "LLMCheckerChain"
@ -228,6 +242,7 @@ def test_llm_math_chain(client: TestClient):
"name": "memory",
"type": "BaseMemory",
"list": False,
"advanced": True,
}
assert template["verbose"] == {
"required": False,
@ -239,6 +254,7 @@ def test_llm_math_chain(client: TestClient):
"name": "verbose",
"type": "bool",
"list": False,
"advanced": True,
}
assert template["llm"] == {
"required": True,
@ -249,6 +265,7 @@ def test_llm_math_chain(client: TestClient):
"name": "llm",
"type": "BaseLanguageModel",
"list": False,
"advanced": True,
}
assert template["input_key"] == {
"required": True,
@ -260,6 +277,7 @@ def test_llm_math_chain(client: TestClient):
"name": "input_key",
"type": "str",
"list": False,
"advanced": True,
}
assert template["output_key"] == {
"required": True,
@ -271,6 +289,7 @@ def test_llm_math_chain(client: TestClient):
"name": "output_key",
"type": "str",
"list": False,
"advanced": True,
}
assert template["_type"] == "LLMMathChain"
@ -316,6 +335,7 @@ def test_series_character_chain(client: TestClient):
"name": "memory",
"type": "BaseMemory",
"list": False,
"advanced": True,
}
assert template["verbose"] == {
"required": False,
@ -326,6 +346,7 @@ def test_series_character_chain(client: TestClient):
"name": "verbose",
"type": "bool",
"list": False,
"advanced": True,
}
assert template["llm"] == {
"required": True,
@ -336,6 +357,7 @@ def test_series_character_chain(client: TestClient):
"name": "llm",
"type": "BaseLanguageModel",
"list": False,
"advanced": True,
}
assert template["input_key"] == {
"required": True,
@ -347,6 +369,7 @@ def test_series_character_chain(client: TestClient):
"name": "input_key",
"type": "str",
"list": False,
"advanced": True,
}
assert template["output_key"] == {
"required": True,
@ -358,6 +381,7 @@ def test_series_character_chain(client: TestClient):
"name": "output_key",
"type": "str",
"list": False,
"advanced": True,
}
assert template["template"] == {
"required": False,
@ -369,6 +393,7 @@ def test_series_character_chain(client: TestClient):
"name": "template",
"type": "str",
"list": False,
"advanced": True,
}
assert template["ai_prefix_value"] == {
"required": False,
@ -380,6 +405,7 @@ def test_series_character_chain(client: TestClient):
"name": "ai_prefix_value",
"type": "str",
"list": False,
"advanced": True,
}
assert template["character"] == {
"required": True,
@ -390,6 +416,7 @@ def test_series_character_chain(client: TestClient):
"name": "character",
"type": "str",
"list": False,
"advanced": True,
}
assert template["series"] == {
"required": True,
@ -400,6 +427,7 @@ def test_series_character_chain(client: TestClient):
"name": "series",
"type": "str",
"list": False,
"advanced": True,
}
assert template["_type"] == "SeriesCharacterChain"
@ -447,6 +475,7 @@ def test_mid_journey_prompt_chain(client: TestClient):
"name": "memory",
"type": "BaseMemory",
"list": False,
"advanced": True,
}
assert template["verbose"] == {
"required": False,
@ -457,6 +486,7 @@ def test_mid_journey_prompt_chain(client: TestClient):
"name": "verbose",
"type": "bool",
"list": False,
"advanced": True,
}
# Continue with other template object assertions
assert template["prompt"] == {
@ -477,6 +507,7 @@ def test_mid_journey_prompt_chain(client: TestClient):
"name": "prompt",
"type": "BasePromptTemplate",
"list": False,
"advanced": True,
}
assert template["llm"] == {
"required": True,
@ -487,6 +518,7 @@ def test_mid_journey_prompt_chain(client: TestClient):
"name": "llm",
"type": "BaseLanguageModel",
"list": False,
"advanced": True,
}
assert template["output_key"] == {
"required": True,
@ -498,6 +530,7 @@ def test_mid_journey_prompt_chain(client: TestClient):
"name": "output_key",
"type": "str",
"list": False,
"advanced": True,
}
assert template["input_key"] == {
"required": True,
@ -509,6 +542,7 @@ def test_mid_journey_prompt_chain(client: TestClient):
"name": "input_key",
"type": "str",
"list": False,
"advanced": True,
}
assert template["template"] == {
"required": False,
@ -520,6 +554,7 @@ def test_mid_journey_prompt_chain(client: TestClient):
"name": "template",
"type": "str",
"list": False,
"advanced": True,
}
assert template["ai_prefix_value"] == {
"required": False,
@ -530,6 +565,7 @@ def test_mid_journey_prompt_chain(client: TestClient):
"name": "ai_prefix_value",
"type": "str",
"list": False,
"advanced": True,
}
# Test the description object
assert (
@ -575,6 +611,7 @@ def test_time_travel_guide_chain(client: TestClient):
"name": "memory",
"type": "BaseMemory",
"list": False,
"advanced": True,
}
assert template["verbose"] == {
"required": False,
@ -585,6 +622,7 @@ def test_time_travel_guide_chain(client: TestClient):
"name": "verbose",
"type": "bool",
"list": False,
"advanced": True,
}
assert template["prompt"] == {
@ -605,6 +643,7 @@ def test_time_travel_guide_chain(client: TestClient):
"name": "prompt",
"type": "BasePromptTemplate",
"list": False,
"advanced": True,
}
assert template["llm"] == {
"required": True,
@ -615,6 +654,7 @@ def test_time_travel_guide_chain(client: TestClient):
"name": "llm",
"type": "BaseLanguageModel",
"list": False,
"advanced": True,
}
assert template["output_key"] == {
"required": True,
@ -626,6 +666,7 @@ def test_time_travel_guide_chain(client: TestClient):
"name": "output_key",
"type": "str",
"list": False,
"advanced": True,
}
assert template["input_key"] == {
@ -638,6 +679,7 @@ def test_time_travel_guide_chain(client: TestClient):
"name": "input_key",
"type": "str",
"list": False,
"advanced": True,
}
assert template["template"] == {
@ -650,6 +692,7 @@ def test_time_travel_guide_chain(client: TestClient):
"name": "template",
"type": "str",
"list": False,
"advanced": True,
}
assert template["ai_prefix_value"] == {
"required": False,
@ -660,5 +703,6 @@ def test_time_travel_guide_chain(client: TestClient):
"name": "ai_prefix_value",
"type": "str",
"list": False,
"advanced": True,
}
assert chain["description"] == ""

View file

@ -28,6 +28,7 @@ def test_hugging_face_hub(client: TestClient):
"name": "cache",
"type": "bool",
"list": False,
"advanced": True,
}
assert template["verbose"] == {
"required": False,
@ -39,6 +40,7 @@ def test_hugging_face_hub(client: TestClient):
"name": "verbose",
"type": "bool",
"list": False,
"advanced": True,
}
assert template["client"] == {
"required": False,
@ -49,6 +51,7 @@ def test_hugging_face_hub(client: TestClient):
"name": "client",
"type": "Any",
"list": False,
"advanced": True,
}
assert template["repo_id"] == {
"required": False,
@ -60,6 +63,7 @@ def test_hugging_face_hub(client: TestClient):
"name": "repo_id",
"type": "str",
"list": False,
"advanced": True,
}
assert template["task"] == {
"required": True,
@ -71,6 +75,7 @@ def test_hugging_face_hub(client: TestClient):
"name": "task",
"type": "str",
"list": True,
"advanced": True,
}
assert template["model_kwargs"] == {
"required": False,
@ -81,6 +86,7 @@ def test_hugging_face_hub(client: TestClient):
"name": "model_kwargs",
"type": "code",
"list": False,
"advanced": True,
}
assert template["huggingfacehub_api_token"] == {
"required": False,
@ -92,6 +98,7 @@ def test_hugging_face_hub(client: TestClient):
"display_name": "HuggingFace Hub API Token",
"type": "str",
"list": False,
"advanced": False,
}
@ -113,6 +120,7 @@ def test_openai(client: TestClient):
"name": "cache",
"type": "bool",
"list": False,
"advanced": True,
}
assert template["verbose"] == {
"required": False,
@ -123,6 +131,7 @@ def test_openai(client: TestClient):
"name": "verbose",
"type": "bool",
"list": False,
"advanced": True,
}
assert template["client"] == {
"required": False,
@ -133,6 +142,7 @@ def test_openai(client: TestClient):
"name": "client",
"type": "Any",
"list": False,
"advanced": True,
}
assert template["model_name"] == {
"required": False,
@ -151,6 +161,7 @@ def test_openai(client: TestClient):
"name": "model_name",
"type": "str",
"list": True,
"advanced": False,
}
# Add more assertions for other properties here
assert template["temperature"] == {
@ -163,6 +174,7 @@ def test_openai(client: TestClient):
"name": "temperature",
"type": "float",
"list": False,
"advanced": False,
}
assert template["max_tokens"] == {
"required": False,
@ -174,6 +186,7 @@ def test_openai(client: TestClient):
"name": "max_tokens",
"type": "int",
"list": False,
"advanced": True,
}
assert template["top_p"] == {
"required": False,
@ -185,6 +198,7 @@ def test_openai(client: TestClient):
"name": "top_p",
"type": "float",
"list": False,
"advanced": True,
}
assert template["frequency_penalty"] == {
"required": False,
@ -196,6 +210,7 @@ def test_openai(client: TestClient):
"name": "frequency_penalty",
"type": "float",
"list": False,
"advanced": True,
}
assert template["presence_penalty"] == {
"required": False,
@ -207,6 +222,7 @@ def test_openai(client: TestClient):
"name": "presence_penalty",
"type": "float",
"list": False,
"advanced": True,
}
assert template["n"] == {
"required": False,
@ -218,6 +234,7 @@ def test_openai(client: TestClient):
"name": "n",
"type": "int",
"list": False,
"advanced": True,
}
assert template["best_of"] == {
"required": False,
@ -229,6 +246,7 @@ def test_openai(client: TestClient):
"name": "best_of",
"type": "int",
"list": False,
"advanced": True,
}
assert template["model_kwargs"] == {
"required": False,
@ -239,6 +257,7 @@ def test_openai(client: TestClient):
"name": "model_kwargs",
"type": "code",
"list": False,
"advanced": True,
}
assert template["openai_api_key"] == {
"required": False,
@ -251,6 +270,7 @@ def test_openai(client: TestClient):
"display_name": "OpenAI API Key",
"type": "str",
"list": False,
"advanced": False,
}
assert template["batch_size"] == {
"required": False,
@ -262,6 +282,7 @@ def test_openai(client: TestClient):
"name": "batch_size",
"type": "int",
"list": False,
"advanced": True,
}
assert template["request_timeout"] == {
"required": False,
@ -272,6 +293,7 @@ def test_openai(client: TestClient):
"name": "request_timeout",
"type": "Union[float, Tuple[float, float], NoneType]",
"list": False,
"advanced": True,
}
assert template["logit_bias"] == {
"required": False,
@ -282,6 +304,7 @@ def test_openai(client: TestClient):
"name": "logit_bias",
"type": "code",
"list": False,
"advanced": True,
}
assert template["max_retries"] == {
"required": False,
@ -293,6 +316,7 @@ def test_openai(client: TestClient):
"name": "max_retries",
"type": "int",
"list": False,
"advanced": True,
}
assert template["streaming"] == {
"required": False,
@ -304,6 +328,7 @@ def test_openai(client: TestClient):
"name": "streaming",
"type": "bool",
"list": False,
"advanced": True,
}
@ -326,6 +351,7 @@ def test_chat_open_ai(client: TestClient):
"name": "verbose",
"type": "bool",
"list": False,
"advanced": True,
}
assert template["client"] == {
"required": False,
@ -336,6 +362,7 @@ def test_chat_open_ai(client: TestClient):
"name": "client",
"type": "Any",
"list": False,
"advanced": True,
}
assert template["model_name"] == {
"required": False,
@ -348,6 +375,7 @@ def test_chat_open_ai(client: TestClient):
"name": "model_name",
"type": "str",
"list": True,
"advanced": False,
}
assert template["temperature"] == {
"required": False,
@ -359,6 +387,7 @@ def test_chat_open_ai(client: TestClient):
"name": "temperature",
"type": "float",
"list": False,
"advanced": False,
}
assert template["model_kwargs"] == {
"required": False,
@ -369,6 +398,7 @@ def test_chat_open_ai(client: TestClient):
"name": "model_kwargs",
"type": "code",
"list": False,
"advanced": True,
}
assert template["openai_api_key"] == {
"required": False,
@ -381,6 +411,7 @@ def test_chat_open_ai(client: TestClient):
"display_name": "OpenAI API Key",
"type": "str",
"list": False,
"advanced": False,
}
assert template["request_timeout"] == {
"required": False,
@ -392,6 +423,7 @@ def test_chat_open_ai(client: TestClient):
"name": "request_timeout",
"type": "int",
"list": False,
"advanced": True,
}
assert template["max_retries"] == {
"required": False,
@ -403,6 +435,7 @@ def test_chat_open_ai(client: TestClient):
"name": "max_retries",
"type": "int",
"list": False,
"advanced": True,
}
assert template["streaming"] == {
"required": False,
@ -414,6 +447,7 @@ def test_chat_open_ai(client: TestClient):
"name": "streaming",
"type": "bool",
"list": False,
"advanced": True,
}
assert template["n"] == {
"required": False,
@ -425,6 +459,7 @@ def test_chat_open_ai(client: TestClient):
"name": "n",
"type": "int",
"list": False,
"advanced": True,
}
assert template["max_tokens"] == {
@ -436,6 +471,7 @@ def test_chat_open_ai(client: TestClient):
"name": "max_tokens",
"type": "int",
"list": False,
"advanced": True,
}
assert template["_type"] == "ChatOpenAI"
assert (

View file

@ -27,6 +27,7 @@ def test_prompt_template(client: TestClient):
"name": "input_variables",
"type": "str",
"list": True,
"advanced": True,
}
assert template["output_parser"] == {
"required": False,
@ -37,6 +38,7 @@ def test_prompt_template(client: TestClient):
"name": "output_parser",
"type": "BaseOutputParser",
"list": False,
"advanced": True,
}
assert template["partial_variables"] == {
"required": False,
@ -47,6 +49,7 @@ def test_prompt_template(client: TestClient):
"name": "partial_variables",
"type": "code",
"list": False,
"advanced": True,
}
assert template["template"] == {
"required": True,
@ -57,6 +60,7 @@ def test_prompt_template(client: TestClient):
"name": "template",
"type": "prompt",
"list": False,
"advanced": True,
}
assert template["template_format"] == {
"required": False,
@ -68,6 +72,7 @@ def test_prompt_template(client: TestClient):
"name": "template_format",
"type": "str",
"list": False,
"advanced": True,
}
assert template["validate_template"] == {
"required": False,
@ -79,6 +84,7 @@ def test_prompt_template(client: TestClient):
"name": "validate_template",
"type": "bool",
"list": False,
"advanced": True,
}
@ -100,6 +106,7 @@ def test_few_shot_prompt_template(client: TestClient):
"name": "examples",
"type": "prompt",
"list": True,
"advanced": True,
}
assert template["example_selector"] == {
"required": False,
@ -110,6 +117,7 @@ def test_few_shot_prompt_template(client: TestClient):
"name": "example_selector",
"type": "BaseExampleSelector",
"list": False,
"advanced": True,
}
assert template["example_prompt"] == {
"required": True,
@ -120,6 +128,7 @@ def test_few_shot_prompt_template(client: TestClient):
"name": "example_prompt",
"type": "PromptTemplate",
"list": False,
"advanced": True,
}
assert template["suffix"] == {
"required": True,
@ -130,6 +139,7 @@ def test_few_shot_prompt_template(client: TestClient):
"name": "suffix",
"type": "prompt",
"list": False,
"advanced": True,
}
assert template["example_separator"] == {
"required": False,
@ -141,6 +151,7 @@ def test_few_shot_prompt_template(client: TestClient):
"name": "example_separator",
"type": "str",
"list": False,
"advanced": True,
}
assert template["prefix"] == {
"required": False,
@ -152,6 +163,7 @@ def test_few_shot_prompt_template(client: TestClient):
"name": "prefix",
"type": "prompt",
"list": False,
"advanced": True,
}
@ -172,6 +184,7 @@ def test_zero_shot_prompt(client: TestClient):
"name": "prefix",
"type": "str",
"list": False,
"advanced": True,
}
assert template["suffix"] == {
"required": True,
@ -183,6 +196,7 @@ def test_zero_shot_prompt(client: TestClient):
"name": "suffix",
"type": "str",
"list": False,
"advanced": True,
}
assert template["format_instructions"] == {
"required": False,
@ -194,4 +208,5 @@ def test_zero_shot_prompt(client: TestClient):
"name": "format_instructions",
"type": "str",
"list": False,
"advanced": True,
}