refactor: Update output names in TextInput, TextOutput, RecordsOutput, ChatInput, and ChatOutput
This commit is contained in:
parent
472c8737dd
commit
834570df8b
3 changed files with 15 additions and 12 deletions
|
|
@ -6,7 +6,7 @@ from langchain.memory.chat_memory import BaseChatMemory
|
|||
from langchain_core.document_loaders import BaseLoader
|
||||
from langchain_core.documents import Document
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.language_models import BaseLLM, BaseLanguageModel
|
||||
from langchain_core.language_models import BaseLanguageModel, BaseLLM
|
||||
from langchain_core.memory import BaseMemory
|
||||
from langchain_core.output_parsers import BaseOutputParser
|
||||
from langchain_core.prompts import BasePromptTemplate, ChatPromptTemplate, PromptTemplate
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ class InterfaceVertex(ComponentVertex):
|
|||
if isinstance(message, str):
|
||||
message = unescape_string(message)
|
||||
stream_url = None
|
||||
text_output = self.results["Message"]
|
||||
text_output = self.results["message"]
|
||||
if isinstance(text_output, (AIMessage, AIMessageChunk)):
|
||||
artifacts = ChatOutputResponse.from_message(
|
||||
text_output,
|
||||
|
|
@ -173,8 +173,8 @@ class InterfaceVertex(ComponentVertex):
|
|||
elif isinstance(message, (AsyncIterator, Iterator)):
|
||||
stream_url = self.build_stream_url()
|
||||
message = ""
|
||||
self.results["Message"] = message
|
||||
self.results["Record"].message = message
|
||||
self.results["message"] = message
|
||||
self.results["record"].message = message
|
||||
self._built_object = self.results
|
||||
elif not isinstance(text_output, str):
|
||||
message = str(text_output)
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class Input(BaseModel):
|
|||
def serialize_model(self, handler):
|
||||
result = handler(self)
|
||||
# If the field is str, we add the Text input type
|
||||
if self.field_type in [str, Text]:
|
||||
if self.field_type in ["str", "Text"]:
|
||||
if "input_types" not in result:
|
||||
result["input_types"] = ["Text"]
|
||||
if self.field_type == Text:
|
||||
|
|
@ -110,7 +110,10 @@ class Input(BaseModel):
|
|||
# this should be done for all types
|
||||
# How to check if v is a type?
|
||||
if isinstance(v, (type, GenericAlias)):
|
||||
return str(v)
|
||||
if isinstance(v, type):
|
||||
v = v.__name__
|
||||
else:
|
||||
v = str(v)
|
||||
elif not isinstance(v, str):
|
||||
raise ValueError(f"type must be a string or a type, not {type(v)}")
|
||||
return v
|
||||
|
|
@ -144,19 +147,19 @@ class Input(BaseModel):
|
|||
|
||||
|
||||
class Output(BaseModel):
|
||||
types: Optional[list[str]] = Field(default=[], serialization_alias="types")
|
||||
types: Optional[list[str]] = Field(default=[])
|
||||
"""List of output types for the field."""
|
||||
|
||||
selected: Optional[str] = Field(default=None, serialization_alias="selected")
|
||||
selected: Optional[str] = Field(default=None)
|
||||
"""The selected output type for the field."""
|
||||
|
||||
name: str = Field(default=None)
|
||||
"""The name of the field."""
|
||||
|
||||
display_name: Optional[str] = Field(default=None)
|
||||
"""The display name of the field."""
|
||||
|
||||
name: str = Field(default=None, serialization_alias="name")
|
||||
"""The name of the field."""
|
||||
|
||||
method: Optional[str] = Field(default=None, serialization_alias="method")
|
||||
method: Optional[str] = Field(default=None)
|
||||
"""The method to use for the output."""
|
||||
|
||||
def to_dict(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue