diff --git a/src/backend/base/langflow/base/io/text.py b/src/backend/base/langflow/base/io/text.py index 5b1a6678b..93ccac528 100644 --- a/src/backend/base/langflow/base/io/text.py +++ b/src/backend/base/langflow/base/io/text.py @@ -12,16 +12,29 @@ class TextComponent(CustomComponent): def build_config(self): return { - "input_value": {"display_name": "Value", "input_types": ["Record"], "info": "Text or Record to be passed."}, - "record_template": {"display_name": "Record Template", "multiline": True}, + "input_value": { + "display_name": "Value", + "input_types": ["Text", "Record"], + "info": "Text or Record to be passed.", + }, + "record_template": { + "display_name": "Record Template", + "multiline": True, + "info": "Template to convert Record to Text. If left empty, it will be dynamically set to the Record's text key.", + "advanced": True, + }, } def build( self, input_value: Optional[Union[Text, Record]] = "", - record_template: Optional[str] = "Text: {text}\nData: {data}", + record_template: Optional[str] = "{text}", ) -> Text: if isinstance(input_value, Record): + if record_template == "": + # it should be dynamically set to the Record's .text_key value + # meaning, if text_key = "bacon", then record_template = "{bacon}" + record_template = "{" + input_value.text_key + "}" input_value = records_to_text(template=record_template, records=input_value) self.status = input_value if not input_value: diff --git a/src/backend/base/langflow/base/models/model.py b/src/backend/base/langflow/base/models/model.py index 7bbd614d6..b8ef38e07 100644 --- a/src/backend/base/langflow/base/models/model.py +++ b/src/backend/base/langflow/base/models/model.py @@ -35,6 +35,8 @@ class LCModelComponent(CustomComponent): self, runnable: BaseChatModel, stream: bool, input_value: str, system_message: Optional[str] = None ): messages: list[Union[HumanMessage, SystemMessage]] = [] + if not input_value and not system_message: + raise ValueError("The message you want to send to the model is empty.") if system_message: messages.append(SystemMessage(content=system_message)) if input_value: diff --git a/src/backend/base/langflow/components/helpers/SplitText.py b/src/backend/base/langflow/components/helpers/SplitText.py index ad80c4947..ac8c6fe29 100644 --- a/src/backend/base/langflow/components/helpers/SplitText.py +++ b/src/backend/base/langflow/components/helpers/SplitText.py @@ -9,7 +9,7 @@ from langchain_core.documents import Document from langflow.interface.custom.custom_component import CustomComponent from langflow.schema import Record from langflow.field_typing import Text -from langflow.utils.util import build_loader_repr_from_records, unescape_string +from langflow.utils.util import unescape_string class SplitTextComponent(CustomComponent): @@ -54,7 +54,6 @@ class SplitTextComponent(CustomComponent): chunk_overlap: Optional[int] = 200, recursive: bool = False, ) -> list[Record]: - separators = [unescape_string(x) for x in separators] # Make sure chunk_size and chunk_overlap are ints diff --git a/src/backend/base/langflow/components/inputs/TextInput.py b/src/backend/base/langflow/components/inputs/TextInput.py index 3db9777c6..dc6d16368 100644 --- a/src/backend/base/langflow/components/inputs/TextInput.py +++ b/src/backend/base/langflow/components/inputs/TextInput.py @@ -13,15 +13,20 @@ class TextInput(TextComponent): return { "input_value": { "display_name": "Value", - "input_types": ["Record"], + "input_types": ["Text", "Record"], "info": "Text or Record to be passed as input.", }, - "record_template": {"display_name": "Record Template", "multiline": True}, + "record_template": { + "display_name": "Record Template", + "multiline": True, + "info": "Template to convert Record to Text. If left empty, it will be dynamically set to the Record's text key.", + "advanced": True, + }, } def build( self, input_value: Optional[str] = "", - record_template: Optional[str] = "{text}", + record_template: Optional[str] = "", ) -> Text: return super().build(input_value=input_value, record_template=record_template) diff --git a/src/backend/base/langflow/components/outputs/TextOutput.py b/src/backend/base/langflow/components/outputs/TextOutput.py index b3917966b..d36baa497 100644 --- a/src/backend/base/langflow/components/outputs/TextOutput.py +++ b/src/backend/base/langflow/components/outputs/TextOutput.py @@ -16,8 +16,13 @@ class TextOutput(TextComponent): "input_types": ["Record"], "info": "Text or Record to be passed as output.", }, - "record_template": {"display_name": "Record Template", "multiline": True}, + "record_template": { + "display_name": "Record Template", + "multiline": True, + "info": "Template to convert Record to Text. If left empty, it will be dynamically set to the Record's text key.", + "advanced": True, + }, } - def build(self, input_value: Optional[Text] = "", record_template: str = "{text}") -> Text: + def build(self, input_value: Optional[Text] = "", record_template: str = "") -> Text: return super().build(input_value=input_value, record_template=record_template) diff --git a/src/backend/base/langflow/graph/graph/base.py b/src/backend/base/langflow/graph/graph/base.py index 845062237..909acfa2e 100644 --- a/src/backend/base/langflow/graph/graph/base.py +++ b/src/backend/base/langflow/graph/graph/base.py @@ -603,8 +603,7 @@ class Graph: # This is a hack to make sure that the LLM vertex is sent to # the toolkit vertex self._build_vertex_params() - # remove invalid vertices - self._validate_vertices() + # Now that we have the vertices and edges # We need to map the vertices that are connected to # to ChatVertex instances @@ -631,14 +630,6 @@ class Graph: if isinstance(vertex, ToolkitVertex): vertex.params["llm"] = llm_vertex - def _validate_vertices(self) -> None: - """Check that all vertices have edges""" - if len(self.vertices) == 1: - return - for vertex in self.vertices: - if not self._validate_vertex(vertex): - raise ValueError(f"{vertex.display_name} is not connected to any other components") - def _validate_vertex(self, vertex: Vertex) -> bool: """Validates a vertex.""" # All vertices that do not have edges are invalid diff --git a/src/frontend/src/components/EditFlowSettingsComponent/index.tsx b/src/frontend/src/components/EditFlowSettingsComponent/index.tsx index 919a2e68a..94ee4f19e 100644 --- a/src/frontend/src/components/EditFlowSettingsComponent/index.tsx +++ b/src/frontend/src/components/EditFlowSettingsComponent/index.tsx @@ -74,12 +74,11 @@ export const EditFlowSettings: React.FC = ({ onChange={handleDescriptionChange} value={description!} placeholder="Flow description" - className="mt-2 max-h-[100px] font-normal resize-none" + className="mt-2 max-h-[100px] resize-none font-normal" rows={3} onDoubleClickCapture={(event) => { handleFocus(event); }} - /> ) : ( \ No newline at end of file diff --git a/src/frontend/src/icons/GoogleGenerativeAI/GoogleGemini.jsx b/src/frontend/src/icons/GoogleGenerativeAI/GoogleGemini.jsx new file mode 100644 index 000000000..dcd531ebb --- /dev/null +++ b/src/frontend/src/icons/GoogleGenerativeAI/GoogleGemini.jsx @@ -0,0 +1,10 @@ +const SvgGoogleGenerativeAI = (props) => ( + + + + + + + +); +export default SvgGoogleGenerativeAI; diff --git a/src/frontend/src/icons/GoogleGenerativeAI/index.tsx b/src/frontend/src/icons/GoogleGenerativeAI/index.tsx new file mode 100644 index 000000000..2123f129d --- /dev/null +++ b/src/frontend/src/icons/GoogleGenerativeAI/index.tsx @@ -0,0 +1,9 @@ +import React, { forwardRef } from "react"; +import SvgGoogleGenerativeAI from "./GoogleGemini"; + +export const GoogleGenerativeAIIcon = forwardRef< + SVGSVGElement, + React.PropsWithChildren<{}> +>((props, ref) => { + return ; +}); diff --git a/src/frontend/src/utils/styleUtils.ts b/src/frontend/src/utils/styleUtils.ts index f298e8a6a..8594fa1b1 100644 --- a/src/frontend/src/utils/styleUtils.ts +++ b/src/frontend/src/utils/styleUtils.ts @@ -151,6 +151,7 @@ import { EvernoteIcon } from "../icons/Evernote"; import { FBIcon } from "../icons/FacebookMessenger"; import { GitBookIcon } from "../icons/GitBook"; import { GoogleIcon } from "../icons/Google"; +import { GoogleGenerativeAIIcon } from "../icons/GoogleGenerativeAI"; import { GradientInfinity, GradientSave, @@ -328,6 +329,7 @@ export const nodeIconsLucide: iconsType = { GoogleSearchResults: GoogleIcon, GoogleSearchRun: GoogleIcon, Google: GoogleIcon, + GoogleGenerativeAI: GoogleGenerativeAIIcon, HNLoader: HackerNewsIcon, HuggingFaceHub: HuggingFaceIcon, HuggingFace: HuggingFaceIcon,