Merge branch 'form_io' of personal:logspace-ai/langflow into form_io
This commit is contained in:
commit
786d089eb3
6 changed files with 22 additions and 27 deletions
|
|
@ -68,7 +68,11 @@ def instantiate_based_on_type(class_object, base_type, node_type, params):
|
||||||
elif base_type == "prompts":
|
elif base_type == "prompts":
|
||||||
return instantiate_prompt(node_type, class_object, params)
|
return instantiate_prompt(node_type, class_object, params)
|
||||||
elif base_type == "tools":
|
elif base_type == "tools":
|
||||||
return instantiate_tool(node_type, class_object, params)
|
tool = instantiate_tool(node_type, class_object, params)
|
||||||
|
if hasattr(tool, "name") and isinstance(tool, BaseTool):
|
||||||
|
# tool name shouldn't contain spaces
|
||||||
|
tool.name = tool.name.replace(" ", "_")
|
||||||
|
return tool
|
||||||
elif base_type == "toolkits":
|
elif base_type == "toolkits":
|
||||||
return instantiate_toolkit(node_type, class_object, params)
|
return instantiate_toolkit(node_type, class_object, params)
|
||||||
elif base_type == "embeddings":
|
elif base_type == "embeddings":
|
||||||
|
|
@ -133,6 +137,9 @@ def instantiate_llm(node_type, class_object, params: Dict):
|
||||||
def instantiate_memory(node_type, class_object, params):
|
def instantiate_memory(node_type, class_object, params):
|
||||||
# process input_key and output_key to remove them if
|
# process input_key and output_key to remove them if
|
||||||
# they are empty strings
|
# they are empty strings
|
||||||
|
if node_type == "ConversationEntityMemory":
|
||||||
|
params.pop("memory_key", None)
|
||||||
|
|
||||||
for key in ["input_key", "output_key"]:
|
for key in ["input_key", "output_key"]:
|
||||||
if key in params and (params[key] == "" or not params[key]):
|
if key in params and (params[key] == "" or not params[key]):
|
||||||
params.pop(key)
|
params.pop(key)
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,11 @@ async def get_result_and_steps(langchain_object, inputs: Union[dict, str], **kwa
|
||||||
# Deactivating until we have a frontend solution
|
# Deactivating until we have a frontend solution
|
||||||
# to display intermediate steps
|
# to display intermediate steps
|
||||||
langchain_object.return_intermediate_steps = True
|
langchain_object.return_intermediate_steps = True
|
||||||
|
try:
|
||||||
fix_memory_inputs(langchain_object)
|
fix_memory_inputs(langchain_object)
|
||||||
|
except Exception as exc:
|
||||||
|
logger.error(exc)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async_callbacks = [AsyncStreamingLLMCallbackHandler(**kwargs)]
|
async_callbacks = [AsyncStreamingLLMCallbackHandler(**kwargs)]
|
||||||
output = await langchain_object.acall(inputs, callbacks=async_callbacks)
|
output = await langchain_object.acall(inputs, callbacks=async_callbacks)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,10 @@ def fix_memory_inputs(langchain_object):
|
||||||
if not hasattr(langchain_object, "memory") or langchain_object.memory is None:
|
if not hasattr(langchain_object, "memory") or langchain_object.memory is None:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
if langchain_object.memory.memory_key in langchain_object.input_variables:
|
if (
|
||||||
|
hasattr(langchain_object.memory, "memory_key")
|
||||||
|
and langchain_object.memory.memory_key in langchain_object.input_variables
|
||||||
|
):
|
||||||
return
|
return
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
input_variables = (
|
input_variables = (
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,9 @@ class MemoryFrontendNode(FrontendNode):
|
||||||
field.show = True
|
field.show = True
|
||||||
if field.name == "entity_store":
|
if field.name == "entity_store":
|
||||||
field.show = False
|
field.show = False
|
||||||
|
if name == "ConversationEntityMemory" and field.name == "memory_key":
|
||||||
|
field.show = False
|
||||||
|
field.required = False
|
||||||
|
|
||||||
|
|
||||||
class PostgresChatMessageHistoryFrontendNode(MemoryFrontendNode):
|
class PostgresChatMessageHistoryFrontendNode(MemoryFrontendNode):
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import "ace-builds/src-noconflict/mode-python";
|
||||||
import "ace-builds/src-noconflict/theme-github";
|
import "ace-builds/src-noconflict/theme-github";
|
||||||
import "ace-builds/src-noconflict/theme-twilight";
|
import "ace-builds/src-noconflict/theme-twilight";
|
||||||
import { TerminalSquare } from "lucide-react";
|
import { TerminalSquare } from "lucide-react";
|
||||||
import { useContext, useRef, useState } from "react";
|
import { useContext, useState } from "react";
|
||||||
import AceEditor from "react-ace";
|
import AceEditor from "react-ace";
|
||||||
import { Button } from "../../components/ui/button";
|
import { Button } from "../../components/ui/button";
|
||||||
import { CODE_PROMPT_DIALOG_SUBTITLE } from "../../constants";
|
import { CODE_PROMPT_DIALOG_SUBTITLE } from "../../constants";
|
||||||
|
|
@ -31,10 +31,6 @@ export default function CodeAreaModal({
|
||||||
const { dark } = useContext(darkContext);
|
const { dark } = useContext(darkContext);
|
||||||
const { closePopUp, setCloseEdit } = useContext(PopUpContext);
|
const { closePopUp, setCloseEdit } = useContext(PopUpContext);
|
||||||
const { setErrorData, setSuccessData } = useContext(alertContext);
|
const { setErrorData, setSuccessData } = useContext(alertContext);
|
||||||
const [error, setError] = useState<{
|
|
||||||
detail: { error: string; traceback: string };
|
|
||||||
}>(null);
|
|
||||||
const ref = useRef();
|
|
||||||
|
|
||||||
function setModalOpen(x: boolean) {
|
function setModalOpen(x: boolean) {
|
||||||
if (x === false) {
|
if (x === false) {
|
||||||
|
|
@ -113,23 +109,6 @@ export default function CodeAreaModal({
|
||||||
className="h-full w-full rounded-lg border-[1px] border-gray-300 custom-scroll dark:border-gray-600"
|
className="h-full w-full rounded-lg border-[1px] border-gray-300 custom-scroll dark:border-gray-600"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
|
||||||
className={
|
|
||||||
"w-full transition-all delay-500 " +
|
|
||||||
(error?.detail.error !== undefined ? "h-2/6" : "h-0")
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<div className="mt-1 h-full w-full overflow-x-clip overflow-y-scroll text-left custom-scroll">
|
|
||||||
<h1 className="text-lg text-destructive">
|
|
||||||
{error?.detail?.error}
|
|
||||||
</h1>
|
|
||||||
<div className="ml-2 w-full break-all text-sm text-status-red">
|
|
||||||
<pre className="w-full whitespace-pre-wrap break-all">
|
|
||||||
{error?.detail?.traceback}
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex h-fit w-full justify-end">
|
<div className="flex h-fit w-full justify-end">
|
||||||
<Button className="mt-3" onClick={handleClick} type="submit">
|
<Button className="mt-3" onClick={handleClick} type="submit">
|
||||||
Check & Save
|
Check & Save
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,8 @@ export default function Page({ flow }: { flow: FlowType }) {
|
||||||
const onSelectionEnd = useCallback(() => {
|
const onSelectionEnd = useCallback(() => {
|
||||||
setSelectionEnded(true);
|
setSelectionEnded(true);
|
||||||
}, []);
|
}, []);
|
||||||
const onSelectionStart = useCallback(() => {
|
const onSelectionStart = useCallback((event) => {
|
||||||
|
event.preventDefault();
|
||||||
setSelectionEnded(false);
|
setSelectionEnded(false);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
@ -410,7 +411,6 @@ export default function Page({ flow }: { flow: FlowType }) {
|
||||||
nodesDraggable={!disableCopyPaste}
|
nodesDraggable={!disableCopyPaste}
|
||||||
panOnDrag={!disableCopyPaste}
|
panOnDrag={!disableCopyPaste}
|
||||||
zoomOnDoubleClick={!disableCopyPaste}
|
zoomOnDoubleClick={!disableCopyPaste}
|
||||||
selectNodesOnDrag={false}
|
|
||||||
className="theme-attribution"
|
className="theme-attribution"
|
||||||
minZoom={0.01}
|
minZoom={0.01}
|
||||||
maxZoom={8}
|
maxZoom={8}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue