refactor: Remove PromptComponent and update langflow components to use Prompt field type
This commit is contained in:
parent
c40188f6b6
commit
c3e2ad670e
9 changed files with 598 additions and 225 deletions
|
|
@ -1,38 +0,0 @@
|
||||||
from langflow.custom import Component
|
|
||||||
from langflow.field_typing import Input, Output
|
|
||||||
from langflow.field_typing.prompt import Prompt
|
|
||||||
from langflow.schema.record import Record
|
|
||||||
|
|
||||||
|
|
||||||
class PromptComponent(Component):
|
|
||||||
display_name: str = "Prompt"
|
|
||||||
description: str = "Create a prompt template with dynamic variables."
|
|
||||||
icon = "prompts"
|
|
||||||
|
|
||||||
def build_config(self):
|
|
||||||
return {
|
|
||||||
"template": Input(display_name="Template"),
|
|
||||||
}
|
|
||||||
|
|
||||||
inputs = [
|
|
||||||
Input(name="template", field_type=Prompt, display_name="Template"),
|
|
||||||
]
|
|
||||||
|
|
||||||
outputs = [
|
|
||||||
Output(display_name="Prompt", name="prompt", method="build_prompt"),
|
|
||||||
Output(display_name="Text", name="text", method="format_prompt"),
|
|
||||||
]
|
|
||||||
|
|
||||||
async def format_prompt(self) -> str:
|
|
||||||
prompt = await self.build_prompt()
|
|
||||||
formatted_text = prompt.format_text()
|
|
||||||
self.status = formatted_text
|
|
||||||
return formatted_text
|
|
||||||
|
|
||||||
async def build_prompt(
|
|
||||||
self,
|
|
||||||
) -> Prompt:
|
|
||||||
kwargs = {k: v for k, v in self._arguments.items() if k != "template"}
|
|
||||||
prompt = await Prompt.from_template_and_variables(self.template, kwargs)
|
|
||||||
self.status = [Record.from_lc_message(message) for message in prompt.messages]
|
|
||||||
return prompt
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
from .ChatInput import ChatInput
|
from .ChatInput import ChatInput
|
||||||
from .Prompt import PromptComponent
|
|
||||||
from .TextInput import TextInput
|
from .TextInput import TextInput
|
||||||
|
|
||||||
__all__ = ["ChatInput", "PromptComponent", "TextInput"]
|
__all__ = ["ChatInput", "TextInput"]
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,37 @@
|
||||||
from langflow.custom import CustomComponent
|
from langflow.custom import Component
|
||||||
from langflow.field_typing import TemplateField
|
from langflow.field_typing import Input, Output
|
||||||
from langflow.field_typing.prompt import Prompt
|
from langflow.field_typing.prompt import Prompt
|
||||||
|
|
||||||
|
|
||||||
class PromptComponent(CustomComponent):
|
class PromptComponent(Component):
|
||||||
display_name: str = "Empty Prompt"
|
display_name: str = "Prompt"
|
||||||
description: str = "Create a prompt template with dynamic variables."
|
description: str = "Create a prompt template with dynamic variables."
|
||||||
icon = "prompts"
|
icon = "prompts"
|
||||||
|
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
return {
|
return {
|
||||||
"template": TemplateField(display_name="Template"),
|
"template": Input(display_name="Template"),
|
||||||
"code": TemplateField(advanced=True),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async def build(
|
inputs = [
|
||||||
|
Input(name="template", type=Prompt, display_name="Template"),
|
||||||
|
]
|
||||||
|
|
||||||
|
outputs = [
|
||||||
|
Output(display_name="Prompt", name="prompt", method="build_prompt"),
|
||||||
|
Output(display_name="Text", name="text", method="format_prompt"),
|
||||||
|
]
|
||||||
|
|
||||||
|
async def format_prompt(self) -> str:
|
||||||
|
prompt = await self.build_prompt()
|
||||||
|
formatted_text = prompt.format_text()
|
||||||
|
self.status = formatted_text
|
||||||
|
return formatted_text
|
||||||
|
|
||||||
|
async def build_prompt(
|
||||||
self,
|
self,
|
||||||
template: Prompt,
|
|
||||||
**kwargs,
|
|
||||||
) -> Prompt:
|
) -> Prompt:
|
||||||
prompt = await Prompt.from_template_and_variables(template, kwargs) # type: ignore
|
kwargs = {k: v for k, v in self._arguments.items() if k != "template"}
|
||||||
|
prompt = await Prompt.from_template_and_variables(self.template, kwargs)
|
||||||
self.status = prompt.format_text()
|
self.status = prompt.format_text()
|
||||||
return prompt
|
return prompt
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"type": "code",
|
"type": "code",
|
||||||
"value": "from langflow.custom import Component\nfrom langflow.field_typing import Input, Output\nfrom langflow.field_typing.prompt import Prompt\nfrom langflow.schema.record import Record\n\n\nclass PromptComponent(Component):\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\": Input(display_name=\"Template\"),\n }\n\n inputs = [\n Input(name=\"template\", field_type=Prompt, display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n Output(display_name=\"Text\", name=\"text\", method=\"format_prompt\"),\n ]\n\n async def format_prompt(self) -> str:\n prompt = await self.build_prompt()\n formatted_text = prompt.format_text()\n self.status = formatted_text\n return formatted_text\n\n async def build_prompt(\n self,\n ) -> Prompt:\n kwargs = {k: v for k, v in self._arguments.items() if k != \"template\"}\n prompt = await Prompt.from_template_and_variables(self.template, kwargs)\n self.status = [Record.from_lc_message(message) for message in prompt.messages]\n return prompt\n"
|
"value": "from langflow.custom import Component\nfrom langflow.field_typing import Input, Output\nfrom langflow.field_typing.prompt import Prompt\n\n\nclass PromptComponent(Component):\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\": Input(display_name=\"Template\"),\n }\n\n inputs = [\n Input(name=\"template\", type=Prompt, display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n Output(display_name=\"Text\", name=\"text\", method=\"format_prompt\"),\n ]\n\n async def format_prompt(self) -> str:\n prompt = await self.build_prompt()\n formatted_text = prompt.format_text()\n self.status = formatted_text\n return formatted_text\n\n async def build_prompt(\n self,\n ) -> Prompt:\n kwargs = {k: v for k, v in self._arguments.items() if k != \"template\"}\n prompt = await Prompt.from_template_and_variables(self.template, kwargs)\n self.status = prompt.format_text()\n return prompt\n"
|
||||||
},
|
},
|
||||||
"template": {
|
"template": {
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,19 @@
|
||||||
"dataType": "URL",
|
"dataType": "URL",
|
||||||
"id": "URL-HYPkR",
|
"id": "URL-HYPkR",
|
||||||
"name": "record",
|
"name": "record",
|
||||||
"output_types": ["Record"]
|
"output_types": [
|
||||||
|
"Record"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "reference_2",
|
"fieldName": "reference_2",
|
||||||
"id": "Prompt-Rse03",
|
"id": "Prompt-Rse03",
|
||||||
"inputTypes": ["Document", "BaseOutputParser", "Record", "Text"],
|
"inputTypes": [
|
||||||
|
"Document",
|
||||||
|
"BaseOutputParser",
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -34,12 +41,16 @@
|
||||||
"dataType": "OpenAIModel",
|
"dataType": "OpenAIModel",
|
||||||
"id": "OpenAIModel-gi29P",
|
"id": "OpenAIModel-gi29P",
|
||||||
"name": "text",
|
"name": "text",
|
||||||
"output_types": ["Text"]
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "ChatOutput-JPlxl",
|
"id": "ChatOutput-JPlxl",
|
||||||
"inputTypes": ["Text"],
|
"inputTypes": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -59,12 +70,19 @@
|
||||||
"dataType": "URL",
|
"dataType": "URL",
|
||||||
"id": "URL-2cX90",
|
"id": "URL-2cX90",
|
||||||
"name": "record",
|
"name": "record",
|
||||||
"output_types": ["Record"]
|
"output_types": [
|
||||||
|
"Record"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "reference_1",
|
"fieldName": "reference_1",
|
||||||
"id": "Prompt-Rse03",
|
"id": "Prompt-Rse03",
|
||||||
"inputTypes": ["Document", "BaseOutputParser", "Record", "Text"],
|
"inputTypes": [
|
||||||
|
"Document",
|
||||||
|
"BaseOutputParser",
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -84,12 +102,19 @@
|
||||||
"dataType": "TextInput",
|
"dataType": "TextInput",
|
||||||
"id": "TextInput-og8Or",
|
"id": "TextInput-og8Or",
|
||||||
"name": "Text",
|
"name": "Text",
|
||||||
"output_types": ["Text"]
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "instructions",
|
"fieldName": "instructions",
|
||||||
"id": "Prompt-Rse03",
|
"id": "Prompt-Rse03",
|
||||||
"inputTypes": ["Document", "BaseOutputParser", "Record", "Text"],
|
"inputTypes": [
|
||||||
|
"Document",
|
||||||
|
"BaseOutputParser",
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -109,12 +134,18 @@
|
||||||
"dataType": "Prompt",
|
"dataType": "Prompt",
|
||||||
"id": "Prompt-Rse03",
|
"id": "Prompt-Rse03",
|
||||||
"name": "prompt",
|
"name": "prompt",
|
||||||
"output_types": ["Prompt"]
|
"output_types": [
|
||||||
|
"Prompt"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "OpenAIModel-gi29P",
|
"id": "OpenAIModel-gi29P",
|
||||||
"inputTypes": ["Text", "Record", "Prompt"],
|
"inputTypes": [
|
||||||
|
"Text",
|
||||||
|
"Record",
|
||||||
|
"Prompt"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -136,10 +167,18 @@
|
||||||
"display_name": "Prompt",
|
"display_name": "Prompt",
|
||||||
"id": "Prompt-Rse03",
|
"id": "Prompt-Rse03",
|
||||||
"node": {
|
"node": {
|
||||||
"base_classes": ["object", "Text", "str"],
|
"base_classes": [
|
||||||
|
"object",
|
||||||
|
"Text",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"beta": false,
|
"beta": false,
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"template": ["reference_1", "reference_2", "instructions"]
|
"template": [
|
||||||
|
"reference_1",
|
||||||
|
"reference_2",
|
||||||
|
"instructions"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"description": "Create a prompt template with dynamic variables.",
|
"description": "Create a prompt template with dynamic variables.",
|
||||||
"display_name": "Prompt",
|
"display_name": "Prompt",
|
||||||
|
|
@ -162,7 +201,9 @@
|
||||||
"method": "build_prompt",
|
"method": "build_prompt",
|
||||||
"name": "prompt",
|
"name": "prompt",
|
||||||
"selected": "Prompt",
|
"selected": "Prompt",
|
||||||
"types": ["Prompt"],
|
"types": [
|
||||||
|
"Prompt"
|
||||||
|
],
|
||||||
"value": "__UNDEFINED__"
|
"value": "__UNDEFINED__"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -171,7 +212,9 @@
|
||||||
"method": "format_prompt",
|
"method": "format_prompt",
|
||||||
"name": "text",
|
"name": "text",
|
||||||
"selected": "Text",
|
"selected": "Text",
|
||||||
"types": ["Text"],
|
"types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"value": "__UNDEFINED__"
|
"value": "__UNDEFINED__"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -193,7 +236,7 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"type": "code",
|
"type": "code",
|
||||||
"value": "from langflow.custom import Component\nfrom langflow.field_typing import Input, Output\nfrom langflow.field_typing.prompt import Prompt\nfrom langflow.schema.record import Record\n\n\nclass PromptComponent(Component):\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\": Input(display_name=\"Template\"),\n }\n\n inputs = [\n Input(name=\"template\", field_type=Prompt, display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n Output(display_name=\"Text\", name=\"text\", method=\"format_prompt\"),\n ]\n\n async def format_prompt(self) -> str:\n prompt = await self.build_prompt()\n formatted_text = prompt.format_text()\n self.status = formatted_text\n return formatted_text\n\n async def build_prompt(\n self,\n ) -> Prompt:\n kwargs = {k: v for k, v in self._arguments.items() if k != \"template\"}\n prompt = await Prompt.from_template_and_variables(self.template, kwargs)\n self.status = [Record.from_lc_message(message) for message in prompt.messages]\n return prompt\n"
|
"value": "from langflow.custom import Component\nfrom langflow.field_typing import Input, Output\nfrom langflow.field_typing.prompt import Prompt\n\n\nclass PromptComponent(Component):\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\": Input(display_name=\"Template\"),\n }\n\n inputs = [\n Input(name=\"template\", type=Prompt, display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n Output(display_name=\"Text\", name=\"text\", method=\"format_prompt\"),\n ]\n\n async def format_prompt(self) -> str:\n prompt = await self.build_prompt()\n formatted_text = prompt.format_text()\n self.status = formatted_text\n return formatted_text\n\n async def build_prompt(\n self,\n ) -> Prompt:\n kwargs = {k: v for k, v in self._arguments.items() if k != \"template\"}\n prompt = await Prompt.from_template_and_variables(self.template, kwargs)\n self.status = prompt.format_text()\n return prompt\n"
|
||||||
},
|
},
|
||||||
"instructions": {
|
"instructions": {
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
|
|
@ -280,7 +323,9 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"info": "",
|
"info": "",
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"list": false,
|
"list": false,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": false,
|
"multiline": false,
|
||||||
|
|
@ -316,7 +361,9 @@
|
||||||
"data": {
|
"data": {
|
||||||
"id": "URL-HYPkR",
|
"id": "URL-HYPkR",
|
||||||
"node": {
|
"node": {
|
||||||
"base_classes": ["Record"],
|
"base_classes": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"beta": false,
|
"beta": false,
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"urls": null
|
"urls": null
|
||||||
|
|
@ -328,7 +375,9 @@
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"icon": "layout-template",
|
"icon": "layout-template",
|
||||||
"output_types": ["Record"],
|
"output_types": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"cache": true,
|
"cache": true,
|
||||||
|
|
@ -336,7 +385,9 @@
|
||||||
"method": null,
|
"method": null,
|
||||||
"name": "record",
|
"name": "record",
|
||||||
"selected": "Record",
|
"selected": "Record",
|
||||||
"types": ["Record"],
|
"types": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"value": "__UNDEFINED__"
|
"value": "__UNDEFINED__"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -367,7 +418,9 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"info": "",
|
"info": "",
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"list": true,
|
"list": true,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": false,
|
"multiline": false,
|
||||||
|
|
@ -405,7 +458,12 @@
|
||||||
"data": {
|
"data": {
|
||||||
"id": "ChatOutput-JPlxl",
|
"id": "ChatOutput-JPlxl",
|
||||||
"node": {
|
"node": {
|
||||||
"base_classes": ["Text", "Record", "object", "str"],
|
"base_classes": [
|
||||||
|
"Text",
|
||||||
|
"Record",
|
||||||
|
"object",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"beta": false,
|
"beta": false,
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"input_value": null,
|
"input_value": null,
|
||||||
|
|
@ -430,7 +488,9 @@
|
||||||
"method": "text_response",
|
"method": "text_response",
|
||||||
"name": "text",
|
"name": "text",
|
||||||
"selected": "Text",
|
"selected": "Text",
|
||||||
"types": ["Text"],
|
"types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"value": "__UNDEFINED__"
|
"value": "__UNDEFINED__"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -439,7 +499,9 @@
|
||||||
"method": "message_response",
|
"method": "message_response",
|
||||||
"name": "message",
|
"name": "message",
|
||||||
"selected": "Message",
|
"selected": "Message",
|
||||||
"types": ["Message"],
|
"types": [
|
||||||
|
"Message"
|
||||||
|
],
|
||||||
"value": "__UNDEFINED__"
|
"value": "__UNDEFINED__"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -470,7 +532,9 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"info": "Message to be passed as output.",
|
"info": "Message to be passed as output.",
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"list": false,
|
"list": false,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": true,
|
"multiline": true,
|
||||||
|
|
@ -490,7 +554,9 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"info": "Template to convert Record to Text. If left empty, it will be dynamically set to the Record's text key.",
|
"info": "Template to convert Record to Text. If left empty, it will be dynamically set to the Record's text key.",
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"list": false,
|
"list": false,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": false,
|
"multiline": false,
|
||||||
|
|
@ -510,12 +576,17 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"info": "Type of sender.",
|
"info": "Type of sender.",
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"list": true,
|
"list": true,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": false,
|
"multiline": false,
|
||||||
"name": "sender",
|
"name": "sender",
|
||||||
"options": ["Machine", "User"],
|
"options": [
|
||||||
|
"Machine",
|
||||||
|
"User"
|
||||||
|
],
|
||||||
"password": false,
|
"password": false,
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"required": false,
|
"required": false,
|
||||||
|
|
@ -531,7 +602,9 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"info": "Name of the sender.",
|
"info": "Name of the sender.",
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"list": false,
|
"list": false,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": false,
|
"multiline": false,
|
||||||
|
|
@ -551,7 +624,9 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"info": "Session ID for the message.",
|
"info": "Session ID for the message.",
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"list": false,
|
"list": false,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": false,
|
"multiline": false,
|
||||||
|
|
@ -582,7 +657,11 @@
|
||||||
"data": {
|
"data": {
|
||||||
"id": "OpenAIModel-gi29P",
|
"id": "OpenAIModel-gi29P",
|
||||||
"node": {
|
"node": {
|
||||||
"base_classes": ["str", "Text", "object"],
|
"base_classes": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"beta": false,
|
"beta": false,
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"input_value": null,
|
"input_value": null,
|
||||||
|
|
@ -612,7 +691,9 @@
|
||||||
],
|
],
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"icon": "OpenAI",
|
"icon": "OpenAI",
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"cache": true,
|
"cache": true,
|
||||||
|
|
@ -620,7 +701,9 @@
|
||||||
"method": null,
|
"method": null,
|
||||||
"name": "text",
|
"name": "text",
|
||||||
"selected": "Text",
|
"selected": "Text",
|
||||||
"types": ["Text"],
|
"types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"value": "__UNDEFINED__"
|
"value": "__UNDEFINED__"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -651,7 +734,11 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"info": "",
|
"info": "",
|
||||||
"input_types": ["Text", "Record", "Prompt"],
|
"input_types": [
|
||||||
|
"Text",
|
||||||
|
"Record",
|
||||||
|
"Prompt"
|
||||||
|
],
|
||||||
"list": false,
|
"list": false,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": false,
|
"multiline": false,
|
||||||
|
|
@ -708,7 +795,9 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"info": "",
|
"info": "",
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"list": true,
|
"list": true,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": false,
|
"multiline": false,
|
||||||
|
|
@ -735,7 +824,9 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"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.",
|
"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.",
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"list": false,
|
"list": false,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": false,
|
"multiline": false,
|
||||||
|
|
@ -754,7 +845,9 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"info": "The OpenAI API Key to use for the OpenAI model.",
|
"info": "The OpenAI API Key to use for the OpenAI model.",
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"list": false,
|
"list": false,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": false,
|
"multiline": false,
|
||||||
|
|
@ -793,7 +886,9 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"info": "System message to pass to the model.",
|
"info": "System message to pass to the model.",
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"list": false,
|
"list": false,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": false,
|
"multiline": false,
|
||||||
|
|
@ -853,7 +948,9 @@
|
||||||
"data": {
|
"data": {
|
||||||
"id": "URL-2cX90",
|
"id": "URL-2cX90",
|
||||||
"node": {
|
"node": {
|
||||||
"base_classes": ["Record"],
|
"base_classes": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"beta": false,
|
"beta": false,
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"urls": null
|
"urls": null
|
||||||
|
|
@ -865,7 +962,9 @@
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"icon": "layout-template",
|
"icon": "layout-template",
|
||||||
"output_types": ["Record"],
|
"output_types": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"cache": true,
|
"cache": true,
|
||||||
|
|
@ -873,7 +972,9 @@
|
||||||
"method": null,
|
"method": null,
|
||||||
"name": "record",
|
"name": "record",
|
||||||
"selected": "Record",
|
"selected": "Record",
|
||||||
"types": ["Record"],
|
"types": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"value": "__UNDEFINED__"
|
"value": "__UNDEFINED__"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -904,7 +1005,9 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"info": "",
|
"info": "",
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"list": true,
|
"list": true,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": false,
|
"multiline": false,
|
||||||
|
|
@ -915,7 +1018,9 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"type": "str",
|
"type": "str",
|
||||||
"value": ["https://www.promptingguide.ai/introduction/basics"]
|
"value": [
|
||||||
|
"https://www.promptingguide.ai/introduction/basics"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -940,7 +1045,11 @@
|
||||||
"data": {
|
"data": {
|
||||||
"id": "TextInput-og8Or",
|
"id": "TextInput-og8Or",
|
||||||
"node": {
|
"node": {
|
||||||
"base_classes": ["object", "Text", "str"],
|
"base_classes": [
|
||||||
|
"object",
|
||||||
|
"Text",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"beta": false,
|
"beta": false,
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"input_value": null,
|
"input_value": null,
|
||||||
|
|
@ -953,12 +1062,16 @@
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"icon": "type",
|
"icon": "type",
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"name": "Text",
|
"name": "Text",
|
||||||
"selected": "Text",
|
"selected": "Text",
|
||||||
"types": ["Text"]
|
"types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"template": {
|
"template": {
|
||||||
|
|
@ -988,7 +1101,10 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"info": "Text or Record to be passed as input.",
|
"info": "Text or Record to be passed as input.",
|
||||||
"input_types": ["Record", "Text"],
|
"input_types": [
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"list": false,
|
"list": false,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": false,
|
"multiline": false,
|
||||||
|
|
@ -1008,7 +1124,9 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"info": "Template to convert Record to Text. If left empty, it will be dynamically set to the Record's text key.",
|
"info": "Template to convert Record to Text. If left empty, it will be dynamically set to the Record's text key.",
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"list": false,
|
"list": false,
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"multiline": true,
|
"multiline": true,
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"type": "code",
|
"type": "code",
|
||||||
"value": "from langflow.custom import Component\nfrom langflow.field_typing import Input, Output\nfrom langflow.field_typing.prompt import Prompt\nfrom langflow.schema.record import Record\n\n\nclass PromptComponent(Component):\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\": Input(display_name=\"Template\"),\n }\n\n inputs = [\n Input(name=\"template\", field_type=Prompt, display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n Output(display_name=\"Text\", name=\"text\", method=\"format_prompt\"),\n ]\n\n async def format_prompt(self) -> str:\n prompt = await self.build_prompt()\n formatted_text = prompt.format_text()\n self.status = formatted_text\n return formatted_text\n\n async def build_prompt(\n self,\n ) -> Prompt:\n kwargs = {k: v for k, v in self._arguments.items() if k != \"template\"}\n prompt = await Prompt.from_template_and_variables(self.template, kwargs)\n self.status = [Record.from_lc_message(message) for message in prompt.messages]\n return prompt\n"
|
"value": "from langflow.custom import Component\nfrom langflow.field_typing import Input, Output\nfrom langflow.field_typing.prompt import Prompt\n\n\nclass PromptComponent(Component):\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\": Input(display_name=\"Template\"),\n }\n\n inputs = [\n Input(name=\"template\", type=Prompt, display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n Output(display_name=\"Text\", name=\"text\", method=\"format_prompt\"),\n ]\n\n async def format_prompt(self) -> str:\n prompt = await self.build_prompt()\n formatted_text = prompt.format_text()\n self.status = formatted_text\n return formatted_text\n\n async def build_prompt(\n self,\n ) -> Prompt:\n kwargs = {k: v for k, v in self._arguments.items() if k != \"template\"}\n prompt = await Prompt.from_template_and_variables(self.template, kwargs)\n self.status = prompt.format_text()\n return prompt\n"
|
||||||
},
|
},
|
||||||
"template": {
|
"template": {
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
|
|
|
||||||
|
|
@ -834,7 +834,7 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"type": "code",
|
"type": "code",
|
||||||
"value": "from langflow.custom import Component\nfrom langflow.field_typing import Input, Output\nfrom langflow.field_typing.prompt import Prompt\nfrom langflow.schema.record import Record\n\n\nclass PromptComponent(Component):\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\": Input(display_name=\"Template\"),\n }\n\n inputs = [\n Input(name=\"template\", field_type=Prompt, display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n Output(display_name=\"Text\", name=\"text\", method=\"format_prompt\"),\n ]\n\n async def format_prompt(self) -> str:\n prompt = await self.build_prompt()\n formatted_text = prompt.format_text()\n self.status = formatted_text\n return formatted_text\n\n async def build_prompt(\n self,\n ) -> Prompt:\n kwargs = {k: v for k, v in self._arguments.items() if k != \"template\"}\n prompt = await Prompt.from_template_and_variables(self.template, kwargs)\n self.status = [Record.from_lc_message(message) for message in prompt.messages]\n return prompt\n"
|
"value": "from langflow.custom import Component\nfrom langflow.field_typing import Input, Output\nfrom langflow.field_typing.prompt import Prompt\n\n\nclass PromptComponent(Component):\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\": Input(display_name=\"Template\"),\n }\n\n inputs = [\n Input(name=\"template\", type=Prompt, display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n Output(display_name=\"Text\", name=\"text\", method=\"format_prompt\"),\n ]\n\n async def format_prompt(self) -> str:\n prompt = await self.build_prompt()\n formatted_text = prompt.format_text()\n self.status = formatted_text\n return formatted_text\n\n async def build_prompt(\n self,\n ) -> Prompt:\n kwargs = {k: v for k, v in self._arguments.items() if k != \"template\"}\n prompt = await Prompt.from_template_and_variables(self.template, kwargs)\n self.status = prompt.format_text()\n return prompt\n"
|
||||||
},
|
},
|
||||||
"context": {
|
"context": {
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
|
|
|
||||||
|
|
@ -320,7 +320,7 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"type": "code",
|
"type": "code",
|
||||||
"value": "from langflow.custom import Component\nfrom langflow.field_typing import Input, Output\nfrom langflow.field_typing.prompt import Prompt\nfrom langflow.schema.record import Record\n\n\nclass PromptComponent(Component):\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\": Input(display_name=\"Template\"),\n }\n\n inputs = [\n Input(name=\"template\", field_type=Prompt, display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n Output(display_name=\"Text\", name=\"text\", method=\"format_prompt\"),\n ]\n\n async def format_prompt(self) -> str:\n prompt = await self.build_prompt()\n formatted_text = prompt.format_text()\n self.status = formatted_text\n return formatted_text\n\n async def build_prompt(\n self,\n ) -> Prompt:\n kwargs = {k: v for k, v in self._arguments.items() if k != \"template\"}\n prompt = await Prompt.from_template_and_variables(self.template, kwargs)\n self.status = [Record.from_lc_message(message) for message in prompt.messages]\n return prompt\n"
|
"value": "from langflow.custom import Component\nfrom langflow.field_typing import Input, Output\nfrom langflow.field_typing.prompt import Prompt\n\n\nclass PromptComponent(Component):\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\": Input(display_name=\"Template\"),\n }\n\n inputs = [\n Input(name=\"template\", type=Prompt, display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n Output(display_name=\"Text\", name=\"text\", method=\"format_prompt\"),\n ]\n\n async def format_prompt(self) -> str:\n prompt = await self.build_prompt()\n formatted_text = prompt.format_text()\n self.status = formatted_text\n return formatted_text\n\n async def build_prompt(\n self,\n ) -> Prompt:\n kwargs = {k: v for k, v in self._arguments.items() if k != \"template\"}\n prompt = await Prompt.from_template_and_variables(self.template, kwargs)\n self.status = prompt.format_text()\n return prompt\n"
|
||||||
},
|
},
|
||||||
"document": {
|
"document": {
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
|
|
@ -462,7 +462,7 @@
|
||||||
"show": true,
|
"show": true,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"type": "code",
|
"type": "code",
|
||||||
"value": "from langflow.custom import Component\nfrom langflow.field_typing import Input, Output\nfrom langflow.field_typing.prompt import Prompt\nfrom langflow.schema.record import Record\n\n\nclass PromptComponent(Component):\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\": Input(display_name=\"Template\"),\n }\n\n inputs = [\n Input(name=\"template\", field_type=Prompt, display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n Output(display_name=\"Text\", name=\"text\", method=\"format_prompt\"),\n ]\n\n async def format_prompt(self) -> str:\n prompt = await self.build_prompt()\n formatted_text = prompt.format_text()\n self.status = formatted_text\n return formatted_text\n\n async def build_prompt(\n self,\n ) -> Prompt:\n kwargs = {k: v for k, v in self._arguments.items() if k != \"template\"}\n prompt = await Prompt.from_template_and_variables(self.template, kwargs)\n self.status = [Record.from_lc_message(message) for message in prompt.messages]\n return prompt\n"
|
"value": "from langflow.custom import Component\nfrom langflow.field_typing import Input, Output\nfrom langflow.field_typing.prompt import Prompt\n\n\nclass PromptComponent(Component):\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\": Input(display_name=\"Template\"),\n }\n\n inputs = [\n Input(name=\"template\", type=Prompt, display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt\", name=\"prompt\", method=\"build_prompt\"),\n Output(display_name=\"Text\", name=\"text\", method=\"format_prompt\"),\n ]\n\n async def format_prompt(self) -> str:\n prompt = await self.build_prompt()\n formatted_text = prompt.format_text()\n self.status = formatted_text\n return formatted_text\n\n async def build_prompt(\n self,\n ) -> Prompt:\n kwargs = {k: v for k, v in self._arguments.items() if k != \"template\"}\n prompt = await Prompt.from_template_and_variables(self.template, kwargs)\n self.status = prompt.format_text()\n return prompt\n"
|
||||||
},
|
},
|
||||||
"summary": {
|
"summary": {
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue