fix modal returning to input
This commit is contained in:
parent
e0e361d39c
commit
7d72254ac8
2 changed files with 1114 additions and 1111 deletions
|
|
@ -22,7 +22,7 @@
|
||||||
"list": false,
|
"list": false,
|
||||||
"show": true,
|
"show": true,
|
||||||
"multiline": true,
|
"multiline": true,
|
||||||
"value": "from langchain_core.prompts import PromptTemplate\n\nfrom langflow.field_typing import Prompt, TemplateField, Text\nfrom langflow.interface.custom.custom_component import CustomComponent\n\n\nclass PromptComponent(CustomComponent):\n display_name: str = \"Prompt\"\n description: str = \"Create a prompt template with dynamic variables.\"\n icon = \"terminal-square\"\n\n def build_config(self):\n return {\n \"template\": TemplateField(display_name=\"Template\"),\n \"code\": TemplateField(advanced=True),\n }\n\n def build(\n self,\n template: Prompt,\n **kwargs,\n ) -> Text:\n from langflow.base.prompts.utils import dict_values_to_string\n\n prompt_template = PromptTemplate.from_template(Text(template))\n kwargs = dict_values_to_string(kwargs)\n kwargs = {k: \"\\n\".join(v) if isinstance(v, list) else v for k, v in kwargs.items()}\n try:\n formated_prompt = prompt_template.format(**kwargs)\n except Exception as exc:\n raise ValueError(f\"Error formatting prompt: {exc}\") from exc\n self.status = f'Prompt:\\n\"{formated_prompt}\"'\n return formated_prompt\n",
|
"value": "from langchain_core.prompts import PromptTemplate\n\nfrom langflow.field_typing import Prompt, TemplateField, Text\nfrom langflow.interface.custom.custom_component import CustomComponent\n\n\nclass PromptComponent(CustomComponent):\n display_name: str = \"Prompt\"\n description: str = \"Create a prompt template with dynamic variables.\"\n icon = \"prompts\"\n\n def build_config(self):\n return {\n \"template\": TemplateField(display_name=\"Template\"),\n \"code\": TemplateField(advanced=True),\n }\n\n def build(\n self,\n template: Prompt,\n **kwargs,\n ) -> Text:\n from langflow.base.prompts.utils import dict_values_to_string\n\n prompt_template = PromptTemplate.from_template(Text(template))\n kwargs = dict_values_to_string(kwargs)\n kwargs = {k: \"\\n\".join(v) if isinstance(v, list) else v for k, v in kwargs.items()}\n try:\n formated_prompt = prompt_template.format(**kwargs)\n except Exception as exc:\n raise ValueError(f\"Error formatting prompt: {exc}\") from exc\n self.status = f'Prompt:\\n\"{formated_prompt}\"'\n return formated_prompt\n",
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
|
|
@ -110,7 +110,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "Create a prompt template with dynamic variables.",
|
"description": "Create a prompt template with dynamic variables.",
|
||||||
"icon": "terminal-square",
|
"icon": "prompts",
|
||||||
"is_input": null,
|
"is_input": null,
|
||||||
"is_output": null,
|
"is_output": null,
|
||||||
"is_composition": null,
|
"is_composition": null,
|
||||||
|
|
@ -1126,7 +1126,7 @@
|
||||||
"y": 143.9251365088694,
|
"y": 143.9251365088694,
|
||||||
"zoom": 0.5282102678500032
|
"zoom": 0.5282102678500032
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "Use a language model to generate text based on a prompt. \n\nIn this project, you'll be able to generate text based on a request and some topics.\n\nThe Topic 1 and Topic 2 components are actually Text Input, while the Prompt Output component is a Text Output. Changing the name of the component makes them easier to identify when interacting with them.",
|
"description": "Use a language model to generate text based on a prompt. \n\nIn this project, you'll be able to generate text based on a request and some topics.\n\nThe Topic 1 and Topic 2 components are actually Text Input, while the Prompt Output component is a Text Output. Changing the name of the component makes them easier to identify when interacting with them.",
|
||||||
"name": "Basic Prompting",
|
"name": "Basic Prompting",
|
||||||
"last_tested_version": "1.0.0a0",
|
"last_tested_version": "1.0.0a0",
|
||||||
|
|
|
||||||
|
|
@ -116,10 +116,13 @@ export default function IOModal({
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSelectedViewField(startView());
|
if(selectedTab!==2) setSelectedTab(inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0);
|
||||||
setSelectedTab(inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0);
|
|
||||||
}, [allNodes]);
|
}, [allNodes]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setSelectedViewField(startView());
|
||||||
|
},[open])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseModal
|
<BaseModal
|
||||||
size={selectedTab === 0 ? "large-thin" : "large"}
|
size={selectedTab === 0 ? "large-thin" : "large"}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue