Merge branch 'zustand/io/migration' of personal:logspace-ai/langflow into zustand/io/migration
This commit is contained in:
commit
782ec35e20
11 changed files with 58 additions and 22 deletions
|
|
@ -12,16 +12,29 @@ class TextComponent(CustomComponent):
|
||||||
|
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
return {
|
return {
|
||||||
"input_value": {"display_name": "Value", "input_types": ["Record"], "info": "Text or Record to be passed."},
|
"input_value": {
|
||||||
"record_template": {"display_name": "Record Template", "multiline": True},
|
"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(
|
def build(
|
||||||
self,
|
self,
|
||||||
input_value: Optional[Union[Text, Record]] = "",
|
input_value: Optional[Union[Text, Record]] = "",
|
||||||
record_template: Optional[str] = "Text: {text}\nData: {data}",
|
record_template: Optional[str] = "{text}",
|
||||||
) -> Text:
|
) -> Text:
|
||||||
if isinstance(input_value, Record):
|
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)
|
input_value = records_to_text(template=record_template, records=input_value)
|
||||||
self.status = input_value
|
self.status = input_value
|
||||||
if not input_value:
|
if not input_value:
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,8 @@ class LCModelComponent(CustomComponent):
|
||||||
self, runnable: BaseChatModel, stream: bool, input_value: str, system_message: Optional[str] = None
|
self, runnable: BaseChatModel, stream: bool, input_value: str, system_message: Optional[str] = None
|
||||||
):
|
):
|
||||||
messages: list[Union[HumanMessage, SystemMessage]] = []
|
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:
|
if system_message:
|
||||||
messages.append(SystemMessage(content=system_message))
|
messages.append(SystemMessage(content=system_message))
|
||||||
if input_value:
|
if input_value:
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ from langchain_core.documents import Document
|
||||||
from langflow.interface.custom.custom_component import CustomComponent
|
from langflow.interface.custom.custom_component import CustomComponent
|
||||||
from langflow.schema import Record
|
from langflow.schema import Record
|
||||||
from langflow.field_typing import Text
|
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):
|
class SplitTextComponent(CustomComponent):
|
||||||
|
|
@ -54,7 +54,6 @@ class SplitTextComponent(CustomComponent):
|
||||||
chunk_overlap: Optional[int] = 200,
|
chunk_overlap: Optional[int] = 200,
|
||||||
recursive: bool = False,
|
recursive: bool = False,
|
||||||
) -> list[Record]:
|
) -> list[Record]:
|
||||||
|
|
||||||
separators = [unescape_string(x) for x in separators]
|
separators = [unescape_string(x) for x in separators]
|
||||||
|
|
||||||
# Make sure chunk_size and chunk_overlap are ints
|
# Make sure chunk_size and chunk_overlap are ints
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,20 @@ class TextInput(TextComponent):
|
||||||
return {
|
return {
|
||||||
"input_value": {
|
"input_value": {
|
||||||
"display_name": "Value",
|
"display_name": "Value",
|
||||||
"input_types": ["Record"],
|
"input_types": ["Text", "Record"],
|
||||||
"info": "Text or Record to be passed as input.",
|
"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(
|
def build(
|
||||||
self,
|
self,
|
||||||
input_value: Optional[str] = "",
|
input_value: Optional[str] = "",
|
||||||
record_template: Optional[str] = "{text}",
|
record_template: Optional[str] = "",
|
||||||
) -> Text:
|
) -> Text:
|
||||||
return super().build(input_value=input_value, record_template=record_template)
|
return super().build(input_value=input_value, record_template=record_template)
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,13 @@ class TextOutput(TextComponent):
|
||||||
"input_types": ["Record"],
|
"input_types": ["Record"],
|
||||||
"info": "Text or Record to be passed as output.",
|
"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)
|
return super().build(input_value=input_value, record_template=record_template)
|
||||||
|
|
|
||||||
|
|
@ -603,8 +603,7 @@ class Graph:
|
||||||
# This is a hack to make sure that the LLM vertex is sent to
|
# This is a hack to make sure that the LLM vertex is sent to
|
||||||
# the toolkit vertex
|
# the toolkit vertex
|
||||||
self._build_vertex_params()
|
self._build_vertex_params()
|
||||||
# remove invalid vertices
|
|
||||||
self._validate_vertices()
|
|
||||||
# Now that we have the vertices and edges
|
# Now that we have the vertices and edges
|
||||||
# We need to map the vertices that are connected to
|
# We need to map the vertices that are connected to
|
||||||
# to ChatVertex instances
|
# to ChatVertex instances
|
||||||
|
|
@ -631,14 +630,6 @@ class Graph:
|
||||||
if isinstance(vertex, ToolkitVertex):
|
if isinstance(vertex, ToolkitVertex):
|
||||||
vertex.params["llm"] = llm_vertex
|
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:
|
def _validate_vertex(self, vertex: Vertex) -> bool:
|
||||||
"""Validates a vertex."""
|
"""Validates a vertex."""
|
||||||
# All vertices that do not have edges are invalid
|
# All vertices that do not have edges are invalid
|
||||||
|
|
|
||||||
|
|
@ -74,12 +74,11 @@ export const EditFlowSettings: React.FC<InputProps> = ({
|
||||||
onChange={handleDescriptionChange}
|
onChange={handleDescriptionChange}
|
||||||
value={description!}
|
value={description!}
|
||||||
placeholder="Flow 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}
|
rows={3}
|
||||||
onDoubleClickCapture={(event) => {
|
onDoubleClickCapture={(event) => {
|
||||||
handleFocus(event);
|
handleFocus(event);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<span
|
<span
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M16 8.016A8.522 8.522 0 008.016 16h-.032A8.521 8.521 0 000 8.016v-.032A8.521 8.521 0 007.984 0h.032A8.522 8.522 0 0016 7.984v.032z" fill="url(#prefix__paint0_radial_980_20147)"/><defs><radialGradient id="prefix__paint0_radial_980_20147" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="matrix(16.1326 5.4553 -43.70045 129.2322 1.588 6.503)"><stop offset=".067" stop-color="#9168C0"/><stop offset=".343" stop-color="#5684D1"/><stop offset=".672" stop-color="#1BA1E3"/></radialGradient></defs></svg>
|
||||||
|
After Width: | Height: | Size: 599 B |
10
src/frontend/src/icons/GoogleGenerativeAI/GoogleGemini.jsx
Normal file
10
src/frontend/src/icons/GoogleGenerativeAI/GoogleGemini.jsx
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
const SvgGoogleGenerativeAI = (props) => (<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" {...props}>
|
||||||
|
<path d="M16 8.016A8.522 8.522 0 008.016 16h-.032A8.521 8.521 0 000 8.016v-.032A8.521 8.521 0 007.984 0h.032A8.522 8.522 0 0016 7.984v.032z" fill="url(#prefix__paint0_radial_980_20147)"/>
|
||||||
|
<defs>
|
||||||
|
<radialGradient id="prefix__paint0_radial_980_20147" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="matrix(16.1326 5.4553 -43.70045 129.2322 1.588 6.503)">
|
||||||
|
<stop offset=".067" stop-color="#9168C0"/><stop offset=".343" stop-color="#5684D1"/><stop offset=".672" stop-color="#1BA1E3"/>
|
||||||
|
</radialGradient>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
export default SvgGoogleGenerativeAI;
|
||||||
9
src/frontend/src/icons/GoogleGenerativeAI/index.tsx
Normal file
9
src/frontend/src/icons/GoogleGenerativeAI/index.tsx
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import React, { forwardRef } from "react";
|
||||||
|
import SvgGoogleGenerativeAI from "./GoogleGemini";
|
||||||
|
|
||||||
|
export const GoogleGenerativeAIIcon = forwardRef<
|
||||||
|
SVGSVGElement,
|
||||||
|
React.PropsWithChildren<{}>
|
||||||
|
>((props, ref) => {
|
||||||
|
return <SvgGoogleGenerativeAI ref={ref} {...props} />;
|
||||||
|
});
|
||||||
|
|
@ -151,6 +151,7 @@ import { EvernoteIcon } from "../icons/Evernote";
|
||||||
import { FBIcon } from "../icons/FacebookMessenger";
|
import { FBIcon } from "../icons/FacebookMessenger";
|
||||||
import { GitBookIcon } from "../icons/GitBook";
|
import { GitBookIcon } from "../icons/GitBook";
|
||||||
import { GoogleIcon } from "../icons/Google";
|
import { GoogleIcon } from "../icons/Google";
|
||||||
|
import { GoogleGenerativeAIIcon } from "../icons/GoogleGenerativeAI";
|
||||||
import {
|
import {
|
||||||
GradientInfinity,
|
GradientInfinity,
|
||||||
GradientSave,
|
GradientSave,
|
||||||
|
|
@ -328,6 +329,7 @@ export const nodeIconsLucide: iconsType = {
|
||||||
GoogleSearchResults: GoogleIcon,
|
GoogleSearchResults: GoogleIcon,
|
||||||
GoogleSearchRun: GoogleIcon,
|
GoogleSearchRun: GoogleIcon,
|
||||||
Google: GoogleIcon,
|
Google: GoogleIcon,
|
||||||
|
GoogleGenerativeAI: GoogleGenerativeAIIcon,
|
||||||
HNLoader: HackerNewsIcon,
|
HNLoader: HackerNewsIcon,
|
||||||
HuggingFaceHub: HuggingFaceIcon,
|
HuggingFaceHub: HuggingFaceIcon,
|
||||||
HuggingFace: HuggingFaceIcon,
|
HuggingFace: HuggingFaceIcon,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue