Fixed starter examples
This commit is contained in:
parent
d0e84c1dc8
commit
4cc7ae1f2a
3 changed files with 2 additions and 1994 deletions
|
|
@ -1,875 +0,0 @@
|
|||
{
|
||||
"data": {
|
||||
"edges": [
|
||||
{
|
||||
"className": "",
|
||||
"data": {
|
||||
"sourceHandle": {
|
||||
"dataType": "ChatInput",
|
||||
"id": "ChatInput-8QeBH",
|
||||
"name": "message",
|
||||
"output_types": [
|
||||
"Message"
|
||||
]
|
||||
},
|
||||
"targetHandle": {
|
||||
"fieldName": "user_input",
|
||||
"id": "Prompt-GAmYb",
|
||||
"inputTypes": [
|
||||
"Message",
|
||||
"Text"
|
||||
],
|
||||
"type": "str"
|
||||
}
|
||||
},
|
||||
"id": "reactflow__edge-ChatInput-8QeBH{œdataTypeœ:œChatInputœ,œidœ:œChatInput-8QeBHœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt-GAmYb{œfieldNameœ:œuser_inputœ,œidœ:œPrompt-GAmYbœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}",
|
||||
"source": "ChatInput-8QeBH",
|
||||
"sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-8QeBHœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}",
|
||||
"target": "Prompt-GAmYb",
|
||||
"targetHandle": "{œfieldNameœ: œuser_inputœ, œidœ: œPrompt-GAmYbœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}"
|
||||
},
|
||||
{
|
||||
"className": "",
|
||||
"data": {
|
||||
"sourceHandle": {
|
||||
"dataType": "Prompt",
|
||||
"id": "Prompt-GAmYb",
|
||||
"name": "prompt",
|
||||
"output_types": [
|
||||
"Message"
|
||||
]
|
||||
},
|
||||
"targetHandle": {
|
||||
"fieldName": "input_value",
|
||||
"id": "OpenAIModel-aN26e",
|
||||
"inputTypes": [
|
||||
"Message"
|
||||
],
|
||||
"type": "str"
|
||||
}
|
||||
},
|
||||
"id": "reactflow__edge-Prompt-GAmYb{œdataTypeœ:œPromptœ,œidœ:œPrompt-GAmYbœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-aN26e{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-aN26eœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
|
||||
"source": "Prompt-GAmYb",
|
||||
"sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-GAmYbœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}",
|
||||
"target": "OpenAIModel-aN26e",
|
||||
"targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-aN26eœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
|
||||
},
|
||||
{
|
||||
"className": "",
|
||||
"data": {
|
||||
"sourceHandle": {
|
||||
"dataType": "OpenAIModel",
|
||||
"id": "OpenAIModel-aN26e",
|
||||
"name": "text_output",
|
||||
"output_types": [
|
||||
"Message"
|
||||
]
|
||||
},
|
||||
"targetHandle": {
|
||||
"fieldName": "input_value",
|
||||
"id": "ChatOutput-wokdr",
|
||||
"inputTypes": [
|
||||
"Message"
|
||||
],
|
||||
"type": "str"
|
||||
}
|
||||
},
|
||||
"id": "reactflow__edge-OpenAIModel-aN26e{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-aN26eœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-wokdr{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-wokdrœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
|
||||
"source": "OpenAIModel-aN26e",
|
||||
"sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-aN26eœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}",
|
||||
"target": "ChatOutput-wokdr",
|
||||
"targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-wokdrœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"data": {
|
||||
"description": "Create a prompt template with dynamic variables.",
|
||||
"display_name": "Prompt",
|
||||
"edited": false,
|
||||
"id": "Prompt-GAmYb",
|
||||
"node": {
|
||||
"base_classes": [
|
||||
"Message"
|
||||
],
|
||||
"beta": false,
|
||||
"conditional_paths": [],
|
||||
"custom_fields": {
|
||||
"template": [
|
||||
"user_input"
|
||||
]
|
||||
},
|
||||
"description": "Create a prompt template with dynamic variables.",
|
||||
"display_name": "Prompt",
|
||||
"documentation": "",
|
||||
"edited": true,
|
||||
"field_order": [
|
||||
"template"
|
||||
],
|
||||
"frozen": false,
|
||||
"icon": "prompts",
|
||||
"output_types": [],
|
||||
"outputs": [
|
||||
{
|
||||
"cache": true,
|
||||
"display_name": "Prompt Message",
|
||||
"hidden": false,
|
||||
"method": "build_prompt",
|
||||
"name": "prompt",
|
||||
"selected": "Message",
|
||||
"types": [
|
||||
"Message"
|
||||
],
|
||||
"value": "__UNDEFINED__"
|
||||
}
|
||||
],
|
||||
"pinned": false,
|
||||
"template": {
|
||||
"_type": "Component",
|
||||
"code": {
|
||||
"advanced": true,
|
||||
"dynamic": true,
|
||||
"fileTypes": [],
|
||||
"file_path": "",
|
||||
"info": "",
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"multiline": true,
|
||||
"name": "code",
|
||||
"password": false,
|
||||
"placeholder": "",
|
||||
"required": true,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"type": "code",
|
||||
"value": "from langflow.base.prompts.api_utils import process_prompt_template\nfrom langflow.custom import Component\nfrom langflow.io import Output, PromptInput\nfrom langflow.schema.message import Message\nfrom langflow.template.utils import update_template_values\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt\"\n description: str = \"Create a prompt template with dynamic variables.\"\n icon = \"prompts\"\n trace_type = \"prompt\"\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt Message\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n async def build_prompt(\n self,\n ) -> Message:\n prompt = await Message.from_template_and_variables(**self._attributes)\n self.status = prompt.text\n return prompt\n\n def post_code_processing(self, new_build_config: dict, current_build_config: dict):\n \"\"\"\n This function is called after the code validation is done.\n \"\"\"\n frontend_node = super().post_code_processing(new_build_config, current_build_config)\n template = frontend_node[\"template\"][\"template\"][\"value\"]\n _ = process_prompt_template(\n template=template,\n name=\"template\",\n custom_fields=frontend_node[\"custom_fields\"],\n frontend_node_template=frontend_node[\"template\"],\n )\n # Now that template is updated, we need to grab any values that were set in the current_build_config\n # and update the frontend_node with those values\n update_template_values(frontend_template=frontend_node, raw_template=current_build_config[\"template\"])\n return frontend_node\n"
|
||||
},
|
||||
"template": {
|
||||
"advanced": false,
|
||||
"display_name": "Template",
|
||||
"dynamic": false,
|
||||
"info": "",
|
||||
"list": false,
|
||||
"name": "template",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_input": true,
|
||||
"type": "prompt",
|
||||
"value": "Answer the user as if you were a pirate.\n\nUser: {user_input}\n\nAnswer: "
|
||||
},
|
||||
"user_input": {
|
||||
"advanced": false,
|
||||
"display_name": "user_input",
|
||||
"dynamic": false,
|
||||
"field_type": "str",
|
||||
"fileTypes": [],
|
||||
"file_path": "",
|
||||
"info": "",
|
||||
"input_types": [
|
||||
"Message",
|
||||
"Text"
|
||||
],
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"multiline": true,
|
||||
"name": "user_input",
|
||||
"password": false,
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"type": "str",
|
||||
"value": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": "Prompt"
|
||||
},
|
||||
"dragging": false,
|
||||
"height": 422,
|
||||
"id": "Prompt-GAmYb",
|
||||
"position": {
|
||||
"x": 43.70859256635981,
|
||||
"y": 1115.5304359666682
|
||||
},
|
||||
"positionAbsolute": {
|
||||
"x": 43.70859256635981,
|
||||
"y": 1115.5304359666682
|
||||
},
|
||||
"selected": false,
|
||||
"type": "genericNode",
|
||||
"width": 384
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"description": "Get chat inputs from the Playground.",
|
||||
"display_name": "Chat Input",
|
||||
"edited": false,
|
||||
"id": "ChatInput-8QeBH",
|
||||
"node": {
|
||||
"base_classes": [
|
||||
"Message"
|
||||
],
|
||||
"beta": false,
|
||||
"conditional_paths": [],
|
||||
"custom_fields": {},
|
||||
"description": "Get chat inputs from the Playground.",
|
||||
"display_name": "Chat Input",
|
||||
"documentation": "",
|
||||
"edited": true,
|
||||
"field_order": [
|
||||
"input_value",
|
||||
"sender",
|
||||
"sender_name",
|
||||
"session_id",
|
||||
"files"
|
||||
],
|
||||
"frozen": false,
|
||||
"icon": "ChatInput",
|
||||
"output_types": [],
|
||||
"outputs": [
|
||||
{
|
||||
"cache": true,
|
||||
"display_name": "Message",
|
||||
"hidden": false,
|
||||
"method": "message_response",
|
||||
"name": "message",
|
||||
"selected": "Message",
|
||||
"types": [
|
||||
"Message"
|
||||
],
|
||||
"value": "__UNDEFINED__"
|
||||
}
|
||||
],
|
||||
"pinned": false,
|
||||
"template": {
|
||||
"_type": "Component",
|
||||
"code": {
|
||||
"advanced": true,
|
||||
"dynamic": true,
|
||||
"fileTypes": [],
|
||||
"file_path": "",
|
||||
"info": "",
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"multiline": true,
|
||||
"name": "code",
|
||||
"password": false,
|
||||
"placeholder": "",
|
||||
"required": true,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"type": "code",
|
||||
"value": "from langflow.base.data.utils import IMG_FILE_TYPES, TEXT_FILE_TYPES\nfrom langflow.base.io.chat import ChatComponent\nfrom langflow.io import DropdownInput, FileInput, MultilineInput, Output, TextInput\nfrom langflow.schema.message import Message\n\n\nclass ChatInput(ChatComponent):\n display_name = \"Chat Input\"\n description = \"Get chat inputs from the Playground.\"\n icon = \"ChatInput\"\n\n inputs = [\n MultilineInput(\n name=\"input_value\",\n display_name=\"Text\",\n value=\"\",\n info=\"Message to be passed as input.\",\n ),\n DropdownInput(\n name=\"sender\",\n display_name=\"Sender Type\",\n options=[\"Machine\", \"User\"],\n value=\"User\",\n info=\"Type of sender.\",\n advanced=True,\n ),\n TextInput(\n name=\"sender_name\",\n display_name=\"Sender Name\",\n info=\"Name of the sender.\",\n value=\"User\",\n advanced=True,\n ),\n TextInput(name=\"session_id\", display_name=\"Session ID\", info=\"Session ID for the message.\", advanced=True),\n FileInput(\n name=\"files\",\n display_name=\"Files\",\n file_types=TEXT_FILE_TYPES + IMG_FILE_TYPES,\n info=\"Files to be sent with the message.\",\n advanced=True,\n is_list=True,\n ),\n ]\n outputs = [\n Output(display_name=\"Message\", name=\"message\", method=\"message_response\"),\n ]\n\n def message_response(self) -> Message:\n message = Message(\n text=self.input_value,\n sender=self.sender,\n sender_name=self.sender_name,\n session_id=self.session_id,\n files=self.files,\n )\n if self.session_id and isinstance(message, Message) and isinstance(message.text, str):\n self.store_message(message)\n self.message.value = message\n\n self.status = message\n return message\n"
|
||||
},
|
||||
"files": {
|
||||
"advanced": true,
|
||||
"display_name": "Files",
|
||||
"dynamic": false,
|
||||
"fileTypes": [
|
||||
"txt",
|
||||
"md",
|
||||
"mdx",
|
||||
"csv",
|
||||
"json",
|
||||
"yaml",
|
||||
"yml",
|
||||
"xml",
|
||||
"html",
|
||||
"htm",
|
||||
"pdf",
|
||||
"docx",
|
||||
"py",
|
||||
"sh",
|
||||
"sql",
|
||||
"js",
|
||||
"ts",
|
||||
"tsx",
|
||||
"jpg",
|
||||
"jpeg",
|
||||
"png",
|
||||
"bmp",
|
||||
"image"
|
||||
],
|
||||
"file_path": "",
|
||||
"info": "Files to be sent with the message.",
|
||||
"list": true,
|
||||
"name": "files",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_metadata": true,
|
||||
"type": "file",
|
||||
"value": ""
|
||||
},
|
||||
"input_value": {
|
||||
"advanced": false,
|
||||
"display_name": "Text",
|
||||
"dynamic": false,
|
||||
"info": "Message to be passed as input.",
|
||||
"input_types": [
|
||||
"Message"
|
||||
],
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"multiline": true,
|
||||
"name": "input_value",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_input": true,
|
||||
"trace_as_metadata": true,
|
||||
"type": "str",
|
||||
"value": ""
|
||||
},
|
||||
"sender": {
|
||||
"advanced": true,
|
||||
"display_name": "Sender Type",
|
||||
"dynamic": false,
|
||||
"info": "Type of sender.",
|
||||
"name": "sender",
|
||||
"options": [
|
||||
"Machine",
|
||||
"User"
|
||||
],
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_metadata": true,
|
||||
"type": "str",
|
||||
"value": "User"
|
||||
},
|
||||
"sender_name": {
|
||||
"advanced": true,
|
||||
"display_name": "Sender Name",
|
||||
"dynamic": false,
|
||||
"info": "Name of the sender.",
|
||||
"input_types": [
|
||||
"Message"
|
||||
],
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"name": "sender_name",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_input": true,
|
||||
"trace_as_metadata": true,
|
||||
"type": "str",
|
||||
"value": "User"
|
||||
},
|
||||
"session_id": {
|
||||
"advanced": true,
|
||||
"display_name": "Session ID",
|
||||
"dynamic": false,
|
||||
"info": "Session ID for the message.",
|
||||
"input_types": [
|
||||
"Message"
|
||||
],
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"name": "session_id",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_input": true,
|
||||
"trace_as_metadata": true,
|
||||
"type": "str",
|
||||
"value": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": "ChatInput"
|
||||
},
|
||||
"dragging": false,
|
||||
"height": 308,
|
||||
"id": "ChatInput-8QeBH",
|
||||
"position": {
|
||||
"x": -521.3324537445985,
|
||||
"y": 1089.7620993695407
|
||||
},
|
||||
"positionAbsolute": {
|
||||
"x": -521.3324537445985,
|
||||
"y": 1089.7620993695407
|
||||
},
|
||||
"selected": false,
|
||||
"type": "genericNode",
|
||||
"width": 384
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"description": "Generates text using OpenAI LLMs.",
|
||||
"display_name": "OpenAI",
|
||||
"edited": false,
|
||||
"id": "OpenAIModel-aN26e",
|
||||
"node": {
|
||||
"base_classes": [
|
||||
"LanguageModel",
|
||||
"Message"
|
||||
],
|
||||
"beta": false,
|
||||
"conditional_paths": [],
|
||||
"custom_fields": {},
|
||||
"description": "Generates text using OpenAI LLMs.",
|
||||
"display_name": "OpenAI",
|
||||
"documentation": "",
|
||||
"edited": true,
|
||||
"field_order": [
|
||||
"input_value",
|
||||
"max_tokens",
|
||||
"model_kwargs",
|
||||
"output_schema",
|
||||
"model_name",
|
||||
"openai_api_base",
|
||||
"openai_api_key",
|
||||
"temperature",
|
||||
"stream",
|
||||
"system_message",
|
||||
"seed"
|
||||
],
|
||||
"frozen": false,
|
||||
"icon": "OpenAI",
|
||||
"output_types": [],
|
||||
"outputs": [
|
||||
{
|
||||
"cache": true,
|
||||
"display_name": "Text",
|
||||
"hidden": false,
|
||||
"method": "text_response",
|
||||
"name": "text_output",
|
||||
"selected": "Message",
|
||||
"types": [
|
||||
"Message"
|
||||
],
|
||||
"value": "__UNDEFINED__"
|
||||
},
|
||||
{
|
||||
"cache": true,
|
||||
"display_name": "Language Model",
|
||||
"method": "build_model",
|
||||
"name": "model_output",
|
||||
"selected": "LanguageModel",
|
||||
"types": [
|
||||
"LanguageModel"
|
||||
],
|
||||
"value": "__UNDEFINED__"
|
||||
}
|
||||
],
|
||||
"pinned": false,
|
||||
"template": {
|
||||
"_type": "Component",
|
||||
"code": {
|
||||
"advanced": true,
|
||||
"dynamic": true,
|
||||
"fileTypes": [],
|
||||
"file_path": "",
|
||||
"info": "",
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"multiline": true,
|
||||
"name": "code",
|
||||
"password": false,
|
||||
"placeholder": "",
|
||||
"required": true,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"type": "code",
|
||||
"value": "import operator\nfrom functools import reduce\n\nfrom langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.constants import STREAM_INFO_TEXT\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.inputs import (\n BoolInput,\n DictInput,\n DropdownInput,\n FloatInput,\n IntInput,\n MessageInput,\n SecretStrInput,\n StrInput,\n)\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n inputs = [\n MessageInput(name=\"input_value\", display_name=\"Input\"),\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n ),\n DictInput(name=\"model_kwargs\", display_name=\"Model Kwargs\", advanced=True),\n DictInput(\n name=\"output_schema\",\n is_list=True,\n display_name=\"Schema\",\n advanced=True,\n info=\"The schema for the Output of the model. You must pass the word JSON in the prompt. If left blank, JSON mode will be disabled.\",\n ),\n DropdownInput(\n name=\"model_name\", display_name=\"Model Name\", advanced=False, options=MODEL_NAMES, value=MODEL_NAMES[0]\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"openai_api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n FloatInput(name=\"temperature\", display_name=\"Temperature\", value=0.1),\n BoolInput(name=\"stream\", display_name=\"Stream\", info=STREAM_INFO_TEXT, advanced=True),\n StrInput(\n name=\"system_message\",\n display_name=\"System Message\",\n info=\"System message to pass to the model.\",\n advanced=True,\n ),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n ]\n\n def build_model(self) -> LanguageModel:\n # self.output_schea is a list of dictionaries\n # let's convert it to a dictionary\n output_schema_dict: dict[str, str] = reduce(operator.ior, self.output_schema or {}, {})\n openai_api_key = self.openai_api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = bool(output_schema_dict)\n seed = self.seed\n model_kwargs[\"seed\"] = seed\n\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature or 0.1,\n )\n if json_mode:\n output = output.with_structured_output(schema=output_schema_dict, method=\"json_mode\") # type: ignore\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"\n Get a message from an OpenAI exception.\n\n Args:\n exception (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n\n try:\n from openai import BadRequestError\n except ImportError:\n return\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\") # type: ignore\n if message:\n return message\n return\n"
|
||||
},
|
||||
"input_value": {
|
||||
"advanced": false,
|
||||
"display_name": "Input",
|
||||
"dynamic": false,
|
||||
"info": "",
|
||||
"input_types": [
|
||||
"Message"
|
||||
],
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"name": "input_value",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_input": true,
|
||||
"trace_as_metadata": true,
|
||||
"type": "str",
|
||||
"value": ""
|
||||
},
|
||||
"max_tokens": {
|
||||
"advanced": true,
|
||||
"display_name": "Max Tokens",
|
||||
"dynamic": false,
|
||||
"info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.",
|
||||
"list": false,
|
||||
"name": "max_tokens",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_metadata": true,
|
||||
"type": "int",
|
||||
"value": ""
|
||||
},
|
||||
"model_kwargs": {
|
||||
"advanced": true,
|
||||
"display_name": "Model Kwargs",
|
||||
"dynamic": false,
|
||||
"info": "",
|
||||
"list": false,
|
||||
"name": "model_kwargs",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_input": true,
|
||||
"type": "dict",
|
||||
"value": {}
|
||||
},
|
||||
"model_name": {
|
||||
"advanced": false,
|
||||
"display_name": "Model Name",
|
||||
"dynamic": false,
|
||||
"info": "",
|
||||
"name": "model_name",
|
||||
"options": [
|
||||
"gpt-4o",
|
||||
"gpt-4-turbo",
|
||||
"gpt-4-turbo-preview",
|
||||
"gpt-3.5-turbo",
|
||||
"gpt-3.5-turbo-0125"
|
||||
],
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_metadata": true,
|
||||
"type": "str",
|
||||
"value": "gpt-4o"
|
||||
},
|
||||
"openai_api_base": {
|
||||
"advanced": true,
|
||||
"display_name": "OpenAI API Base",
|
||||
"dynamic": false,
|
||||
"info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.",
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"name": "openai_api_base",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_metadata": true,
|
||||
"type": "str",
|
||||
"value": ""
|
||||
},
|
||||
"openai_api_key": {
|
||||
"advanced": false,
|
||||
"display_name": "OpenAI API Key",
|
||||
"dynamic": false,
|
||||
"info": "The OpenAI API Key to use for the OpenAI model.",
|
||||
"input_types": [],
|
||||
"load_from_db": false,
|
||||
"name": "openai_api_key",
|
||||
"password": true,
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"type": "str",
|
||||
"value": ""
|
||||
},
|
||||
"output_schema": {
|
||||
"advanced": true,
|
||||
"display_name": "Schema",
|
||||
"dynamic": false,
|
||||
"info": "The schema for the Output of the model. You must pass the word JSON in the prompt. If left blank, JSON mode will be disabled.",
|
||||
"list": true,
|
||||
"name": "output_schema",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_input": true,
|
||||
"type": "dict",
|
||||
"value": {}
|
||||
},
|
||||
"seed": {
|
||||
"advanced": true,
|
||||
"display_name": "Seed",
|
||||
"dynamic": false,
|
||||
"info": "The seed controls the reproducibility of the job.",
|
||||
"list": false,
|
||||
"name": "seed",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_metadata": true,
|
||||
"type": "int",
|
||||
"value": 1
|
||||
},
|
||||
"stream": {
|
||||
"advanced": true,
|
||||
"display_name": "Stream",
|
||||
"dynamic": false,
|
||||
"info": "Stream the response from the model. Streaming works only in Chat.",
|
||||
"list": false,
|
||||
"name": "stream",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_metadata": true,
|
||||
"type": "bool",
|
||||
"value": false
|
||||
},
|
||||
"system_message": {
|
||||
"advanced": true,
|
||||
"display_name": "System Message",
|
||||
"dynamic": false,
|
||||
"info": "System message to pass to the model.",
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"name": "system_message",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_metadata": true,
|
||||
"type": "str",
|
||||
"value": ""
|
||||
},
|
||||
"temperature": {
|
||||
"advanced": false,
|
||||
"display_name": "Temperature",
|
||||
"dynamic": false,
|
||||
"info": "",
|
||||
"list": false,
|
||||
"name": "temperature",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_metadata": true,
|
||||
"type": "float",
|
||||
"value": 0.1
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": "OpenAIModel"
|
||||
},
|
||||
"dragging": false,
|
||||
"height": 621,
|
||||
"id": "OpenAIModel-aN26e",
|
||||
"position": {
|
||||
"x": 584.9288140250019,
|
||||
"y": 1149.0790574268922
|
||||
},
|
||||
"positionAbsolute": {
|
||||
"x": 584.9288140250019,
|
||||
"y": 1149.0790574268922
|
||||
},
|
||||
"selected": false,
|
||||
"type": "genericNode",
|
||||
"width": 384
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"description": "Display a chat message in the Playground.",
|
||||
"display_name": "Chat Output",
|
||||
"edited": false,
|
||||
"id": "ChatOutput-wokdr",
|
||||
"node": {
|
||||
"base_classes": [
|
||||
"Message"
|
||||
],
|
||||
"beta": false,
|
||||
"conditional_paths": [],
|
||||
"custom_fields": {},
|
||||
"description": "Display a chat message in the Playground.",
|
||||
"display_name": "Chat Output",
|
||||
"documentation": "",
|
||||
"edited": true,
|
||||
"field_order": [
|
||||
"input_value",
|
||||
"sender",
|
||||
"sender_name",
|
||||
"session_id",
|
||||
"data_template"
|
||||
],
|
||||
"frozen": false,
|
||||
"icon": "ChatOutput",
|
||||
"output_types": [],
|
||||
"outputs": [
|
||||
{
|
||||
"cache": true,
|
||||
"display_name": "Message",
|
||||
"method": "message_response",
|
||||
"name": "message",
|
||||
"selected": "Message",
|
||||
"types": [
|
||||
"Message"
|
||||
],
|
||||
"value": "__UNDEFINED__"
|
||||
}
|
||||
],
|
||||
"pinned": false,
|
||||
"template": {
|
||||
"_type": "Component",
|
||||
"code": {
|
||||
"advanced": true,
|
||||
"dynamic": true,
|
||||
"fileTypes": [],
|
||||
"file_path": "",
|
||||
"info": "",
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"multiline": true,
|
||||
"name": "code",
|
||||
"password": false,
|
||||
"placeholder": "",
|
||||
"required": true,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"type": "code",
|
||||
"value": "from langflow.base.io.chat import ChatComponent\nfrom langflow.io import DropdownInput, Output, TextInput\nfrom langflow.schema.message import Message\n\n\nclass ChatOutput(ChatComponent):\n display_name = \"Chat Output\"\n description = \"Display a chat message in the Playground.\"\n icon = \"ChatOutput\"\n\n inputs = [\n TextInput(\n name=\"input_value\",\n display_name=\"Text\",\n info=\"Message to be passed as output.\",\n ),\n DropdownInput(\n name=\"sender\",\n display_name=\"Sender Type\",\n options=[\"Machine\", \"User\"],\n value=\"Machine\",\n advanced=True,\n info=\"Type of sender.\",\n ),\n TextInput(\n name=\"sender_name\", display_name=\"Sender Name\", info=\"Name of the sender.\", value=\"AI\", advanced=True\n ),\n TextInput(name=\"session_id\", display_name=\"Session ID\", info=\"Session ID for the message.\", advanced=True),\n TextInput(\n name=\"data_template\",\n display_name=\"Data Template\",\n value=\"{text}\",\n advanced=True,\n info=\"Template to convert Data to Text. If left empty, it will be dynamically set to the Data's text key.\",\n ),\n ]\n outputs = [\n Output(display_name=\"Message\", name=\"message\", method=\"message_response\"),\n ]\n\n def message_response(self) -> Message:\n message = Message(\n text=self.input_value,\n sender=self.sender,\n sender_name=self.sender_name,\n session_id=self.session_id,\n )\n if self.session_id and isinstance(message, Message) and isinstance(message.text, str):\n self.store_message(message)\n self.message.value = message\n\n self.status = message\n return message\n"
|
||||
},
|
||||
"data_template": {
|
||||
"advanced": true,
|
||||
"display_name": "Data Template",
|
||||
"dynamic": false,
|
||||
"info": "Template to convert Data to Text. If left empty, it will be dynamically set to the Data's text key.",
|
||||
"input_types": [
|
||||
"Message"
|
||||
],
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"name": "data_template",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_input": true,
|
||||
"trace_as_metadata": true,
|
||||
"type": "str",
|
||||
"value": "{text}"
|
||||
},
|
||||
"input_value": {
|
||||
"advanced": false,
|
||||
"display_name": "Text",
|
||||
"dynamic": false,
|
||||
"info": "Message to be passed as output.",
|
||||
"input_types": [
|
||||
"Message"
|
||||
],
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"name": "input_value",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_input": true,
|
||||
"trace_as_metadata": true,
|
||||
"type": "str",
|
||||
"value": ""
|
||||
},
|
||||
"sender": {
|
||||
"advanced": true,
|
||||
"display_name": "Sender Type",
|
||||
"dynamic": false,
|
||||
"info": "Type of sender.",
|
||||
"name": "sender",
|
||||
"options": [
|
||||
"Machine",
|
||||
"User"
|
||||
],
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_metadata": true,
|
||||
"type": "str",
|
||||
"value": "Machine"
|
||||
},
|
||||
"sender_name": {
|
||||
"advanced": true,
|
||||
"display_name": "Sender Name",
|
||||
"dynamic": false,
|
||||
"info": "Name of the sender.",
|
||||
"input_types": [
|
||||
"Message"
|
||||
],
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"name": "sender_name",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_input": true,
|
||||
"trace_as_metadata": true,
|
||||
"type": "str",
|
||||
"value": "AI"
|
||||
},
|
||||
"session_id": {
|
||||
"advanced": true,
|
||||
"display_name": "Session ID",
|
||||
"dynamic": false,
|
||||
"info": "Session ID for the message.",
|
||||
"input_types": [
|
||||
"Message"
|
||||
],
|
||||
"list": false,
|
||||
"load_from_db": false,
|
||||
"name": "session_id",
|
||||
"placeholder": "",
|
||||
"required": false,
|
||||
"show": true,
|
||||
"title_case": false,
|
||||
"trace_as_input": true,
|
||||
"trace_as_metadata": true,
|
||||
"type": "str",
|
||||
"value": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": "ChatOutput"
|
||||
},
|
||||
"dragging": false,
|
||||
"height": 308,
|
||||
"id": "ChatOutput-wokdr",
|
||||
"position": {
|
||||
"x": 1157.3374592784412,
|
||||
"y": 1160.9424490383622
|
||||
},
|
||||
"positionAbsolute": {
|
||||
"x": 1157.3374592784412,
|
||||
"y": 1160.9424490383622
|
||||
},
|
||||
"selected": false,
|
||||
"type": "genericNode",
|
||||
"width": 384
|
||||
}
|
||||
],
|
||||
"viewport": {
|
||||
"x": 353.0590737990465,
|
||||
"y": -407.76221076623995,
|
||||
"zoom": 0.5467255436493648
|
||||
}
|
||||
},
|
||||
"description": "This flow will get you experimenting with the basics of the UI, the Chat and the Prompt component. \n\nTry changing the Template in it to see how the model behaves. \nYou can change it to this and a Text Input into the `type_of_person` variable : \"Answer the user as if you were a pirate.\n\nUser: {user_input}\n\nAnswer: \" ",
|
||||
"endpoint_name": null,
|
||||
"id": "d646c486-746c-402f-a94a-a03eb2f7941c",
|
||||
"is_component": false,
|
||||
"last_tested_version": "1.0.0rc1",
|
||||
"name": "Basic Prompting (Hello World)"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue