Merge remote-tracking branch 'origin/dev' into bug/component_share

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-12-10 11:58:13 -03:00
commit cdbf7b05eb
15 changed files with 164 additions and 148 deletions

View file

@ -129,7 +129,7 @@ def add_new_custom_field(
display_name=display_name,
**field_config,
)
template.get("template")[field_name] = new_field.to_dict()
template.get("template")[field_name] = new_field.model_dump(by_alias=True, exclude_none=True)
template.get("custom_fields")[field_name] = None
return template

View file

@ -1,11 +1,11 @@
from abc import ABC
from typing import Any, Optional, Union
from typing import Any, Optional
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict, Field, field_serializer
class TemplateFieldCreator(BaseModel, ABC):
field_type: str = "str"
class TemplateField(BaseModel):
model_config = ConfigDict()
field_type: str = Field(default="str", serialization_alias="type")
"""The type of field this is. Default is a string."""
required: bool = False
@ -14,7 +14,7 @@ class TemplateFieldCreator(BaseModel, ABC):
placeholder: str = ""
"""A placeholder string for the field. Default is an empty string."""
is_list: bool = False
is_list: bool = Field(default=False, serialization_alias="list")
"""Defines if the field is a list. Default is False."""
show: bool = True
@ -23,19 +23,19 @@ class TemplateFieldCreator(BaseModel, ABC):
multiline: bool = False
"""Defines if the field will allow the user to open a text editor. Default is False."""
value: Any = None
value: Any = ""
"""The value of the field. Default is None."""
file_types: list[str] = []
file_types: list[str] = Field(default=[], serialization_alias="fileTypes")
"""List of file types associated with the field. Default is an empty list. (duplicate)"""
file_path: Union[str, None] = None
file_path: Optional[str] = ""
"""The file path of the field if it is a file. Defaults to None."""
password: bool = False
"""Specifies if the field is a password. Defaults to False."""
options: list[str] = []
options: Optional[list[str]] = None
"""List of options for the field. Only used when is_list=True. Default is an empty list."""
name: str = ""
@ -47,7 +47,7 @@ class TemplateFieldCreator(BaseModel, ABC):
advanced: bool = False
"""Specifies if the field will an advanced parameter (hidden). Defaults to False."""
input_types: list[str] = []
input_types: Optional[list[str]] = None
"""List of input types for the handle when the field has more than one type. Default is an empty list."""
dynamic: bool = False
@ -60,21 +60,10 @@ class TemplateFieldCreator(BaseModel, ABC):
"""Specifies if the field should be refreshed. Defaults to False."""
def to_dict(self):
result = self.model_dump()
# Remove key if it is None
for key in list(result.keys()):
if result[key] is None or result[key] == [] and key != "value":
del result[key]
result["type"] = result.pop("field_type")
result["list"] = result.pop("is_list")
if result.get("file_types"):
result["fileTypes"] = result.pop("file_types")
return self.model_dump(by_alias=True, exclude_none=True)
@field_serializer("file_path")
def serialize_file_path(self, value):
if self.field_type == "file":
result["file_path"] = self.file_path
return result
class TemplateField(TemplateFieldCreator):
pass
return value
return ""

View file

@ -1,7 +1,6 @@
from typing import Optional
from langchain.agents import types
from langflow.template.field.base import TemplateField
from langflow.template.frontend_node.base import FrontendNode
from langflow.template.template.base import Template
@ -29,17 +28,17 @@ class SQLAgentNode(FrontendNode):
type_name="sql_agent",
fields=[
TemplateField(
field_type="str",
field_type="str", # pyright: ignore
required=True,
placeholder="",
is_list=False,
is_list=False, # pyright: ignore
show=True,
multiline=False,
value="",
name="database_uri",
),
TemplateField(
field_type="BaseLanguageModel",
field_type="BaseLanguageModel", # pyright: ignore
required=True,
show=True,
name="llm",
@ -50,9 +49,6 @@ class SQLAgentNode(FrontendNode):
description: str = """Construct an SQL agent from an LLM and tools."""
base_classes: list[str] = ["AgentExecutor"]
def to_dict(self):
return super().to_dict()
class VectorStoreRouterAgentNode(FrontendNode):
name: str = "VectorStoreRouterAgent"
@ -60,14 +56,14 @@ class VectorStoreRouterAgentNode(FrontendNode):
type_name="vectorstorerouter_agent",
fields=[
TemplateField(
field_type="VectorStoreRouterToolkit",
field_type="VectorStoreRouterToolkit", # pyright: ignore
required=True,
show=True,
name="vectorstoreroutertoolkit",
display_name="Vector Store Router Toolkit",
),
TemplateField(
field_type="BaseLanguageModel",
field_type="BaseLanguageModel", # pyright: ignore
required=True,
show=True,
name="llm",
@ -78,9 +74,6 @@ class VectorStoreRouterAgentNode(FrontendNode):
description: str = """Construct an agent from a Vector Store Router."""
base_classes: list[str] = ["AgentExecutor"]
def to_dict(self):
return super().to_dict()
class VectorStoreAgentNode(FrontendNode):
name: str = "VectorStoreAgent"
@ -88,14 +81,14 @@ class VectorStoreAgentNode(FrontendNode):
type_name="vectorstore_agent",
fields=[
TemplateField(
field_type="VectorStoreInfo",
field_type="VectorStoreInfo", # pyright: ignore
required=True,
show=True,
name="vectorstoreinfo",
display_name="Vector Store Info",
),
TemplateField(
field_type="BaseLanguageModel",
field_type="BaseLanguageModel", # pyright: ignore
required=True,
show=True,
name="llm",
@ -106,9 +99,6 @@ class VectorStoreAgentNode(FrontendNode):
description: str = """Construct an agent from a Vector Store."""
base_classes: list[str] = ["AgentExecutor"]
def to_dict(self):
return super().to_dict()
class SQLDatabaseNode(FrontendNode):
name: str = "SQLDatabase"
@ -116,9 +106,9 @@ class SQLDatabaseNode(FrontendNode):
type_name="sql_database",
fields=[
TemplateField(
field_type="str",
field_type="str", # pyright: ignore
required=True,
is_list=False,
is_list=False, # pyright: ignore
show=True,
multiline=False,
value="",
@ -129,9 +119,6 @@ class SQLDatabaseNode(FrontendNode):
description: str = """SQLAlchemy wrapper around a database."""
base_classes: list[str] = ["SQLDatabase"]
def to_dict(self):
return super().to_dict()
class CSVAgentNode(FrontendNode):
name: str = "CSVAgent"
@ -139,15 +126,15 @@ class CSVAgentNode(FrontendNode):
type_name="csv_agent",
fields=[
TemplateField(
field_type="file",
field_type="file", # pyright: ignore
required=True,
show=True,
name="path",
value="",
file_types=[".csv"],
file_types=[".csv"], # pyright: ignore
),
TemplateField(
field_type="BaseLanguageModel",
field_type="BaseLanguageModel", # pyright: ignore
required=True,
show=True,
name="llm",
@ -158,9 +145,6 @@ class CSVAgentNode(FrontendNode):
description: str = """Construct a CSV agent from a CSV and tools."""
base_classes: list[str] = ["AgentExecutor"]
def to_dict(self):
return super().to_dict()
class InitializeAgentNode(FrontendNode):
name: str = "AgentInitializer"
@ -169,9 +153,9 @@ class InitializeAgentNode(FrontendNode):
type_name="initialize_agent",
fields=[
TemplateField(
field_type="str",
field_type="str", # pyright: ignore
required=True,
is_list=True,
is_list=True, # pyright: ignore
show=True,
multiline=False,
options=list(NON_CHAT_AGENTS.keys()),
@ -180,22 +164,22 @@ class InitializeAgentNode(FrontendNode):
advanced=False,
),
TemplateField(
field_type="BaseChatMemory",
field_type="BaseChatMemory", # pyright: ignore
required=False,
show=True,
name="memory",
advanced=False,
),
TemplateField(
field_type="Tool",
field_type="Tool", # pyright: ignore
required=True,
show=True,
name="tools",
is_list=True,
is_list=True, # pyright: ignore
advanced=False,
),
TemplateField(
field_type="BaseLanguageModel",
field_type="BaseLanguageModel", # pyright: ignore
required=True,
show=True,
name="llm",
@ -207,9 +191,6 @@ class InitializeAgentNode(FrontendNode):
description: str = """Construct a zero shot agent from an LLM and tools."""
base_classes: list[str] = ["AgentExecutor", "Callable"]
def to_dict(self):
return super().to_dict()
@staticmethod
def format_field(field: TemplateField, name: Optional[str] = None) -> None:
# do nothing and don't return anything
@ -222,13 +203,13 @@ class JsonAgentNode(FrontendNode):
type_name="json_agent",
fields=[
TemplateField(
field_type="BaseToolkit",
field_type="BaseToolkit", # pyright: ignore
required=True,
show=True,
name="toolkit",
),
TemplateField(
field_type="BaseLanguageModel",
field_type="BaseLanguageModel", # pyright: ignore
required=True,
show=True,
name="llm",
@ -238,6 +219,3 @@ class JsonAgentNode(FrontendNode):
)
description: str = """Construct a json agent from an LLM and tools."""
base_classes: list[str] = ["AgentExecutor"]
def to_dict(self):
return super().to_dict()

View file

@ -7,7 +7,7 @@ from langflow.template.frontend_node.constants import CLASSES_TO_REMOVE, FORCE_S
from langflow.template.frontend_node.formatter import field_formatters
from langflow.template.template.base import Template
from langflow.utils import constants
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, field_serializer, model_serializer
class FieldFormatters(BaseModel):
@ -63,26 +63,32 @@ class FrontendNode(BaseModel):
"""Sets the documentation of the frontend node."""
self.documentation = documentation
def process_base_classes(self) -> None:
@field_serializer("base_classes")
def process_base_classes(self, base_classes: List[str]) -> List[str]:
"""Removes unwanted base classes from the list of base classes."""
self.base_classes = [base_class for base_class in self.base_classes if base_class not in CLASSES_TO_REMOVE]
return [base_class for base_class in base_classes if base_class not in CLASSES_TO_REMOVE]
@field_serializer("display_name")
def process_display_name(self, display_name: str) -> str:
"""Sets the display name of the frontend node."""
return display_name or self.name
@model_serializer(mode="wrap")
def serialize(self, handler):
result = handler(self)
if hasattr(self, "template") and hasattr(self.template, "to_dict"):
result["template"] = self.template.to_dict(self.format_field)
name = result.pop("name")
return {name: result}
# For backwards compatibility
def to_dict(self) -> dict:
"""Returns a dict representation of the frontend node."""
self.process_base_classes()
return {
self.name: {
"template": self.template.to_dict(self.format_field),
"description": self.description,
"base_classes": self.base_classes,
"display_name": self.display_name or self.name,
"custom_fields": self.custom_fields,
"output_types": self.output_types,
"documentation": self.documentation,
"beta": self.beta,
"error": self.error,
},
}
return self.model_dump(by_alias=True, exclude_none=True)
def add_extra_fields(self) -> None:
pass

View file

@ -247,9 +247,6 @@ class CombineDocsChainNode(FrontendNode):
description: str = """Load question answering chain."""
base_classes: list[str] = ["BaseCombineDocumentsChain", "Callable"]
def to_dict(self):
return super().to_dict()
@staticmethod
def format_field(field: TemplateField, name: Optional[str] = None) -> None:
# do nothing and don't return anything

View file

@ -1,5 +1,7 @@
from typing import Optional
from pydantic import field_serializer
from langflow.template.field.base import TemplateField
from langflow.template.frontend_node.base import FrontendNode
from langflow.template.template.base import Template
@ -67,19 +69,8 @@ class CustomComponentFrontendNode(FrontendNode):
description: Optional[str] = None
base_classes: list[str] = []
def to_dict(self) -> dict:
"""Returns a dict representation of the frontend node."""
self.process_base_classes()
return {
self.name: {
"template": self.template.to_dict(self.format_field),
"description": self.description,
"base_classes": self.base_classes,
"display_name": self.display_name,
"custom_fields": self.custom_fields,
"output_types": self.output_types,
"documentation": self.documentation,
"beta": self.beta,
"error": self.error,
},
}
@field_serializer("display_name")
def process_display_name(self, display_name: str) -> str:
"""Sets the display name of the frontend node."""
return display_name

View file

@ -129,7 +129,7 @@ class MultilineFieldFormatter(FieldFormatter):
class DefaultValueFormatter(FieldFormatter):
def format(self, field: TemplateField, name: Optional[str] = None) -> None:
value = field.to_dict()
value = field.model_dump(by_alias=True, exclude_none=True)
if "default" in value:
field.value = value["default"]
@ -144,7 +144,7 @@ class HeadersDefaultValueFormatter(FieldFormatter):
class DictCodeFileFormatter(FieldFormatter):
def format(self, field: TemplateField, name: Optional[str] = None) -> None:
key = field.name
value = field.to_dict()
value = field.model_dump(by_alias=True, exclude_none=True)
_type = value["type"]
if "dict" in _type.lower() and key == "dict_":
field.field_type = "file"

View file

@ -1,14 +1,9 @@
from typing import Optional
from langchain.agents.mrkl import prompt
from langflow.template.frontend_node.constants import (
DEFAULT_PROMPT,
HUMAN_PROMPT,
SYSTEM_PROMPT,
)
from langflow.template.field.base import TemplateField
from langflow.template.frontend_node.base import FrontendNode
from langflow.template.frontend_node.constants import DEFAULT_PROMPT, HUMAN_PROMPT, SYSTEM_PROMPT
from langflow.template.template.base import Template
@ -50,9 +45,6 @@ class PromptTemplateNode(FrontendNode):
description: str
base_classes: list[str] = ["BasePromptTemplate"]
def to_dict(self):
return super().to_dict()
@staticmethod
def format_field(field: TemplateField, name: Optional[str] = None) -> None:
FrontendNode.format_field(field, name)
@ -66,9 +58,6 @@ class BasePromptFrontendNode(FrontendNode):
description: str
base_classes: list[str]
def to_dict(self):
return super().to_dict()
class ZeroShotPromptNode(BasePromptFrontendNode):
name: str = "ZeroShotPrompt"
@ -110,9 +99,6 @@ class ZeroShotPromptNode(BasePromptFrontendNode):
description: str = "Prompt template for Zero Shot Agent."
base_classes: list[str] = ["BasePromptTemplate"]
def to_dict(self):
return super().to_dict()
@staticmethod
def format_field(field: TemplateField, name: Optional[str] = None) -> None:
PromptFrontendNode.format_field(field, name)

View file

@ -1,9 +1,7 @@
from langflow.template.field.base import TemplateField
from langflow.template.frontend_node.base import FrontendNode
from langflow.template.template.base import Template
from langflow.utils.constants import (
DEFAULT_PYTHON_FUNCTION,
)
from langflow.utils.constants import DEFAULT_PYTHON_FUNCTION
class ToolNode(FrontendNode):
@ -57,9 +55,6 @@ class ToolNode(FrontendNode):
description: str = "Converts a chain, agent or function into a tool."
base_classes: list[str] = ["Tool", "BaseTool"]
def to_dict(self):
return super().to_dict()
class PythonFunctionToolNode(FrontendNode):
name: str = "PythonFunctionTool"
@ -113,9 +108,6 @@ class PythonFunctionToolNode(FrontendNode):
description: str = "Python function to be executed."
base_classes: list[str] = ["BaseTool", "Tool"]
def to_dict(self):
return super().to_dict()
class PythonFunctionNode(FrontendNode):
name: str = "PythonFunction"
@ -136,6 +128,3 @@ class PythonFunctionNode(FrontendNode):
)
description: str = "Python function to be executed."
base_classes: list[str] = ["Callable"]
def to_dict(self):
return super().to_dict()

View file

@ -1,9 +1,8 @@
from typing import Callable, Optional, Union
from pydantic import BaseModel
from typing import Callable, Union
from langflow.template.field.base import TemplateField
from langflow.utils.constants import DIRECT_TYPES
from pydantic import BaseModel, model_serializer
class Template(BaseModel):
@ -12,12 +11,11 @@ class Template(BaseModel):
def process_fields(
self,
name: Optional[str] = None,
format_field_func: Union[Callable, None] = None,
):
if format_field_func:
for field in self.fields:
format_field_func(field, name)
format_field_func(field, self.type_name)
def sort_fields(self):
# first sort alphabetically
@ -25,12 +23,19 @@ class Template(BaseModel):
self.fields.sort(key=lambda x: x.name)
self.fields.sort(key=lambda x: x.field_type in DIRECT_TYPES, reverse=False)
def to_dict(self, format_field_func=None):
self.process_fields(self.type_name, format_field_func)
self.sort_fields()
result = {field.name: field.to_dict() for field in self.fields}
result["_type"] = self.type_name # type: ignore
@model_serializer(mode="wrap")
def serialize_model(self, handler):
result = handler(self)
for field in self.fields:
result[field.name] = field.model_dump(by_alias=True, exclude_none=True)
result["_type"] = result.pop("type_name")
return result
# For backwards compatibility
def to_dict(self, format_field_func=None):
self.process_fields(format_field_func)
self.sort_fields()
return self.model_dump(by_alias=True, exclude_none=True, exclude={"fields"})
def add_field(self, field: TemplateField) -> None:
self.fields.append(field)

View file

@ -28,6 +28,7 @@ def test_zero_shot_agent(client: TestClient, logged_in_headers):
"list": True,
"advanced": False,
"info": "",
"fileTypes": [],
}
# Additional assertions for other template variables
@ -43,6 +44,7 @@ def test_zero_shot_agent(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["llm"] == {
"required": True,
@ -56,6 +58,7 @@ def test_zero_shot_agent(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["output_parser"] == {
"required": False,
@ -69,6 +72,7 @@ def test_zero_shot_agent(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["input_variables"] == {
"required": False,
@ -82,6 +86,7 @@ def test_zero_shot_agent(client: TestClient, logged_in_headers):
"list": True,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["prefix"] == {
"required": False,
@ -96,6 +101,7 @@ def test_zero_shot_agent(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["suffix"] == {
"required": False,
@ -110,6 +116,7 @@ def test_zero_shot_agent(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
@ -135,6 +142,9 @@ def test_json_agent(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"file_path": "",
"fileTypes": [],
"value": "",
}
assert template["llm"] == {
"required": True,
@ -149,6 +159,9 @@ def test_json_agent(client: TestClient, logged_in_headers):
"advanced": False,
"display_name": "LLM",
"info": "",
"file_path": "",
"fileTypes": [],
"value": "",
}
@ -174,7 +187,7 @@ def test_csv_agent(client: TestClient, logged_in_headers):
"name": "path",
"type": "file",
"list": False,
"file_path": None,
"file_path": "",
"advanced": False,
"info": "",
}
@ -191,4 +204,7 @@ def test_csv_agent(client: TestClient, logged_in_headers):
"advanced": False,
"display_name": "LLM",
"info": "",
"file_path": "",
"fileTypes": [],
"value": "",
}

View file

@ -35,6 +35,7 @@ def test_llm_checker_chain(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["_type"] == "LLMCheckerChain"
@ -69,6 +70,7 @@ def test_llm_math_chain(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["verbose"] == {
"required": False,
@ -83,6 +85,7 @@ def test_llm_math_chain(client: TestClient, logged_in_headers):
"list": False,
"advanced": True,
"info": "",
"fileTypes": [],
}
assert template["llm"] == {
"required": True,
@ -96,6 +99,7 @@ def test_llm_math_chain(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["input_key"] == {
"required": True,
@ -110,6 +114,7 @@ def test_llm_math_chain(client: TestClient, logged_in_headers):
"list": False,
"advanced": True,
"info": "",
"fileTypes": [],
}
assert template["output_key"] == {
"required": True,
@ -124,6 +129,7 @@ def test_llm_math_chain(client: TestClient, logged_in_headers):
"list": False,
"advanced": True,
"info": "",
"fileTypes": [],
}
assert template["_type"] == "LLMMathChain"
@ -163,6 +169,9 @@ def test_series_character_chain(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
"file_path": "",
"value": "",
}
assert template["character"] == {
"required": True,
@ -176,6 +185,9 @@ def test_series_character_chain(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
"file_path": "",
"value": "",
}
assert template["series"] == {
"required": True,
@ -189,6 +201,9 @@ def test_series_character_chain(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
"file_path": "",
"value": "",
}
assert template["_type"] == "SeriesCharacterChain"
@ -232,6 +247,9 @@ def test_mid_journey_prompt_chain(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"file_path": "",
"fileTypes": [],
"value": "",
}
# Test the description object
assert chain["description"] == "MidJourneyPromptChain is a chain you can use to generate new MidJourney prompts."
@ -270,6 +288,9 @@ def test_time_travel_guide_chain(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"file_path": "",
"fileTypes": [],
"value": "",
}
assert template["memory"] == {
"required": False,
@ -283,6 +304,9 @@ def test_time_travel_guide_chain(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"file_path": "",
"fileTypes": [],
"value": "",
}
assert chain["description"] == "Time travel guide chain."

View file

@ -31,9 +31,9 @@ def test_template_field_defaults(sample_template_field: TemplateField):
assert sample_template_field.is_list is False
assert sample_template_field.show is True
assert sample_template_field.multiline is False
assert sample_template_field.value is None
assert sample_template_field.value == ""
assert sample_template_field.file_types == []
assert sample_template_field.file_path is None
assert sample_template_field.file_path == ""
assert sample_template_field.password is False
assert sample_template_field.name == "test_field"

View file

@ -22,6 +22,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["verbose"] == {
"required": False,
@ -35,6 +36,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["client"] == {
"required": False,
@ -48,6 +50,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["model_name"] == {
"required": False,
@ -69,6 +72,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": True,
"advanced": False,
"info": "",
"fileTypes": [],
}
# Add more assertions for other properties here
assert template["temperature"] == {
@ -84,6 +88,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["max_tokens"] == {
"required": False,
@ -98,6 +103,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["top_p"] == {
"required": False,
@ -112,6 +118,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["frequency_penalty"] == {
"required": False,
@ -126,6 +133,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["presence_penalty"] == {
"required": False,
@ -140,6 +148,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["n"] == {
"required": False,
@ -154,6 +163,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["best_of"] == {
"required": False,
@ -168,6 +178,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["model_kwargs"] == {
"required": False,
@ -181,6 +192,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": True,
"info": "",
"fileTypes": [],
}
assert template["openai_api_key"] == {
"required": False,
@ -196,6 +208,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["batch_size"] == {
"required": False,
@ -210,6 +223,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["request_timeout"] == {
"required": False,
@ -223,6 +237,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["logit_bias"] == {
"required": False,
@ -236,6 +251,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["max_retries"] == {
"required": False,
@ -250,6 +266,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["streaming"] == {
"required": False,
@ -264,6 +281,7 @@ def test_openai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
@ -289,6 +307,7 @@ def test_chat_open_ai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["client"] == {
"required": False,
@ -302,6 +321,7 @@ def test_chat_open_ai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["model_name"] == {
"required": False,
@ -324,6 +344,7 @@ def test_chat_open_ai(client: TestClient, logged_in_headers):
"list": True,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["temperature"] == {
"required": False,
@ -338,6 +359,7 @@ def test_chat_open_ai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["model_kwargs"] == {
"required": False,
@ -351,6 +373,7 @@ def test_chat_open_ai(client: TestClient, logged_in_headers):
"list": False,
"advanced": True,
"info": "",
"fileTypes": [],
}
assert template["openai_api_key"] == {
"required": False,
@ -366,6 +389,7 @@ def test_chat_open_ai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["request_timeout"] == {
"required": False,
@ -379,6 +403,7 @@ def test_chat_open_ai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["max_retries"] == {
"required": False,
@ -393,6 +418,7 @@ def test_chat_open_ai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["streaming"] == {
"required": False,
@ -407,6 +433,7 @@ def test_chat_open_ai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["n"] == {
"required": False,
@ -421,6 +448,7 @@ def test_chat_open_ai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["max_tokens"] == {
@ -435,6 +463,7 @@ def test_chat_open_ai(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["_type"] == "ChatOpenAI"
assert (

View file

@ -31,6 +31,7 @@ def test_prompt_template(client: TestClient, logged_in_headers):
"list": True,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["output_parser"] == {
@ -45,6 +46,7 @@ def test_prompt_template(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["partial_variables"] == {
@ -59,6 +61,7 @@ def test_prompt_template(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["template"] == {
@ -73,6 +76,7 @@ def test_prompt_template(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["template_format"] == {
@ -88,6 +92,7 @@ def test_prompt_template(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}
assert template["validate_template"] == {
@ -103,4 +108,5 @@ def test_prompt_template(client: TestClient, logged_in_headers):
"list": False,
"advanced": False,
"info": "",
"fileTypes": [],
}