Merge remote-tracking branch 'origin/zustand/io/migration' into globalVariables
This commit is contained in:
commit
95f5c4421f
527 changed files with 15744 additions and 2411 deletions
|
|
@ -616,9 +616,7 @@ export default function ParameterComponent({
|
|||
disabled={disabled}
|
||||
name={name}
|
||||
data={data}
|
||||
button_text={
|
||||
data.node?.template[name].refresh_button_text ?? "Refresh"
|
||||
}
|
||||
button_text={data.node?.template[name].refresh_button_text}
|
||||
className="extra-side-bar-buttons ml-2 mt-1"
|
||||
handleUpdateValues={handleRefreshButtonPress}
|
||||
id={"refresh-button-" + name}
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ export default function IOView({
|
|||
</div>
|
||||
</BaseModal.Header>
|
||||
<BaseModal.Content>
|
||||
<div className="flex h-full flex-col overflow-hidden">
|
||||
<div className="flex h-full flex-col ">
|
||||
<div className="flex-max-width mt-2 h-full">
|
||||
{selectedTab !== 0 && (
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ function RefreshButton({
|
|||
isLoading: boolean;
|
||||
disabled: boolean;
|
||||
name: string;
|
||||
button_text: string;
|
||||
button_text?: string;
|
||||
data: NodeDataType;
|
||||
className?: string;
|
||||
handleUpdateValues: (name: string, data: NodeDataType) => void;
|
||||
|
|
@ -45,7 +45,7 @@ function RefreshButton({
|
|||
onClick={handleClick}
|
||||
id={id}
|
||||
>
|
||||
<span className="mr-1">{button_text}</span>
|
||||
{button_text && <span className="mr-1">{button_text}</span>}
|
||||
<IconComponent
|
||||
name={isLoading ? "Loader2" : "RefreshCcw"}
|
||||
className={iconClassName}
|
||||
|
|
|
|||
|
|
@ -748,6 +748,7 @@ export const NATIVE_CATEGORIES = [
|
|||
"models",
|
||||
"helpers",
|
||||
"experimental",
|
||||
"agents",
|
||||
];
|
||||
|
||||
export const SAVE_DEBOUNCE_TIME = 500;
|
||||
|
|
|
|||
|
|
@ -505,7 +505,7 @@ const EditNodeModal = forwardRef(
|
|||
}
|
||||
dynamic={
|
||||
data.node!.template[templateParam]
|
||||
.dynamic ?? false
|
||||
?.dynamic ?? false
|
||||
}
|
||||
setNodeClass={(nodeClass) => {
|
||||
data.node = nodeClass;
|
||||
|
|
|
|||
|
|
@ -477,6 +477,7 @@ export default function NodeToolbarComponent({
|
|||
value={"Update"}
|
||||
icon={"Code"}
|
||||
dataTestId="update-button-modal"
|
||||
ping={isOutdated}
|
||||
/>
|
||||
</SelectItem>
|
||||
)}
|
||||
|
|
@ -616,12 +617,12 @@ export default function NodeToolbarComponent({
|
|||
open={showModalAdvanced}
|
||||
setOpen={setShowModalAdvanced}
|
||||
/>
|
||||
<ShareModal
|
||||
{showconfirmShare&&<ShareModal
|
||||
open={showconfirmShare}
|
||||
setOpen={setShowconfirmShare}
|
||||
is_component={true}
|
||||
component={flowComponent!}
|
||||
/>
|
||||
/>}
|
||||
{hasCode && (
|
||||
<div className="hidden">
|
||||
<CodeAreaComponent
|
||||
|
|
|
|||
|
|
@ -9,14 +9,18 @@ export default function ToolbarSelectItem({
|
|||
icon,
|
||||
styleObj,
|
||||
dataTestId,
|
||||
ping,
|
||||
}: toolbarSelectItemProps) {
|
||||
return (
|
||||
<div className="flex" data-testid={dataTestId}>
|
||||
<ForwardedIconComponent
|
||||
name={icon}
|
||||
className={`relative top-0.5 mr-2 h-4 w-4 ${styleObj?.iconClasses}`}
|
||||
/>{" "}
|
||||
<span className={styleObj?.valueClasses}>{value}</span>{" "}
|
||||
className={`relative top-0.5 mr-2 h-4 w-4 ${styleObj?.iconClasses} ${
|
||||
ping && "animate-pulse text-green-500"
|
||||
}`}
|
||||
/>
|
||||
<span className={styleObj?.valueClasses}>{value}</span>
|
||||
|
||||
{isMac ? (
|
||||
<ForwardedIconComponent
|
||||
name="Command"
|
||||
|
|
|
|||
|
|
@ -442,6 +442,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
|||
get().nodes.filter((node) => nodes.includes(node.id)),
|
||||
get().edges
|
||||
);
|
||||
|
||||
const errors = errorsObjs.map((obj) => obj.errors).flat();
|
||||
if (errors.length > 0) {
|
||||
setErrorData({
|
||||
|
|
@ -450,7 +451,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
|||
});
|
||||
get().setIsBuilding(false);
|
||||
const ids = errorsObjs.map((obj) => obj.id).flat();
|
||||
console.log("ids", ids);
|
||||
|
||||
get().updateBuildStatus(ids, BuildStatus.ERROR);
|
||||
throw new Error("Invalid nodes");
|
||||
}
|
||||
|
|
@ -490,6 +491,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
|||
verticesIds: newIds,
|
||||
verticesLayers: newLayers,
|
||||
runId: runId,
|
||||
verticesToRun: get().verticesBuild!.verticesToRun,
|
||||
});
|
||||
get().updateBuildStatus(
|
||||
vertexBuildData.top_level_vertices,
|
||||
|
|
@ -559,6 +561,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
|||
verticesIds: string[];
|
||||
verticesLayers: VertexLayerElementType[][];
|
||||
runId: string;
|
||||
verticesToRun: string[];
|
||||
} | null
|
||||
) => {
|
||||
set({ verticesBuild: vertices });
|
||||
|
|
@ -588,7 +591,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
|||
},
|
||||
updateBuildStatus: (nodeIdList: string[], status: BuildStatus) => {
|
||||
const newFlowBuildStatus = { ...get().flowBuildStatus };
|
||||
console.log("newFlowBuildStatus", newFlowBuildStatus);
|
||||
|
||||
nodeIdList.forEach((id) => {
|
||||
newFlowBuildStatus[id] = {
|
||||
status,
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ export type Component = {
|
|||
|
||||
export type VerticesOrderTypeAPI = {
|
||||
ids: Array<string>;
|
||||
vertices_to_run: Array<string>;
|
||||
run_id: string;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -724,4 +724,5 @@ export type toolbarSelectItemProps = {
|
|||
valueClasses?: string;
|
||||
};
|
||||
dataTestId: string;
|
||||
ping?: boolean;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ export type FlowStoreType = {
|
|||
verticesIds: string[];
|
||||
verticesLayers: VertexLayerElementType[][];
|
||||
runId: string;
|
||||
verticesToRun: string[];
|
||||
} | null
|
||||
) => void;
|
||||
addToVerticesBuild: (vertices: string[]) => void;
|
||||
|
|
@ -118,6 +119,7 @@ export type FlowStoreType = {
|
|||
verticesIds: string[];
|
||||
verticesLayers: VertexLayerElementType[][];
|
||||
runId: string;
|
||||
verticesToRun: string[];
|
||||
} | null;
|
||||
updateBuildStatus: (nodeId: string[], status: BuildStatus) => void;
|
||||
revertBuiltStatusFromBuilding: () => void;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ export async function updateVerticesOrder(
|
|||
verticesLayers: VertexLayerElementType[][];
|
||||
verticesIds: string[];
|
||||
runId: string;
|
||||
verticesToRun: string[];
|
||||
}> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const setErrorData = useAlertStore.getState().setErrorData;
|
||||
|
|
@ -60,7 +61,6 @@ export async function updateVerticesOrder(
|
|||
try {
|
||||
orderResponse = await getVerticesOrder(flowId, startNodeId, stopNodeId);
|
||||
} catch (error: any) {
|
||||
console.log(error);
|
||||
setErrorData({
|
||||
title: "Oops! Looks like you missed something",
|
||||
list: [error.response?.data?.detail ?? "Unknown Error"],
|
||||
|
|
@ -77,30 +77,16 @@ export async function updateVerticesOrder(
|
|||
});
|
||||
|
||||
const runId = orderResponse.data.run_id;
|
||||
// if (nodeId) {
|
||||
// for (let i = 0; i < verticesOrder.length; i += 1) {
|
||||
// const innerArray = verticesOrder[i];
|
||||
// const idIndex = innerArray.indexOf(nodeId);
|
||||
// if (idIndex !== -1) {
|
||||
// // If there's a nodeId, we want to run just that component and not the entire layer
|
||||
// // because a layer contains dependencies for the next layer
|
||||
// // and we are stopping at the layer that contains the nodeId
|
||||
// verticesLayers.push([innerArray[idIndex]]);
|
||||
// break; // Stop searching after finding the first occurrence
|
||||
// }
|
||||
// // If the targetId is not found, include the entire inner array
|
||||
// verticesLayers.push(innerArray);
|
||||
// }
|
||||
// } else {
|
||||
// verticesLayers = verticesOrder;
|
||||
// }
|
||||
const verticesToRun = orderResponse.data.vertices_to_run;
|
||||
|
||||
const verticesIds = orderResponse.data.ids;
|
||||
useFlowStore.getState().updateVerticesBuild({
|
||||
verticesLayers,
|
||||
verticesIds,
|
||||
runId,
|
||||
verticesToRun,
|
||||
});
|
||||
resolve({ verticesLayers, verticesIds, runId });
|
||||
resolve({ verticesLayers, verticesIds, runId, verticesToRun });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -122,8 +108,22 @@ export async function buildVertices({
|
|||
if (startNodeId && stopNodeId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!verticesBuild || startNodeId || stopNodeId) {
|
||||
verticesBuild = await updateVerticesOrder(flowId, startNodeId, stopNodeId);
|
||||
let verticesOrderResponse = await updateVerticesOrder(
|
||||
flowId,
|
||||
startNodeId,
|
||||
stopNodeId
|
||||
);
|
||||
if (onValidateNodes) {
|
||||
try {
|
||||
onValidateNodes(verticesOrderResponse.verticesToRun);
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (onGetOrderSuccess) onGetOrderSuccess();
|
||||
verticesBuild = useFlowStore.getState().verticesBuild;
|
||||
}
|
||||
|
||||
const verticesIds = verticesBuild?.verticesIds!;
|
||||
|
|
@ -131,17 +131,6 @@ export async function buildVertices({
|
|||
const runId = verticesBuild?.runId!;
|
||||
let stop = false;
|
||||
|
||||
if (onGetOrderSuccess) onGetOrderSuccess();
|
||||
|
||||
if (onValidateNodes) {
|
||||
try {
|
||||
const nodes = useFlowStore.getState().nodes;
|
||||
onValidateNodes(nodes.map((node) => node.id));
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
useFlowStore.getState().updateBuildStatus(verticesIds, BuildStatus.TO_BUILD);
|
||||
useFlowStore.getState().setIsBuilding(true);
|
||||
let currentLayerIndex = 0; // Start with the first layer
|
||||
|
|
|
|||
|
|
@ -429,7 +429,7 @@ export function getPythonCode(
|
|||
const flowName = flow.name;
|
||||
const tweaks = buildTweaks(flow);
|
||||
const inputs = buildInputs();
|
||||
return `from langflow import load_flow_from_json
|
||||
return `from langflow.load import load_flow_from_json
|
||||
TWEAKS = ${
|
||||
tweak && tweak.length > 0
|
||||
? buildTweakObject(tweak)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export const custom = `from langflow import CustomComponent
|
||||
export const custom = `from langflow.custom import CustomComponent
|
||||
|
||||
from langchain.llms.base import BaseLLM
|
||||
from langchain.chains import LLMChain
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@
|
|||
"height": 631,
|
||||
"id": "ChatOpenAI-Hz56M",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 543.1816229116944, "y": 942.891611351432 },
|
||||
"position": {
|
||||
"x": 543.1816229116944,
|
||||
"y": 942.891611351432
|
||||
},
|
||||
"data": {
|
||||
"type": "ChatOpenAI",
|
||||
"node": {
|
||||
|
|
@ -238,7 +241,10 @@
|
|||
"height": 387,
|
||||
"id": "AgentInitializer-QiQ4x",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 1036.6064439140812, "y": 645.1919693466587 },
|
||||
"position": {
|
||||
"x": 1036.6064439140812,
|
||||
"y": 645.1919693466587
|
||||
},
|
||||
"data": {
|
||||
"type": "AgentInitializer",
|
||||
"node": {
|
||||
|
|
@ -299,7 +305,10 @@
|
|||
"_type": "initialize_agent"
|
||||
},
|
||||
"description": "Construct a zero shot agent from an LLM and tools.",
|
||||
"base_classes": ["AgentExecutor", "function"],
|
||||
"base_classes": [
|
||||
"AgentExecutor",
|
||||
"function"
|
||||
],
|
||||
"display_name": "AgentInitializer"
|
||||
},
|
||||
"id": "AgentInitializer-QiQ4x",
|
||||
|
|
@ -316,7 +325,10 @@
|
|||
"height": 437,
|
||||
"id": "PythonFunctionTool-kX99N",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 553.050119331742, "y": 412.9533535948685 },
|
||||
"position": {
|
||||
"x": 553.050119331742,
|
||||
"y": 412.9533535948685
|
||||
},
|
||||
"data": {
|
||||
"type": "PythonFunctionTool",
|
||||
"node": {
|
||||
|
|
@ -360,7 +372,9 @@
|
|||
"_type": "PythonFunctionTool"
|
||||
},
|
||||
"description": "Python function to be executed.",
|
||||
"base_classes": ["Tool"],
|
||||
"base_classes": [
|
||||
"Tool"
|
||||
],
|
||||
"display_name": "PythonFunctionTool"
|
||||
},
|
||||
"id": "PythonFunctionTool-kX99N",
|
||||
|
|
@ -380,7 +394,9 @@
|
|||
"sourceHandle": "{œbaseClassesœ:[œSerializableœ,œBaseChatModelœ,œChatOpenAIœ,œBaseLanguageModelœ],œdataTypeœ:œChatOpenAIœ,œidœ:œChatOpenAI-Hz56Mœ}",
|
||||
"target": "AgentInitializer-QiQ4x",
|
||||
"targetHandle": "{œfieldNameœ:œllmœ,œidœ:œAgentInitializer-QiQ4xœ,œinputTypesœ:null,œtypeœ:œBaseLanguageModelœ}",
|
||||
"style": { "stroke": "#555" },
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"animated": false,
|
||||
"id": "reactflow__edge-ChatOpenAI-Hz56M{œbaseClassesœ:[œSerializableœ,œBaseChatModelœ,œChatOpenAIœ,œBaseLanguageModelœ],œdataTypeœ:œChatOpenAIœ,œidœ:œChatOpenAI-Hz56Mœ}-AgentInitializer-QiQ4x{œfieldNameœ:œllmœ,œidœ:œAgentInitializer-QiQ4xœ,œinputTypesœ:null,œtypeœ:œBaseLanguageModelœ}",
|
||||
|
|
@ -409,14 +425,18 @@
|
|||
"sourceHandle": "{œbaseClassesœ:[œToolœ],œdataTypeœ:œPythonFunctionToolœ,œidœ:œPythonFunctionTool-kX99Nœ}",
|
||||
"target": "AgentInitializer-QiQ4x",
|
||||
"targetHandle": "{œfieldNameœ:œtoolsœ,œidœ:œAgentInitializer-QiQ4xœ,œinputTypesœ:null,œtypeœ:œToolœ}",
|
||||
"style": { "stroke": "#555" },
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"animated": false,
|
||||
"id": "reactflow__edge-PythonFunctionTool-kX99N{œbaseClassesœ:[œToolœ],œdataTypeœ:œPythonFunctionToolœ,œidœ:œPythonFunctionTool-kX99Nœ}-AgentInitializer-QiQ4x{œfieldNameœ:œtoolsœ,œidœ:œAgentInitializer-QiQ4xœ,œinputTypesœ:null,œtypeœ:œToolœ}",
|
||||
"selected": false,
|
||||
"data": {
|
||||
"sourceHandle": {
|
||||
"baseClasses": ["Tool"],
|
||||
"baseClasses": [
|
||||
"Tool"
|
||||
],
|
||||
"dataType": "PythonFunctionTool",
|
||||
"id": "PythonFunctionTool-kX99N"
|
||||
},
|
||||
|
|
@ -446,7 +466,10 @@
|
|||
{
|
||||
"id": "CustomComponent-w4WCp",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 536, "y": 337 },
|
||||
"position": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
},
|
||||
"data": {
|
||||
"type": "CustomComponent",
|
||||
"node": {
|
||||
|
|
@ -456,7 +479,7 @@
|
|||
"placeholder": "",
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from langflow import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"value": "from langflow.custom import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"password": false,
|
||||
"name": "code",
|
||||
"advanced": false,
|
||||
|
|
@ -478,11 +501,18 @@
|
|||
},
|
||||
"id": "CustomComponent-w4WCp"
|
||||
},
|
||||
"positionAbsolute": { "x": 536, "y": 337 }
|
||||
"positionAbsolute": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [],
|
||||
"viewport": { "x": 0, "y": 0, "zoom": 1 }
|
||||
"viewport": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"zoom": 1
|
||||
}
|
||||
},
|
||||
"id": "e43cf2c8-cd64-4936-8170-b207a8b109c4",
|
||||
"user_id": "6f6ebc2c-9e7a-4c35-84fc-51760db10d9b"
|
||||
|
|
@ -497,7 +527,10 @@
|
|||
"height": 631,
|
||||
"id": "ChatOpenAI-7GFF0",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 543.1816229116944, "y": 942.891611351432 },
|
||||
"position": {
|
||||
"x": 543.1816229116944,
|
||||
"y": 942.891611351432
|
||||
},
|
||||
"data": {
|
||||
"type": "ChatOpenAI",
|
||||
"node": {
|
||||
|
|
@ -725,7 +758,10 @@
|
|||
"height": 387,
|
||||
"id": "AgentInitializer-YJgqs",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 1036.6064439140812, "y": 645.1919693466587 },
|
||||
"position": {
|
||||
"x": 1036.6064439140812,
|
||||
"y": 645.1919693466587
|
||||
},
|
||||
"data": {
|
||||
"type": "AgentInitializer",
|
||||
"node": {
|
||||
|
|
@ -786,7 +822,10 @@
|
|||
"_type": "initialize_agent"
|
||||
},
|
||||
"description": "Construct a zero shot agent from an LLM and tools.",
|
||||
"base_classes": ["AgentExecutor", "function"],
|
||||
"base_classes": [
|
||||
"AgentExecutor",
|
||||
"function"
|
||||
],
|
||||
"display_name": "AgentInitializer"
|
||||
},
|
||||
"id": "AgentInitializer-YJgqs",
|
||||
|
|
@ -803,7 +842,10 @@
|
|||
"height": 437,
|
||||
"id": "PythonFunctionTool-gqQDg",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 553.050119331742, "y": 412.9533535948685 },
|
||||
"position": {
|
||||
"x": 553.050119331742,
|
||||
"y": 412.9533535948685
|
||||
},
|
||||
"data": {
|
||||
"type": "PythonFunctionTool",
|
||||
"node": {
|
||||
|
|
@ -847,7 +889,9 @@
|
|||
"_type": "PythonFunctionTool"
|
||||
},
|
||||
"description": "Python function to be executed.",
|
||||
"base_classes": ["Tool"],
|
||||
"base_classes": [
|
||||
"Tool"
|
||||
],
|
||||
"display_name": "PythonFunctionTool"
|
||||
},
|
||||
"id": "PythonFunctionTool-gqQDg",
|
||||
|
|
@ -867,7 +911,9 @@
|
|||
"sourceHandle": "{œbaseClassesœ:[œSerializableœ,œBaseChatModelœ,œChatOpenAIœ,œBaseLanguageModelœ],œdataTypeœ:œChatOpenAIœ,œidœ:œChatOpenAI-7GFF0œ}",
|
||||
"target": "AgentInitializer-YJgqs",
|
||||
"targetHandle": "{œfieldNameœ:œllmœ,œidœ:œAgentInitializer-YJgqsœ,œinputTypesœ:null,œtypeœ:œBaseLanguageModelœ}",
|
||||
"style": { "stroke": "#555" },
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"animated": false,
|
||||
"id": "reactflow__edge-ChatOpenAI-7GFF0{œbaseClassesœ:[œSerializableœ,œBaseChatModelœ,œChatOpenAIœ,œBaseLanguageModelœ],œdataTypeœ:œChatOpenAIœ,œidœ:œChatOpenAI-7GFF0œ}-AgentInitializer-YJgqs{œfieldNameœ:œllmœ,œidœ:œAgentInitializer-YJgqsœ,œinputTypesœ:null,œtypeœ:œBaseLanguageModelœ}",
|
||||
|
|
@ -896,14 +942,18 @@
|
|||
"sourceHandle": "{œbaseClassesœ:[œToolœ],œdataTypeœ:œPythonFunctionToolœ,œidœ:œPythonFunctionTool-gqQDgœ}",
|
||||
"target": "AgentInitializer-YJgqs",
|
||||
"targetHandle": "{œfieldNameœ:œtoolsœ,œidœ:œAgentInitializer-YJgqsœ,œinputTypesœ:null,œtypeœ:œToolœ}",
|
||||
"style": { "stroke": "#555" },
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"animated": false,
|
||||
"id": "reactflow__edge-PythonFunctionTool-gqQDg{œbaseClassesœ:[œToolœ],œdataTypeœ:œPythonFunctionToolœ,œidœ:œPythonFunctionTool-gqQDgœ}-AgentInitializer-YJgqs{œfieldNameœ:œtoolsœ,œidœ:œAgentInitializer-YJgqsœ,œinputTypesœ:null,œtypeœ:œToolœ}",
|
||||
"selected": false,
|
||||
"data": {
|
||||
"sourceHandle": {
|
||||
"baseClasses": ["Tool"],
|
||||
"baseClasses": [
|
||||
"Tool"
|
||||
],
|
||||
"dataType": "PythonFunctionTool",
|
||||
"id": "PythonFunctionTool-gqQDg"
|
||||
},
|
||||
|
|
@ -933,7 +983,10 @@
|
|||
{
|
||||
"id": "CustomComponent-iF9Zr",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 536, "y": 337 },
|
||||
"position": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
},
|
||||
"data": {
|
||||
"type": "CustomComponent",
|
||||
"node": {
|
||||
|
|
@ -943,7 +996,7 @@
|
|||
"placeholder": "",
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from langflow import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"value": "from langflow.custom import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"password": false,
|
||||
"name": "code",
|
||||
"advanced": false,
|
||||
|
|
@ -965,11 +1018,18 @@
|
|||
},
|
||||
"id": "CustomComponent-iF9Zr"
|
||||
},
|
||||
"positionAbsolute": { "x": 536, "y": 337 }
|
||||
"positionAbsolute": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [],
|
||||
"viewport": { "x": 0, "y": 0, "zoom": 1 }
|
||||
"viewport": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"zoom": 1
|
||||
}
|
||||
},
|
||||
"id": "88a0e6a1-8144-4bff-b28c-d312ae5c8a10",
|
||||
"user_id": "6f6ebc2c-9e7a-4c35-84fc-51760db10d9b"
|
||||
|
|
@ -984,7 +1044,10 @@
|
|||
"height": 631,
|
||||
"id": "ChatOpenAI-cljAK",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 543.1816229116944, "y": 942.891611351432 },
|
||||
"position": {
|
||||
"x": 543.1816229116944,
|
||||
"y": 942.891611351432
|
||||
},
|
||||
"data": {
|
||||
"type": "ChatOpenAI",
|
||||
"node": {
|
||||
|
|
@ -1212,7 +1275,10 @@
|
|||
"height": 387,
|
||||
"id": "AgentInitializer-grV0u",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 1036.6064439140812, "y": 645.1919693466587 },
|
||||
"position": {
|
||||
"x": 1036.6064439140812,
|
||||
"y": 645.1919693466587
|
||||
},
|
||||
"data": {
|
||||
"type": "AgentInitializer",
|
||||
"node": {
|
||||
|
|
@ -1273,7 +1339,10 @@
|
|||
"_type": "initialize_agent"
|
||||
},
|
||||
"description": "Construct a zero shot agent from an LLM and tools.",
|
||||
"base_classes": ["AgentExecutor", "function"],
|
||||
"base_classes": [
|
||||
"AgentExecutor",
|
||||
"function"
|
||||
],
|
||||
"display_name": "AgentInitializer"
|
||||
},
|
||||
"id": "AgentInitializer-grV0u",
|
||||
|
|
@ -1290,7 +1359,10 @@
|
|||
"height": 437,
|
||||
"id": "PythonFunctionTool-SctM2",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 553.050119331742, "y": 412.9533535948685 },
|
||||
"position": {
|
||||
"x": 553.050119331742,
|
||||
"y": 412.9533535948685
|
||||
},
|
||||
"data": {
|
||||
"type": "PythonFunctionTool",
|
||||
"node": {
|
||||
|
|
@ -1334,7 +1406,9 @@
|
|||
"_type": "PythonFunctionTool"
|
||||
},
|
||||
"description": "Python function to be executed.",
|
||||
"base_classes": ["Tool"],
|
||||
"base_classes": [
|
||||
"Tool"
|
||||
],
|
||||
"display_name": "PythonFunctionTool"
|
||||
},
|
||||
"id": "PythonFunctionTool-SctM2",
|
||||
|
|
@ -1354,7 +1428,9 @@
|
|||
"sourceHandle": "{œbaseClassesœ:[œSerializableœ,œBaseChatModelœ,œChatOpenAIœ,œBaseLanguageModelœ],œdataTypeœ:œChatOpenAIœ,œidœ:œChatOpenAI-cljAKœ}",
|
||||
"target": "AgentInitializer-grV0u",
|
||||
"targetHandle": "{œfieldNameœ:œllmœ,œidœ:œAgentInitializer-grV0uœ,œinputTypesœ:null,œtypeœ:œBaseLanguageModelœ}",
|
||||
"style": { "stroke": "#555" },
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"animated": false,
|
||||
"id": "reactflow__edge-ChatOpenAI-cljAK{œbaseClassesœ:[œSerializableœ,œBaseChatModelœ,œChatOpenAIœ,œBaseLanguageModelœ],œdataTypeœ:œChatOpenAIœ,œidœ:œChatOpenAI-cljAKœ}-AgentInitializer-grV0u{œfieldNameœ:œllmœ,œidœ:œAgentInitializer-grV0uœ,œinputTypesœ:null,œtypeœ:œBaseLanguageModelœ}",
|
||||
|
|
@ -1383,14 +1459,18 @@
|
|||
"sourceHandle": "{œbaseClassesœ:[œToolœ],œdataTypeœ:œPythonFunctionToolœ,œidœ:œPythonFunctionTool-SctM2œ}",
|
||||
"target": "AgentInitializer-grV0u",
|
||||
"targetHandle": "{œfieldNameœ:œtoolsœ,œidœ:œAgentInitializer-grV0uœ,œinputTypesœ:null,œtypeœ:œToolœ}",
|
||||
"style": { "stroke": "#555" },
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"animated": false,
|
||||
"id": "reactflow__edge-PythonFunctionTool-SctM2{œbaseClassesœ:[œToolœ],œdataTypeœ:œPythonFunctionToolœ,œidœ:œPythonFunctionTool-SctM2œ}-AgentInitializer-grV0u{œfieldNameœ:œtoolsœ,œidœ:œAgentInitializer-grV0uœ,œinputTypesœ:null,œtypeœ:œToolœ}",
|
||||
"selected": false,
|
||||
"data": {
|
||||
"sourceHandle": {
|
||||
"baseClasses": ["Tool"],
|
||||
"baseClasses": [
|
||||
"Tool"
|
||||
],
|
||||
"dataType": "PythonFunctionTool",
|
||||
"id": "PythonFunctionTool-SctM2"
|
||||
},
|
||||
|
|
@ -1420,7 +1500,10 @@
|
|||
{
|
||||
"id": "CustomComponent-z5kAP",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 536, "y": 337 },
|
||||
"position": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
},
|
||||
"data": {
|
||||
"type": "CustomComponent",
|
||||
"node": {
|
||||
|
|
@ -1430,7 +1513,7 @@
|
|||
"placeholder": "",
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from langflow import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"value": "from langflow.custom import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"password": false,
|
||||
"name": "code",
|
||||
"advanced": false,
|
||||
|
|
@ -1452,11 +1535,18 @@
|
|||
},
|
||||
"id": "CustomComponent-z5kAP"
|
||||
},
|
||||
"positionAbsolute": { "x": 536, "y": 337 }
|
||||
"positionAbsolute": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [],
|
||||
"viewport": { "x": 0, "y": 0, "zoom": 1 }
|
||||
"viewport": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"zoom": 1
|
||||
}
|
||||
},
|
||||
"id": "3128b556-35c7-4ced-a834-70fbeb1a410f",
|
||||
"user_id": "6f6ebc2c-9e7a-4c35-84fc-51760db10d9b"
|
||||
|
|
@ -1469,7 +1559,10 @@
|
|||
{
|
||||
"id": "CustomComponent-ZieNZ",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 536, "y": 337 },
|
||||
"position": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
},
|
||||
"data": {
|
||||
"type": "CustomComponent",
|
||||
"node": {
|
||||
|
|
@ -1479,7 +1572,7 @@
|
|||
"placeholder": "",
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from langflow import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"value": "from langflow.custom import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"password": false,
|
||||
"name": "code",
|
||||
"advanced": false,
|
||||
|
|
@ -1501,11 +1594,18 @@
|
|||
},
|
||||
"id": "CustomComponent-ZieNZ"
|
||||
},
|
||||
"positionAbsolute": { "x": 536, "y": 337 }
|
||||
"positionAbsolute": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [],
|
||||
"viewport": { "x": 0, "y": 0, "zoom": 1 }
|
||||
"viewport": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"zoom": 1
|
||||
}
|
||||
},
|
||||
"id": "d3f2c379-9df5-49a0-b33d-d855c2085949",
|
||||
"user_id": "6f6ebc2c-9e7a-4c35-84fc-51760db10d9b"
|
||||
|
|
@ -1518,7 +1618,10 @@
|
|||
{
|
||||
"id": "CustomComponent-CcHG0",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 536, "y": 337 },
|
||||
"position": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
},
|
||||
"data": {
|
||||
"type": "CustomComponent",
|
||||
"node": {
|
||||
|
|
@ -1528,7 +1631,7 @@
|
|||
"placeholder": "",
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from langflow import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"value": "from langflow.custom import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"password": false,
|
||||
"name": "code",
|
||||
"advanced": false,
|
||||
|
|
@ -1550,11 +1653,18 @@
|
|||
},
|
||||
"id": "CustomComponent-CcHG0"
|
||||
},
|
||||
"positionAbsolute": { "x": 536, "y": 337 }
|
||||
"positionAbsolute": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [],
|
||||
"viewport": { "x": 0, "y": 0, "zoom": 1 }
|
||||
"viewport": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"zoom": 1
|
||||
}
|
||||
},
|
||||
"id": "74afff1f-b540-43d5-bc66-d18f39d65d57",
|
||||
"user_id": "6f6ebc2c-9e7a-4c35-84fc-51760db10d9b"
|
||||
|
|
@ -1567,7 +1677,10 @@
|
|||
{
|
||||
"id": "CustomComponent-Q8qSr",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 536, "y": 337 },
|
||||
"position": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
},
|
||||
"data": {
|
||||
"type": "CustomComponent",
|
||||
"node": {
|
||||
|
|
@ -1577,7 +1690,7 @@
|
|||
"placeholder": "",
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from langflow import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"value": "from langflow.custom import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"password": false,
|
||||
"name": "code",
|
||||
"advanced": false,
|
||||
|
|
@ -1599,11 +1712,18 @@
|
|||
},
|
||||
"id": "CustomComponent-Q8qSr"
|
||||
},
|
||||
"positionAbsolute": { "x": 536, "y": 337 }
|
||||
"positionAbsolute": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [],
|
||||
"viewport": { "x": 0, "y": 0, "zoom": 1 }
|
||||
"viewport": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"zoom": 1
|
||||
}
|
||||
},
|
||||
"id": "b0b1c893-6194-4748-ae10-b5f604b271c2",
|
||||
"user_id": "6f6ebc2c-9e7a-4c35-84fc-51760db10d9b"
|
||||
|
|
@ -1616,7 +1736,10 @@
|
|||
{
|
||||
"id": "CustomComponent-Lgoca",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 536, "y": 337 },
|
||||
"position": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
},
|
||||
"data": {
|
||||
"type": "CustomComponent",
|
||||
"node": {
|
||||
|
|
@ -1626,7 +1749,7 @@
|
|||
"placeholder": "",
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from langflow import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"value": "from langflow.custom import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"password": false,
|
||||
"name": "code",
|
||||
"advanced": false,
|
||||
|
|
@ -1648,11 +1771,18 @@
|
|||
},
|
||||
"id": "CustomComponent-Lgoca"
|
||||
},
|
||||
"positionAbsolute": { "x": 536, "y": 337 }
|
||||
"positionAbsolute": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [],
|
||||
"viewport": { "x": 0, "y": 0, "zoom": 1 }
|
||||
"viewport": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"zoom": 1
|
||||
}
|
||||
},
|
||||
"id": "edf1051d-509b-46a2-84c6-b94bdcdc3a4f",
|
||||
"user_id": "6f6ebc2c-9e7a-4c35-84fc-51760db10d9b"
|
||||
|
|
@ -1665,7 +1795,10 @@
|
|||
{
|
||||
"id": "CustomComponent-6OJGW",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 536, "y": 337 },
|
||||
"position": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
},
|
||||
"data": {
|
||||
"type": "CustomComponent",
|
||||
"node": {
|
||||
|
|
@ -1675,7 +1808,7 @@
|
|||
"placeholder": "",
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from langflow import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"value": "from langflow.custom import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"password": false,
|
||||
"name": "code",
|
||||
"advanced": false,
|
||||
|
|
@ -1697,11 +1830,18 @@
|
|||
},
|
||||
"id": "CustomComponent-6OJGW"
|
||||
},
|
||||
"positionAbsolute": { "x": 536, "y": 337 }
|
||||
"positionAbsolute": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [],
|
||||
"viewport": { "x": 0, "y": 0, "zoom": 1 }
|
||||
"viewport": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"zoom": 1
|
||||
}
|
||||
},
|
||||
"id": "65b2a4e0-4084-418a-aa86-ee914acb0ab5",
|
||||
"user_id": "6f6ebc2c-9e7a-4c35-84fc-51760db10d9b"
|
||||
|
|
@ -1714,7 +1854,10 @@
|
|||
{
|
||||
"id": "CustomComponent-tcE83",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 536, "y": 337 },
|
||||
"position": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
},
|
||||
"data": {
|
||||
"type": "CustomComponent",
|
||||
"node": {
|
||||
|
|
@ -1724,7 +1867,7 @@
|
|||
"placeholder": "",
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from langflow import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"value": "from langflow.custom import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"password": false,
|
||||
"name": "code",
|
||||
"advanced": false,
|
||||
|
|
@ -1746,11 +1889,18 @@
|
|||
},
|
||||
"id": "CustomComponent-tcE83"
|
||||
},
|
||||
"positionAbsolute": { "x": 536, "y": 337 }
|
||||
"positionAbsolute": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [],
|
||||
"viewport": { "x": 0, "y": 0, "zoom": 1 }
|
||||
"viewport": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"zoom": 1
|
||||
}
|
||||
},
|
||||
"id": "534e412b-d37b-4133-8029-e5ed139fd55c",
|
||||
"user_id": "6f6ebc2c-9e7a-4c35-84fc-51760db10d9b"
|
||||
|
|
@ -1765,7 +1915,10 @@
|
|||
"height": 631,
|
||||
"id": "ChatOpenAI-mQEi3",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 543.1816229116944, "y": 942.891611351432 },
|
||||
"position": {
|
||||
"x": 543.1816229116944,
|
||||
"y": 942.891611351432
|
||||
},
|
||||
"data": {
|
||||
"type": "ChatOpenAI",
|
||||
"node": {
|
||||
|
|
@ -1993,7 +2146,10 @@
|
|||
"height": 387,
|
||||
"id": "AgentInitializer-EE8R4",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 1036.6064439140812, "y": 645.1919693466587 },
|
||||
"position": {
|
||||
"x": 1036.6064439140812,
|
||||
"y": 645.1919693466587
|
||||
},
|
||||
"data": {
|
||||
"type": "AgentInitializer",
|
||||
"node": {
|
||||
|
|
@ -2054,7 +2210,10 @@
|
|||
"_type": "initialize_agent"
|
||||
},
|
||||
"description": "Construct a zero shot agent from an LLM and tools.",
|
||||
"base_classes": ["AgentExecutor", "function"],
|
||||
"base_classes": [
|
||||
"AgentExecutor",
|
||||
"function"
|
||||
],
|
||||
"display_name": "AgentInitializer"
|
||||
},
|
||||
"id": "AgentInitializer-EE8R4",
|
||||
|
|
@ -2071,7 +2230,10 @@
|
|||
"height": 437,
|
||||
"id": "PythonFunctionTool-YKkDL",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 553.050119331742, "y": 412.9533535948685 },
|
||||
"position": {
|
||||
"x": 553.050119331742,
|
||||
"y": 412.9533535948685
|
||||
},
|
||||
"data": {
|
||||
"type": "PythonFunctionTool",
|
||||
"node": {
|
||||
|
|
@ -2115,7 +2277,9 @@
|
|||
"_type": "PythonFunctionTool"
|
||||
},
|
||||
"description": "Python function to be executed.",
|
||||
"base_classes": ["Tool"],
|
||||
"base_classes": [
|
||||
"Tool"
|
||||
],
|
||||
"display_name": "PythonFunctionTool"
|
||||
},
|
||||
"id": "PythonFunctionTool-YKkDL",
|
||||
|
|
@ -2135,7 +2299,9 @@
|
|||
"sourceHandle": "{œbaseClassesœ:[œSerializableœ,œBaseChatModelœ,œChatOpenAIœ,œBaseLanguageModelœ],œdataTypeœ:œChatOpenAIœ,œidœ:œChatOpenAI-mQEi3œ}",
|
||||
"target": "AgentInitializer-EE8R4",
|
||||
"targetHandle": "{œfieldNameœ:œllmœ,œidœ:œAgentInitializer-EE8R4œ,œinputTypesœ:null,œtypeœ:œBaseLanguageModelœ}",
|
||||
"style": { "stroke": "#555" },
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"animated": false,
|
||||
"id": "reactflow__edge-ChatOpenAI-mQEi3{œbaseClassesœ:[œSerializableœ,œBaseChatModelœ,œChatOpenAIœ,œBaseLanguageModelœ],œdataTypeœ:œChatOpenAIœ,œidœ:œChatOpenAI-mQEi3œ}-AgentInitializer-EE8R4{œfieldNameœ:œllmœ,œidœ:œAgentInitializer-EE8R4œ,œinputTypesœ:null,œtypeœ:œBaseLanguageModelœ}",
|
||||
|
|
@ -2164,14 +2330,18 @@
|
|||
"sourceHandle": "{œbaseClassesœ:[œToolœ],œdataTypeœ:œPythonFunctionToolœ,œidœ:œPythonFunctionTool-YKkDLœ}",
|
||||
"target": "AgentInitializer-EE8R4",
|
||||
"targetHandle": "{œfieldNameœ:œtoolsœ,œidœ:œAgentInitializer-EE8R4œ,œinputTypesœ:null,œtypeœ:œToolœ}",
|
||||
"style": { "stroke": "#555" },
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"animated": false,
|
||||
"id": "reactflow__edge-PythonFunctionTool-YKkDL{œbaseClassesœ:[œToolœ],œdataTypeœ:œPythonFunctionToolœ,œidœ:œPythonFunctionTool-YKkDLœ}-AgentInitializer-EE8R4{œfieldNameœ:œtoolsœ,œidœ:œAgentInitializer-EE8R4œ,œinputTypesœ:null,œtypeœ:œToolœ}",
|
||||
"selected": false,
|
||||
"data": {
|
||||
"sourceHandle": {
|
||||
"baseClasses": ["Tool"],
|
||||
"baseClasses": [
|
||||
"Tool"
|
||||
],
|
||||
"dataType": "PythonFunctionTool",
|
||||
"id": "PythonFunctionTool-YKkDL"
|
||||
},
|
||||
|
|
@ -2201,7 +2371,10 @@
|
|||
{
|
||||
"id": "CustomComponent-T38LS",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 536, "y": 337 },
|
||||
"position": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
},
|
||||
"data": {
|
||||
"type": "CustomComponent",
|
||||
"node": {
|
||||
|
|
@ -2211,7 +2384,7 @@
|
|||
"placeholder": "",
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from langflow import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"value": "from langflow.custom import CustomComponent\n\nfrom langchain.llms.base import BaseLLM\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\nfrom langchain.schema import Document\n\nimport requests\n\nclass YourComponent(CustomComponent):\n display_name: str = \"Custom Component\"\n description: str = \"Create any custom component you want!\"\n\n def build_config(self):\n return { \"url\": { \"multiline\": True, \"required\": True } }\n\n def build(self, url: str, llm: BaseLLM, prompt: PromptTemplate) -> Document:\n response = requests.get(url)\n chain = LLMChain(llm=llm, prompt=prompt)\n result = chain.run(response.text[:300])\n return Document(page_content=str(result))\n",
|
||||
"password": false,
|
||||
"name": "code",
|
||||
"advanced": false,
|
||||
|
|
@ -2233,11 +2406,18 @@
|
|||
},
|
||||
"id": "CustomComponent-T38LS"
|
||||
},
|
||||
"positionAbsolute": { "x": 536, "y": 337 }
|
||||
"positionAbsolute": {
|
||||
"x": 536,
|
||||
"y": 337
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [],
|
||||
"viewport": { "x": 0, "y": 0, "zoom": 1 }
|
||||
"viewport": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"zoom": 1
|
||||
}
|
||||
},
|
||||
"id": "ec36a3b7-7b5f-4663-983c-833bcec4d851",
|
||||
"user_id": "6f6ebc2c-9e7a-4c35-84fc-51760db10d9b"
|
||||
|
|
@ -2252,7 +2432,10 @@
|
|||
"height": 631,
|
||||
"id": "ChatOpenAI-E1XSb",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 543.1816229116944, "y": 942.891611351432 },
|
||||
"position": {
|
||||
"x": 543.1816229116944,
|
||||
"y": 942.891611351432
|
||||
},
|
||||
"data": {
|
||||
"type": "ChatOpenAI",
|
||||
"node": {
|
||||
|
|
@ -2480,7 +2663,10 @@
|
|||
"height": 387,
|
||||
"id": "AgentInitializer-goPm2",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 1036.6064439140812, "y": 645.1919693466587 },
|
||||
"position": {
|
||||
"x": 1036.6064439140812,
|
||||
"y": 645.1919693466587
|
||||
},
|
||||
"data": {
|
||||
"type": "AgentInitializer",
|
||||
"node": {
|
||||
|
|
@ -2541,7 +2727,10 @@
|
|||
"_type": "initialize_agent"
|
||||
},
|
||||
"description": "Construct a zero shot agent from an LLM and tools.",
|
||||
"base_classes": ["AgentExecutor", "function"],
|
||||
"base_classes": [
|
||||
"AgentExecutor",
|
||||
"function"
|
||||
],
|
||||
"display_name": "AgentInitializer"
|
||||
},
|
||||
"id": "AgentInitializer-goPm2",
|
||||
|
|
@ -2558,7 +2747,10 @@
|
|||
"height": 437,
|
||||
"id": "PythonFunctionTool-SQikY",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 553.050119331742, "y": 412.9533535948685 },
|
||||
"position": {
|
||||
"x": 553.050119331742,
|
||||
"y": 412.9533535948685
|
||||
},
|
||||
"data": {
|
||||
"type": "PythonFunctionTool",
|
||||
"node": {
|
||||
|
|
@ -2602,7 +2794,9 @@
|
|||
"_type": "PythonFunctionTool"
|
||||
},
|
||||
"description": "Python function to be executed.",
|
||||
"base_classes": ["Tool"],
|
||||
"base_classes": [
|
||||
"Tool"
|
||||
],
|
||||
"display_name": "PythonFunctionTool"
|
||||
},
|
||||
"id": "PythonFunctionTool-SQikY",
|
||||
|
|
@ -2622,7 +2816,9 @@
|
|||
"sourceHandle": "{œbaseClassesœ:[œSerializableœ,œBaseChatModelœ,œChatOpenAIœ,œBaseLanguageModelœ],œdataTypeœ:œChatOpenAIœ,œidœ:œChatOpenAI-E1XSbœ}",
|
||||
"target": "AgentInitializer-goPm2",
|
||||
"targetHandle": "{œfieldNameœ:œllmœ,œidœ:œAgentInitializer-goPm2œ,œinputTypesœ:null,œtypeœ:œBaseLanguageModelœ}",
|
||||
"style": { "stroke": "#555" },
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"animated": false,
|
||||
"id": "reactflow__edge-ChatOpenAI-E1XSb{œbaseClassesœ:[œSerializableœ,œBaseChatModelœ,œChatOpenAIœ,œBaseLanguageModelœ],œdataTypeœ:œChatOpenAIœ,œidœ:œChatOpenAI-E1XSbœ}-AgentInitializer-goPm2{œfieldNameœ:œllmœ,œidœ:œAgentInitializer-goPm2œ,œinputTypesœ:null,œtypeœ:œBaseLanguageModelœ}",
|
||||
|
|
@ -2651,14 +2847,18 @@
|
|||
"sourceHandle": "{œbaseClassesœ:[œToolœ],œdataTypeœ:œPythonFunctionToolœ,œidœ:œPythonFunctionTool-SQikYœ}",
|
||||
"target": "AgentInitializer-goPm2",
|
||||
"targetHandle": "{œfieldNameœ:œtoolsœ,œidœ:œAgentInitializer-goPm2œ,œinputTypesœ:null,œtypeœ:œToolœ}",
|
||||
"style": { "stroke": "#555" },
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"animated": false,
|
||||
"id": "reactflow__edge-PythonFunctionTool-SQikY{œbaseClassesœ:[œToolœ],œdataTypeœ:œPythonFunctionToolœ,œidœ:œPythonFunctionTool-SQikYœ}-AgentInitializer-goPm2{œfieldNameœ:œtoolsœ,œidœ:œAgentInitializer-goPm2œ,œinputTypesœ:null,œtypeœ:œToolœ}",
|
||||
"selected": false,
|
||||
"data": {
|
||||
"sourceHandle": {
|
||||
"baseClasses": ["Tool"],
|
||||
"baseClasses": [
|
||||
"Tool"
|
||||
],
|
||||
"dataType": "PythonFunctionTool",
|
||||
"id": "PythonFunctionTool-SQikY"
|
||||
},
|
||||
|
|
@ -2681,4 +2881,4 @@
|
|||
"user_id": "6f6ebc2c-9e7a-4c35-84fc-51760db10d9b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,10 @@
|
|||
{
|
||||
"id": "PythonFunctionTool-RfJui",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 117.54690105175428, "y": -84.2465475108354 },
|
||||
"position": {
|
||||
"x": 117.54690105175428,
|
||||
"y": -84.2465475108354
|
||||
},
|
||||
"data": {
|
||||
"type": "PythonFunctionTool",
|
||||
"node": {
|
||||
|
|
@ -43,7 +46,9 @@
|
|||
"dynamic": false,
|
||||
"info": "",
|
||||
"title_case": false,
|
||||
"input_types": ["Text"]
|
||||
"input_types": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"name": {
|
||||
"type": "str",
|
||||
|
|
@ -61,7 +66,9 @@
|
|||
"dynamic": false,
|
||||
"info": "",
|
||||
"title_case": false,
|
||||
"input_types": ["Text"]
|
||||
"input_types": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"return_direct": {
|
||||
"type": "bool",
|
||||
|
|
@ -83,7 +90,10 @@
|
|||
"_type": "PythonFunctionTool"
|
||||
},
|
||||
"description": "Python function to be executed.",
|
||||
"base_classes": ["BaseTool", "Tool"],
|
||||
"base_classes": [
|
||||
"BaseTool",
|
||||
"Tool"
|
||||
],
|
||||
"display_name": "PythonFunctionTool",
|
||||
"documentation": "",
|
||||
"custom_fields": {},
|
||||
|
|
@ -97,13 +107,19 @@
|
|||
"selected": true,
|
||||
"width": 384,
|
||||
"height": 466,
|
||||
"positionAbsolute": { "x": 117.54690105175428, "y": -84.2465475108354 },
|
||||
"positionAbsolute": {
|
||||
"x": 117.54690105175428,
|
||||
"y": -84.2465475108354
|
||||
},
|
||||
"dragging": false
|
||||
},
|
||||
{
|
||||
"id": "AgentInitializer-tPdJw",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 677.68677055088, "y": 127.19859565276168 },
|
||||
"position": {
|
||||
"x": 677.68677055088,
|
||||
"y": 127.19859565276168
|
||||
},
|
||||
"data": {
|
||||
"type": "AgentInitializer",
|
||||
"node": {
|
||||
|
|
@ -192,7 +208,9 @@
|
|||
"dynamic": false,
|
||||
"info": "",
|
||||
"title_case": false,
|
||||
"input_types": ["Text"]
|
||||
"input_types": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"code": {
|
||||
"type": "code",
|
||||
|
|
@ -201,7 +219,7 @@
|
|||
"list": false,
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from typing import Callable, List, Optional, Union\n\nfrom langchain.agents import AgentExecutor, AgentType, initialize_agent, types\nfrom langflow import CustomComponent\nfrom langflow.field_typing import BaseChatMemory, BaseLanguageModel, Tool\n\n\nclass AgentInitializerComponent(CustomComponent):\n display_name: str = \"Agent Initializer\"\n description: str = \"Initialize a Langchain Agent.\"\n documentation: str = \"https://python.langchain.com/docs/modules/agents/agent_types/\"\n\n def build_config(self):\n agents = list(types.AGENT_TO_CLASS.keys())\n # field_type and required are optional\n return {\n \"agent\": {\"options\": agents, \"value\": agents[0], \"display_name\": \"Agent Type\"},\n \"max_iterations\": {\"display_name\": \"Max Iterations\", \"value\": 10},\n \"memory\": {\"display_name\": \"Memory\"},\n \"tools\": {\"display_name\": \"Tools\"},\n \"llm\": {\"display_name\": \"Language Model\"},\n \"code\": {\"advanced\": True},\n }\n\n def build(\n self,\n agent: str,\n llm: BaseLanguageModel,\n tools: List[Tool],\n max_iterations: int,\n memory: Optional[BaseChatMemory] = None,\n ) -> Union[AgentExecutor, Callable]:\n agent = AgentType(agent)\n if memory:\n return initialize_agent(\n tools=tools,\n llm=llm,\n agent=agent,\n memory=memory,\n return_intermediate_steps=True,\n handle_parsing_errors=True,\n max_iterations=max_iterations,\n )\n return initialize_agent(\n tools=tools,\n llm=llm,\n agent=agent,\n return_intermediate_steps=True,\n handle_parsing_errors=True,\n max_iterations=max_iterations,\n )\n",
|
||||
"value": "from typing import Callable, List, Optional, Union\n\nfrom langchain.agents import AgentExecutor, AgentType, initialize_agent, types\nfrom langflow.custom import CustomComponent\nfrom langflow.field_typing import BaseChatMemory, BaseLanguageModel, Tool\n\n\nclass AgentInitializerComponent(CustomComponent):\n display_name: str = \"Agent Initializer\"\n description: str = \"Initialize a Langchain Agent.\"\n documentation: str = \"https://python.langchain.com/docs/modules/agents/agent_types/\"\n\n def build_config(self):\n agents = list(types.AGENT_TO_CLASS.keys())\n # field_type and required are optional\n return {\n \"agent\": {\"options\": agents, \"value\": agents[0], \"display_name\": \"Agent Type\"},\n \"max_iterations\": {\"display_name\": \"Max Iterations\", \"value\": 10},\n \"memory\": {\"display_name\": \"Memory\"},\n \"tools\": {\"display_name\": \"Tools\"},\n \"llm\": {\"display_name\": \"Language Model\"},\n \"code\": {\"advanced\": True},\n }\n\n def build(\n self,\n agent: str,\n llm: BaseLanguageModel,\n tools: List[Tool],\n max_iterations: int,\n memory: Optional[BaseChatMemory] = None,\n ) -> Union[AgentExecutor, Callable]:\n agent = AgentType(agent)\n if memory:\n return initialize_agent(\n tools=tools,\n llm=llm,\n agent=agent,\n memory=memory,\n return_intermediate_steps=True,\n handle_parsing_errors=True,\n max_iterations=max_iterations,\n )\n return initialize_agent(\n tools=tools,\n llm=llm,\n agent=agent,\n return_intermediate_steps=True,\n handle_parsing_errors=True,\n max_iterations=max_iterations,\n )\n",
|
||||
"fileTypes": [],
|
||||
"file_path": "",
|
||||
"password": false,
|
||||
|
|
@ -251,7 +269,10 @@
|
|||
"max_iterations": null,
|
||||
"memory": null
|
||||
},
|
||||
"output_types": ["AgentExecutor", "Callable"],
|
||||
"output_types": [
|
||||
"AgentExecutor",
|
||||
"Callable"
|
||||
],
|
||||
"field_formatters": {},
|
||||
"pinned": false,
|
||||
"beta": true
|
||||
|
|
@ -265,7 +286,10 @@
|
|||
{
|
||||
"id": "ChatOpenAISpecs-stxRM",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 18.226716205350385, "y": 432.6122491402193 },
|
||||
"position": {
|
||||
"x": 18.226716205350385,
|
||||
"y": 432.6122491402193
|
||||
},
|
||||
"data": {
|
||||
"type": "ChatOpenAISpecs",
|
||||
"node": {
|
||||
|
|
@ -277,7 +301,7 @@
|
|||
"list": false,
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from typing import Optional, Union\n\nfrom langchain.llms import BaseLLM\nfrom langchain_community.chat_models.openai import ChatOpenAI\nfrom langflow import CustomComponent\nfrom langflow.field_typing import BaseLanguageModel, NestedDict\n\n\nclass ChatOpenAIComponent(CustomComponent):\n display_name = \"ChatOpenAI\"\n description = \"`OpenAI` Chat large language models API.\"\n icon = \"OpenAI\"\n\n def build_config(self):\n return {\n \"max_tokens\": {\n \"display_name\": \"Max Tokens\",\n \"advanced\": False,\n \"required\": False,\n },\n \"model_kwargs\": {\n \"display_name\": \"Model Kwargs\",\n \"advanced\": True,\n \"required\": False,\n },\n \"model_name\": {\n \"display_name\": \"Model Name\",\n \"advanced\": False,\n \"required\": False,\n \"options\": [\n \"gpt-4-turbo-preview\",\n \"gpt-4-0125-preview\",\n \"gpt-4-1106-preview\",\n \"gpt-4-vision-preview\",\n \"gpt-3.5-turbo-0125\",\n \"gpt-3.5-turbo-1106\",\n ],\n },\n \"openai_api_base\": {\n \"display_name\": \"OpenAI API Base\",\n \"advanced\": False,\n \"required\": False,\n \"info\": (\n \"The base URL of the OpenAI API. Defaults to https://api.openai.com/v1.\\n\\n\"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\"\n ),\n },\n \"openai_api_key\": {\n \"display_name\": \"OpenAI API Key\",\n \"advanced\": False,\n \"required\": False,\n \"password\": True,\n },\n \"temperature\": {\n \"display_name\": \"Temperature\",\n \"advanced\": False,\n \"required\": False,\n \"value\": 0.7,\n },\n }\n\n def build(\n self,\n max_tokens: Optional[int] = 256,\n model_kwargs: NestedDict = {},\n model_name: str = \"gpt-4-1106-preview\",\n openai_api_base: Optional[str] = None,\n openai_api_key: Optional[str] = None,\n temperature: float = 0.7,\n ) -> Union[BaseLanguageModel, BaseLLM]:\n if not openai_api_base:\n openai_api_base = \"https://api.openai.com/v1\"\n return ChatOpenAI(\n max_tokens=max_tokens,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=openai_api_key,\n temperature=temperature,\n )\n",
|
||||
"value": "from typing import Optional, Union\n\nfrom langchain.llms import BaseLLM\nfrom langchain_community.chat_models.openai import ChatOpenAI\nfrom langflow.custom import CustomComponent\nfrom langflow.field_typing import BaseLanguageModel, NestedDict\n\n\nclass ChatOpenAIComponent(CustomComponent):\n display_name = \"ChatOpenAI\"\n description = \"`OpenAI` Chat large language models API.\"\n icon = \"OpenAI\"\n\n def build_config(self):\n return {\n \"max_tokens\": {\n \"display_name\": \"Max Tokens\",\n \"advanced\": False,\n \"required\": False,\n },\n \"model_kwargs\": {\n \"display_name\": \"Model Kwargs\",\n \"advanced\": True,\n \"required\": False,\n },\n \"model_name\": {\n \"display_name\": \"Model Name\",\n \"advanced\": False,\n \"required\": False,\n \"options\": [\n \"gpt-4-turbo-preview\",\n \"gpt-4-0125-preview\",\n \"gpt-4-1106-preview\",\n \"gpt-4-vision-preview\",\n \"gpt-3.5-turbo-0125\",\n \"gpt-3.5-turbo-1106\",\n ],\n },\n \"openai_api_base\": {\n \"display_name\": \"OpenAI API Base\",\n \"advanced\": False,\n \"required\": False,\n \"info\": (\n \"The base URL of the OpenAI API. Defaults to https://api.openai.com/v1.\\n\\n\"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\"\n ),\n },\n \"openai_api_key\": {\n \"display_name\": \"OpenAI API Key\",\n \"advanced\": False,\n \"required\": False,\n \"password\": True,\n },\n \"temperature\": {\n \"display_name\": \"Temperature\",\n \"advanced\": False,\n \"required\": False,\n \"value\": 0.7,\n },\n }\n\n def build(\n self,\n max_tokens: Optional[int] = 256,\n model_kwargs: NestedDict = {},\n model_name: str = \"gpt-4-1106-preview\",\n openai_api_base: Optional[str] = None,\n openai_api_key: Optional[str] = None,\n temperature: float = 0.7,\n ) -> Union[BaseLanguageModel, BaseLLM]:\n if not openai_api_base:\n openai_api_base = \"https://api.openai.com/v1\"\n return ChatOpenAI(\n max_tokens=max_tokens,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=openai_api_key,\n temperature=temperature,\n )\n",
|
||||
"fileTypes": [],
|
||||
"file_path": "",
|
||||
"password": false,
|
||||
|
|
@ -348,7 +372,9 @@
|
|||
"dynamic": false,
|
||||
"info": "",
|
||||
"title_case": false,
|
||||
"input_types": ["Text"]
|
||||
"input_types": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"openai_api_base": {
|
||||
"type": "str",
|
||||
|
|
@ -366,7 +392,9 @@
|
|||
"dynamic": false,
|
||||
"info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1.\n\nYou can change this to use other APIs like JinaChat, LocalAI and Prem.",
|
||||
"title_case": false,
|
||||
"input_types": ["Text"]
|
||||
"input_types": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"openai_api_key": {
|
||||
"type": "str",
|
||||
|
|
@ -384,7 +412,9 @@
|
|||
"dynamic": false,
|
||||
"info": "",
|
||||
"title_case": false,
|
||||
"input_types": ["Text"]
|
||||
"input_types": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"temperature": {
|
||||
"type": "float",
|
||||
|
|
@ -402,7 +432,11 @@
|
|||
"advanced": false,
|
||||
"dynamic": false,
|
||||
"info": "",
|
||||
"rangeSpec": { "min": -1, "max": 1, "step": 0.1 },
|
||||
"rangeSpec": {
|
||||
"min": -1,
|
||||
"max": 1,
|
||||
"step": 0.1
|
||||
},
|
||||
"title_case": false
|
||||
},
|
||||
"_type": "CustomComponent"
|
||||
|
|
@ -428,7 +462,10 @@
|
|||
"openai_api_key": null,
|
||||
"temperature": null
|
||||
},
|
||||
"output_types": ["BaseLanguageModel", "BaseLLM"],
|
||||
"output_types": [
|
||||
"BaseLanguageModel",
|
||||
"BaseLLM"
|
||||
],
|
||||
"field_formatters": {},
|
||||
"pinned": false,
|
||||
"beta": true
|
||||
|
|
@ -438,7 +475,10 @@
|
|||
"selected": false,
|
||||
"width": 384,
|
||||
"height": 666,
|
||||
"positionAbsolute": { "x": 18.226716205350385, "y": 432.6122491402193 },
|
||||
"positionAbsolute": {
|
||||
"x": 18.226716205350385,
|
||||
"y": 432.6122491402193
|
||||
},
|
||||
"dragging": false
|
||||
}
|
||||
],
|
||||
|
|
@ -469,7 +509,9 @@
|
|||
"id": "ChatOpenAISpecs-stxRM"
|
||||
}
|
||||
},
|
||||
"style": { "stroke": "#555" },
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-foreground stroke-connection",
|
||||
"id": "reactflow__edge-ChatOpenAISpecs-stxRM{œbaseClassesœ:[œRunnableœ,œBaseLLMœ,œSerializableœ,œBaseLanguageModelœ,œobjectœ,œGenericœ,œRunnableSerializableœ],œdataTypeœ:œChatOpenAISpecsœ,œidœ:œChatOpenAISpecs-stxRMœ}-AgentInitializer-tPdJw{œfieldNameœ:œllmœ,œidœ:œAgentInitializer-tPdJwœ,œinputTypesœ:null,œtypeœ:œBaseLanguageModelœ}"
|
||||
},
|
||||
|
|
@ -486,12 +528,17 @@
|
|||
"type": "Tool"
|
||||
},
|
||||
"sourceHandle": {
|
||||
"baseClasses": ["BaseTool", "Tool"],
|
||||
"baseClasses": [
|
||||
"BaseTool",
|
||||
"Tool"
|
||||
],
|
||||
"dataType": "PythonFunctionTool",
|
||||
"id": "PythonFunctionTool-RfJui"
|
||||
}
|
||||
},
|
||||
"style": { "stroke": "#555" },
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-foreground stroke-connection",
|
||||
"id": "reactflow__edge-PythonFunctionTool-RfJui{œbaseClassesœ:[œBaseToolœ,œToolœ],œdataTypeœ:œPythonFunctionToolœ,œidœ:œPythonFunctionTool-RfJuiœ}-AgentInitializer-tPdJw{œfieldNameœ:œtoolsœ,œidœ:œAgentInitializer-tPdJwœ,œinputTypesœ:null,œtypeœ:œToolœ}"
|
||||
}
|
||||
|
|
@ -506,4 +553,4 @@
|
|||
"name": "Untitled document (20)",
|
||||
"last_tested_version": "0.7.0a0",
|
||||
"is_component": false
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,10 @@
|
|||
"height": 461,
|
||||
"id": "CustomComponent-MtJjl",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 534.3712097224906, "y": -135.01908566635723 },
|
||||
"position": {
|
||||
"x": 534.3712097224906,
|
||||
"y": -135.01908566635723
|
||||
},
|
||||
"data": {
|
||||
"type": "CustomComponent",
|
||||
"node": {
|
||||
|
|
@ -20,7 +23,7 @@
|
|||
"list": false,
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from langflow import CustomComponent\nfrom langflow.field_typing import Data\nfrom pathlib import Path\nfrom platformdirs import user_cache_dir\nimport os\n\nclass Component(CustomComponent):\n documentation: str = \"http://docs.langflow.org/components/custom\"\n\n def build_config(self):\n return {\"text_input\":{\"display_name\":\"Text Input\", \"input_types\":[\"str\"]},\"save_path\":{\"display_name\":\"Save Path\",\n \"info\":\"Put the full path with the file name and extension\",\"value\":Path(user_cache_dir(\"langflow\"))/\"text.t1.txt\"}}\n\n def build(self, text_input:str,save_path:str) -> str:\n try:\n # Create the directory if it doesn't exist\n os.makedirs(os.path.dirname(save_path), exist_ok=True)\n\n # Open the file in write mode and save the text\n with open(save_path, 'w') as file:\n file.write(text_input)\n except Exception as e:\n raise e\n self.status = text_input\n return text_input",
|
||||
"value": "from langflow.custom import CustomComponent\nfrom langflow.field_typing import Data\nfrom pathlib import Path\nfrom platformdirs import user_cache_dir\nimport os\n\nclass Component(CustomComponent):\n documentation: str = \"http://docs.langflow.org/components/custom\"\n\n def build_config(self):\n return {\"text_input\":{\"display_name\":\"Text Input\", \"input_types\":[\"str\"]},\"save_path\":{\"display_name\":\"Save Path\",\n \"info\":\"Put the full path with the file name and extension\",\"value\":Path(user_cache_dir(\"langflow\"))/\"text.t1.txt\"}}\n\n def build(self, text_input:str,save_path:str) -> str:\n try:\n # Create the directory if it doesn't exist\n os.makedirs(os.path.dirname(save_path), exist_ok=True)\n\n # Open the file in write mode and save the text\n with open(save_path, 'w') as file:\n file.write(text_input)\n except Exception as e:\n raise e\n self.status = text_input\n return text_input",
|
||||
"fileTypes": [],
|
||||
"file_path": "",
|
||||
"password": false,
|
||||
|
|
@ -59,18 +62,27 @@
|
|||
"name": "text_input",
|
||||
"display_name": "Text Input",
|
||||
"advanced": false,
|
||||
"input_types": ["str"],
|
||||
"input_types": [
|
||||
"str"
|
||||
],
|
||||
"dynamic": false,
|
||||
"info": "",
|
||||
"value": ""
|
||||
},
|
||||
"_type": "CustomComponent"
|
||||
},
|
||||
"base_classes": ["str"],
|
||||
"base_classes": [
|
||||
"str"
|
||||
],
|
||||
"display_name": "text checkpoint",
|
||||
"documentation": "http://docs.langflow.org/components/custom",
|
||||
"custom_fields": { "save_path": null, "text_input": null },
|
||||
"output_types": ["str"],
|
||||
"custom_fields": {
|
||||
"save_path": null,
|
||||
"text_input": null
|
||||
},
|
||||
"output_types": [
|
||||
"str"
|
||||
],
|
||||
"field_formatters": {},
|
||||
"beta": true
|
||||
},
|
||||
|
|
@ -78,14 +90,20 @@
|
|||
},
|
||||
"selected": false,
|
||||
"dragging": false,
|
||||
"positionAbsolute": { "x": 534.3712097224906, "y": -135.01908566635723 }
|
||||
"positionAbsolute": {
|
||||
"x": 534.3712097224906,
|
||||
"y": -135.01908566635723
|
||||
}
|
||||
},
|
||||
{
|
||||
"width": 384,
|
||||
"height": 453,
|
||||
"id": "CustomComponent-7NQoq",
|
||||
"type": "genericNode",
|
||||
"position": { "x": 27.487979888011637, "y": -414.43998171034826 },
|
||||
"position": {
|
||||
"x": 27.487979888011637,
|
||||
"y": -414.43998171034826
|
||||
},
|
||||
"data": {
|
||||
"type": "CustomComponent",
|
||||
"node": {
|
||||
|
|
@ -131,7 +149,7 @@
|
|||
"list": false,
|
||||
"show": true,
|
||||
"multiline": true,
|
||||
"value": "from langflow import CustomComponent\nfrom typing import Optional, List, Dict, Union\nfrom langflow.field_typing import (\n AgentExecutor,\n BaseChatMemory,\n BaseLanguageModel,\n BaseLLM,\n BaseLoader,\n BaseMemory,\n BaseOutputParser,\n BasePromptTemplate,\n BaseRetriever,\n Callable,\n Chain,\n ChatPromptTemplate,\n Data,\n Document,\n Embeddings,\n NestedDict,\n Object,\n PromptTemplate,\n TextSplitter,\n Tool,\n VectorStore,\n)\n\nfrom openai import OpenAI\nimport os\nimport ffmpeg\n\nclass Component(CustomComponent):\n display_name: str = \"Whisper Transcriber\"\n description: str = \"Converts audio to text using OpenAI's Whisper.\"\n\n def build_config(self):\n return {\"audio\": {\"field_type\": \"file\", \"suffixes\": [\".mp3\", \".mp4\", \".m4a\"]}, \"OpenAIKey\": {\"field_type\": \"str\", \"password\": True}}\n\n def calculate_segment_duration(self, audio_path, target_chunk_size_mb=24):\n # Calculate the target chunk size in bytes\n target_chunk_size_bytes = target_chunk_size_mb * 1024 * 1024\n\n # Use ffprobe to get the audio file information\n ffprobe_output = ffmpeg.probe(audio_path)\n print(ffprobe_output)\n # Convert duration to float\n duration = float(ffprobe_output[\"format\"][\"duration\"])\n\n # Calculate the approximate bitrate\n bitrate = os.path.getsize(audio_path) / duration\n\n # Calculate the segment duration to achieve the target chunk size\n segment_duration = target_chunk_size_bytes / bitrate\n\n return segment_duration\n\n def split_audio_into_chunks(self, audio_path, target_chunk_size_mb=24):\n # Calculate the segment duration\n segment_duration = self.calculate_segment_duration(audio_path, target_chunk_size_mb)\n\n # Create a directory to store the chunks\n output_directory = f\"{os.path.splitext(audio_path)[0]}_chunks\"\n os.makedirs(output_directory, exist_ok=True)\n\n # Use ffmpeg-python to split the audio file into chunks\n (\n ffmpeg.input(audio_path)\n .output(f\"{output_directory}/%03d{os.path.splitext(audio_path)[1]}\", codec=\"copy\", f=\"segment\", segment_time=segment_duration)\n .run()\n )\n\n # Get the list of generated chunk files\n chunks = [os.path.join(output_directory, file) for file in os.listdir(output_directory)]\n\n return chunks\n\n def build(self, audio: str, OpenAIKey: str) -> str:\n # Split audio into chunks\n audio_chunks = self.split_audio_into_chunks(audio)\n\n client = OpenAI(api_key=OpenAIKey)\n transcripts = []\n\n try:\n for chunk in audio_chunks:\n with open(chunk, \"rb\") as chunk_file:\n transcript = client.audio.transcriptions.create(\n model=\"whisper-1\",\n file=chunk_file,\n response_format=\"text\"\n )\n transcripts.append(transcript)\n finally:\n # Clean up temporary chunk files\n for chunk in audio_chunks:\n os.remove(chunk)\n\n # Concatenate transcripts into the final response\n final_response = \"\\n\".join(transcripts)\n self.status = final_response\n return final_response\n",
|
||||
"value": "from langflow.custom import CustomComponent\nfrom typing import Optional, List, Dict, Union\nfrom langflow.field_typing import (\n AgentExecutor,\n BaseChatMemory,\n BaseLanguageModel,\n BaseLLM,\n BaseLoader,\n BaseMemory,\n BaseOutputParser,\n BasePromptTemplate,\n BaseRetriever,\n Callable,\n Chain,\n ChatPromptTemplate,\n Data,\n Document,\n Embeddings,\n NestedDict,\n Object,\n PromptTemplate,\n TextSplitter,\n Tool,\n VectorStore,\n)\n\nfrom openai import OpenAI\nimport os\nimport ffmpeg\n\nclass Component(CustomComponent):\n display_name: str = \"Whisper Transcriber\"\n description: str = \"Converts audio to text using OpenAI's Whisper.\"\n\n def build_config(self):\n return {\"audio\": {\"field_type\": \"file\", \"suffixes\": [\".mp3\", \".mp4\", \".m4a\"]}, \"OpenAIKey\": {\"field_type\": \"str\", \"password\": True}}\n\n def calculate_segment_duration(self, audio_path, target_chunk_size_mb=24):\n # Calculate the target chunk size in bytes\n target_chunk_size_bytes = target_chunk_size_mb * 1024 * 1024\n\n # Use ffprobe to get the audio file information\n ffprobe_output = ffmpeg.probe(audio_path)\n print(ffprobe_output)\n # Convert duration to float\n duration = float(ffprobe_output[\"format\"][\"duration\"])\n\n # Calculate the approximate bitrate\n bitrate = os.path.getsize(audio_path) / duration\n\n # Calculate the segment duration to achieve the target chunk size\n segment_duration = target_chunk_size_bytes / bitrate\n\n return segment_duration\n\n def split_audio_into_chunks(self, audio_path, target_chunk_size_mb=24):\n # Calculate the segment duration\n segment_duration = self.calculate_segment_duration(audio_path, target_chunk_size_mb)\n\n # Create a directory to store the chunks\n output_directory = f\"{os.path.splitext(audio_path)[0]}_chunks\"\n os.makedirs(output_directory, exist_ok=True)\n\n # Use ffmpeg-python to split the audio file into chunks\n (\n ffmpeg.input(audio_path)\n .output(f\"{output_directory}/%03d{os.path.splitext(audio_path)[1]}\", codec=\"copy\", f=\"segment\", segment_time=segment_duration)\n .run()\n )\n\n # Get the list of generated chunk files\n chunks = [os.path.join(output_directory, file) for file in os.listdir(output_directory)]\n\n return chunks\n\n def build(self, audio: str, OpenAIKey: str) -> str:\n # Split audio into chunks\n audio_chunks = self.split_audio_into_chunks(audio)\n\n client = OpenAI(api_key=OpenAIKey)\n transcripts = []\n\n try:\n for chunk in audio_chunks:\n with open(chunk, \"rb\") as chunk_file:\n transcript = client.audio.transcriptions.create(\n model=\"whisper-1\",\n file=chunk_file,\n response_format=\"text\"\n )\n transcripts.append(transcript)\n finally:\n # Clean up temporary chunk files\n for chunk in audio_chunks:\n os.remove(chunk)\n\n # Concatenate transcripts into the final response\n final_response = \"\\n\".join(transcripts)\n self.status = final_response\n return final_response\n",
|
||||
"fileTypes": [],
|
||||
"file_path": "",
|
||||
"password": false,
|
||||
|
|
@ -143,11 +161,18 @@
|
|||
"_type": "CustomComponent"
|
||||
},
|
||||
"description": "Converts audio to text using OpenAI's Whisper.",
|
||||
"base_classes": ["str"],
|
||||
"base_classes": [
|
||||
"str"
|
||||
],
|
||||
"display_name": "Whisper Transcriber",
|
||||
"documentation": "",
|
||||
"custom_fields": { "OpenAIKey": null, "audio": null },
|
||||
"output_types": ["str"],
|
||||
"custom_fields": {
|
||||
"OpenAIKey": null,
|
||||
"audio": null
|
||||
},
|
||||
"output_types": [
|
||||
"str"
|
||||
],
|
||||
"field_formatters": {},
|
||||
"beta": true
|
||||
},
|
||||
|
|
@ -171,26 +196,36 @@
|
|||
"targetHandle": {
|
||||
"fieldName": "text_input",
|
||||
"id": "CustomComponent-MtJjl",
|
||||
"inputTypes": ["str"],
|
||||
"inputTypes": [
|
||||
"str"
|
||||
],
|
||||
"type": "str"
|
||||
},
|
||||
"sourceHandle": {
|
||||
"baseClasses": ["str"],
|
||||
"baseClasses": [
|
||||
"str"
|
||||
],
|
||||
"dataType": "CustomComponent",
|
||||
"id": "CustomComponent-7NQoq"
|
||||
}
|
||||
},
|
||||
"style": { "stroke": "#555" },
|
||||
"style": {
|
||||
"stroke": "#555"
|
||||
},
|
||||
"className": "stroke-gray-900 stroke-connection",
|
||||
"animated": false,
|
||||
"id": "reactflow__edge-CustomComponent-7NQoq{œbaseClassesœ:[œstrœ],œdataTypeœ:œCustomComponentœ,œidœ:œCustomComponent-7NQoqœ}-CustomComponent-MtJjl{œfieldNameœ:œtext_inputœ,œidœ:œCustomComponent-MtJjlœ,œinputTypesœ:[œstrœ],œtypeœ:œstrœ}"
|
||||
}
|
||||
],
|
||||
"viewport": { "x": 119.37759169012509, "y": 351.3082742479685, "zoom": 1 }
|
||||
"viewport": {
|
||||
"x": 119.37759169012509,
|
||||
"y": 351.3082742479685,
|
||||
"zoom": 1
|
||||
}
|
||||
},
|
||||
"is_component": false,
|
||||
"updated_at": "2023-12-13T23:51:56.874099",
|
||||
"folder": null,
|
||||
"id": "1b0814b7-2964-4e09-9b4b-f7413c4fb50b",
|
||||
"user_id": "8b5cf798-f1b8-4108-88fd-d7274d08d471"
|
||||
}
|
||||
}
|
||||
|
|
@ -195,4 +195,66 @@ test("dropDownComponent", async ({ page }) => {
|
|||
if (value !== "ai21.j2-ultra-v1") {
|
||||
expect(false).toBeTruthy();
|
||||
}
|
||||
});
|
||||
await page.getByTestId("code-button-modal").click();
|
||||
await page
|
||||
.locator("#CodeEditor div")
|
||||
.filter({ hasText: "from typing import" })
|
||||
.nth(1)
|
||||
.click();
|
||||
await page.locator("textarea").press("Control+a");
|
||||
const emptyOptionsCode = `from typing import Optional
|
||||
from langchain.llms.base import BaseLLM
|
||||
from langchain_community.llms.bedrock import Bedrock
|
||||
|
||||
from langflow.interface.custom.custom_component import CustomComponent
|
||||
|
||||
|
||||
class AmazonBedrockComponent(CustomComponent):
|
||||
display_name: str = "Amazon Bedrock"
|
||||
description: str = "LLM model from Amazon Bedrock."
|
||||
icon = "Amazon"
|
||||
|
||||
def build_config(self):
|
||||
return {
|
||||
"model_id": {
|
||||
"display_name": "Model Id",
|
||||
"options": [],
|
||||
},
|
||||
"credentials_profile_name": {"display_name": "Credentials Profile Name"},
|
||||
"streaming": {"display_name": "Streaming", "field_type": "bool"},
|
||||
"endpoint_url": {"display_name": "Endpoint URL"},
|
||||
"region_name": {"display_name": "Region Name"},
|
||||
"model_kwargs": {"display_name": "Model Kwargs"},
|
||||
"cache": {"display_name": "Cache"},
|
||||
"code": {"advanced": True},
|
||||
}
|
||||
|
||||
def build(
|
||||
self,
|
||||
model_id: str = "anthropic.claude-instant-v1",
|
||||
credentials_profile_name: Optional[str] = None,
|
||||
region_name: Optional[str] = None,
|
||||
model_kwargs: Optional[dict] = None,
|
||||
endpoint_url: Optional[str] = None,
|
||||
streaming: bool = False,
|
||||
cache: Optional[bool] = None,
|
||||
) -> BaseLLM:
|
||||
try:
|
||||
output = Bedrock(
|
||||
credentials_profile_name=credentials_profile_name,
|
||||
model_id=model_id,
|
||||
region_name=region_name,
|
||||
model_kwargs=model_kwargs,
|
||||
endpoint_url=endpoint_url,
|
||||
streaming=streaming,
|
||||
cache=cache,
|
||||
) # type: ignore
|
||||
except Exception as e:
|
||||
raise ValueError("Could not connect to AmazonBedrock API.") from e
|
||||
return output
|
||||
|
||||
`;
|
||||
await page.locator("textarea").fill(emptyOptionsCode);
|
||||
await page.getByRole('button', { name: 'Check & Save' }).click();
|
||||
await page.getByText("No parameters are available for display.").isVisible();
|
||||
})
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ test("InputComponent", async ({ page }) => {
|
|||
await page.getByTestId("input-collection_name-edit").click();
|
||||
await page
|
||||
.getByTestId("input-collection_name-edit")
|
||||
.fill("NEW_collection_name_test_123123123!@#$&*(&%$@");
|
||||
.fill("NEW_collection_name_test_123123123!@#$&*(&%$@ÇÇÇÀõe");
|
||||
|
||||
await page.locator('//*[@id="saveChangesBtn"]').click();
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ test("InputComponent", async ({ page }) => {
|
|||
|
||||
let value = await page.getByTestId("input-collection_name").inputValue();
|
||||
|
||||
if (value != "NEW_collection_name_test_123123123!@#$&*(&%$@") {
|
||||
if (value != "NEW_collection_name_test_123123123!@#$&*(&%$@ÇÇÇÀõe") {
|
||||
expect(false).toBeTruthy();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue