Merge branch 'cz/mergeAll' of https://github.com/langflow-ai/langflow into cz/mergeAll
This commit is contained in:
commit
5a64bb2678
19 changed files with 1239 additions and 384 deletions
|
|
@ -58,7 +58,7 @@ class AmazonBedrockComponent(LCModelComponent):
|
||||||
"advanced": True,
|
"advanced": True,
|
||||||
},
|
},
|
||||||
"cache": {"display_name": "Cache"},
|
"cache": {"display_name": "Cache"},
|
||||||
"input_value": {"display_name": "Input"},
|
"input_value": {"display_name": "Input", "input_types": ["Text", "Record"]},
|
||||||
"system_message": {
|
"system_message": {
|
||||||
"display_name": "System Message",
|
"display_name": "System Message",
|
||||||
"info": "System message to pass to the model.",
|
"info": "System message to pass to the model.",
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ class AnthropicLLM(LCModelComponent):
|
||||||
"info": "Endpoint of the Anthropic API. Defaults to 'https://api.anthropic.com' if not specified.",
|
"info": "Endpoint of the Anthropic API. Defaults to 'https://api.anthropic.com' if not specified.",
|
||||||
},
|
},
|
||||||
"code": {"show": False},
|
"code": {"show": False},
|
||||||
"input_value": {"display_name": "Input"},
|
"input_value": {"display_name": "Input", "input_types": ["Text", "Record"]},
|
||||||
"stream": {
|
"stream": {
|
||||||
"display_name": "Stream",
|
"display_name": "Stream",
|
||||||
"advanced": True,
|
"advanced": True,
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ class AzureChatOpenAIComponent(LCModelComponent):
|
||||||
"info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.",
|
"info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.",
|
||||||
},
|
},
|
||||||
"code": {"show": False},
|
"code": {"show": False},
|
||||||
"input_value": {"display_name": "Input"},
|
"input_value": {"display_name": "Input", "input_types": ["Text", "Record"]},
|
||||||
"stream": {
|
"stream": {
|
||||||
"display_name": "Stream",
|
"display_name": "Stream",
|
||||||
"info": STREAM_INFO_TEXT,
|
"info": STREAM_INFO_TEXT,
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ class QianfanChatEndpointComponent(LCModelComponent):
|
||||||
"info": "Endpoint of the Qianfan LLM, required if custom model used.",
|
"info": "Endpoint of the Qianfan LLM, required if custom model used.",
|
||||||
},
|
},
|
||||||
"code": {"show": False},
|
"code": {"show": False},
|
||||||
"input_value": {"display_name": "Input"},
|
"input_value": {"display_name": "Input", "input_types": ["Text", "Record"]},
|
||||||
"stream": {
|
"stream": {
|
||||||
"display_name": "Stream",
|
"display_name": "Stream",
|
||||||
"info": STREAM_INFO_TEXT,
|
"info": STREAM_INFO_TEXT,
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ class ChatLiteLLMModelComponent(LCModelComponent):
|
||||||
"required": False,
|
"required": False,
|
||||||
"default": False,
|
"default": False,
|
||||||
},
|
},
|
||||||
"input_value": {"display_name": "Input"},
|
"input_value": {"display_name": "Input", "input_types": ["Text", "Record"]},
|
||||||
"stream": {
|
"stream": {
|
||||||
"display_name": "Stream",
|
"display_name": "Stream",
|
||||||
"info": STREAM_INFO_TEXT,
|
"info": STREAM_INFO_TEXT,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
from langchain_cohere import ChatCohere
|
||||||
from pydantic.v1 import SecretStr
|
from pydantic.v1 import SecretStr
|
||||||
from langflow.field_typing import Text
|
|
||||||
from langflow.base.constants import STREAM_INFO_TEXT
|
from langflow.base.constants import STREAM_INFO_TEXT
|
||||||
from langflow.base.models.model import LCModelComponent
|
from langflow.base.models.model import LCModelComponent
|
||||||
from langchain_cohere import ChatCohere
|
from langflow.field_typing import Text
|
||||||
|
|
||||||
|
|
||||||
class CohereComponent(LCModelComponent):
|
class CohereComponent(LCModelComponent):
|
||||||
|
|
@ -42,7 +43,7 @@ class CohereComponent(LCModelComponent):
|
||||||
"type": "float",
|
"type": "float",
|
||||||
"show": True,
|
"show": True,
|
||||||
},
|
},
|
||||||
"input_value": {"display_name": "Input"},
|
"input_value": {"display_name": "Input", "input_types": ["Text", "Record"]},
|
||||||
"stream": {
|
"stream": {
|
||||||
"display_name": "Stream",
|
"display_name": "Stream",
|
||||||
"info": STREAM_INFO_TEXT,
|
"info": STREAM_INFO_TEXT,
|
||||||
|
|
@ -69,3 +70,4 @@ class CohereComponent(LCModelComponent):
|
||||||
temperature=temperature,
|
temperature=temperature,
|
||||||
)
|
)
|
||||||
return self.get_chat_result(output, stream, input_value, system_message)
|
return self.get_chat_result(output, stream, input_value, system_message)
|
||||||
|
return self.get_chat_result(output, stream, input_value, system_message)
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,10 @@ from typing import Optional
|
||||||
|
|
||||||
from langchain_community.chat_models.huggingface import ChatHuggingFace
|
from langchain_community.chat_models.huggingface import ChatHuggingFace
|
||||||
from langchain_community.llms.huggingface_endpoint import HuggingFaceEndpoint
|
from langchain_community.llms.huggingface_endpoint import HuggingFaceEndpoint
|
||||||
from langflow.field_typing import Text
|
|
||||||
from langflow.base.constants import STREAM_INFO_TEXT
|
from langflow.base.constants import STREAM_INFO_TEXT
|
||||||
from langflow.base.models.model import LCModelComponent
|
from langflow.base.models.model import LCModelComponent
|
||||||
|
from langflow.field_typing import Text
|
||||||
|
|
||||||
|
|
||||||
class HuggingFaceEndpointsComponent(LCModelComponent):
|
class HuggingFaceEndpointsComponent(LCModelComponent):
|
||||||
|
|
@ -36,7 +37,7 @@ class HuggingFaceEndpointsComponent(LCModelComponent):
|
||||||
"advanced": True,
|
"advanced": True,
|
||||||
},
|
},
|
||||||
"code": {"show": False},
|
"code": {"show": False},
|
||||||
"input_value": {"display_name": "Input"},
|
"input_value": {"display_name": "Input", "input_types": ["Text", "Record"]},
|
||||||
"stream": {
|
"stream": {
|
||||||
"display_name": "Stream",
|
"display_name": "Stream",
|
||||||
"info": STREAM_INFO_TEXT,
|
"info": STREAM_INFO_TEXT,
|
||||||
|
|
@ -72,3 +73,4 @@ class HuggingFaceEndpointsComponent(LCModelComponent):
|
||||||
raise ValueError("Could not connect to HuggingFace Endpoints API.") from e
|
raise ValueError("Could not connect to HuggingFace Endpoints API.") from e
|
||||||
output = ChatHuggingFace(llm=llm)
|
output = ChatHuggingFace(llm=llm)
|
||||||
return self.get_chat_result(output, stream, input_value, system_message)
|
return self.get_chat_result(output, stream, input_value, system_message)
|
||||||
|
return self.get_chat_result(output, stream, input_value, system_message)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class MistralAIModelComponent(LCModelComponent):
|
||||||
|
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
return {
|
return {
|
||||||
"input_value": {"display_name": "Input"},
|
"input_value": {"display_name": "Input", "input_types": ["Text", "Record"]},
|
||||||
"max_tokens": {
|
"max_tokens": {
|
||||||
"display_name": "Max Tokens",
|
"display_name": "Max Tokens",
|
||||||
"advanced": True,
|
"advanced": True,
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ class ChatOllamaComponent(LCModelComponent):
|
||||||
"info": "Template to use for generating text.",
|
"info": "Template to use for generating text.",
|
||||||
"advanced": True,
|
"advanced": True,
|
||||||
},
|
},
|
||||||
"input_value": {"display_name": "Input"},
|
"input_value": {"display_name": "Input", "input_types": ["Text", "Record"]},
|
||||||
"stream": {
|
"stream": {
|
||||||
"display_name": "Stream",
|
"display_name": "Stream",
|
||||||
"info": STREAM_INFO_TEXT,
|
"info": STREAM_INFO_TEXT,
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class OpenAIModelComponent(LCModelComponent):
|
||||||
|
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
return {
|
return {
|
||||||
"input_value": {"display_name": "Input"},
|
"input_value": {"display_name": "Input", "input_types": ["Text", "Record"]},
|
||||||
"max_tokens": {
|
"max_tokens": {
|
||||||
"display_name": "Max Tokens",
|
"display_name": "Max Tokens",
|
||||||
"advanced": True,
|
"advanced": True,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
from langflow.base.constants import STREAM_INFO_TEXT
|
from langflow.base.constants import STREAM_INFO_TEXT
|
||||||
from langflow.base.models.model import LCModelComponent
|
from langflow.base.models.model import LCModelComponent
|
||||||
from langflow.field_typing import Text
|
from langflow.field_typing import Text
|
||||||
|
|
@ -74,7 +73,7 @@ class ChatVertexAIComponent(LCModelComponent):
|
||||||
"value": False,
|
"value": False,
|
||||||
"advanced": True,
|
"advanced": True,
|
||||||
},
|
},
|
||||||
"input_value": {"display_name": "Input"},
|
"input_value": {"display_name": "Input", "input_types": ["Text", "Record"]},
|
||||||
"stream": {
|
"stream": {
|
||||||
"display_name": "Stream",
|
"display_name": "Stream",
|
||||||
"info": STREAM_INFO_TEXT,
|
"info": STREAM_INFO_TEXT,
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,9 @@
|
||||||
"name": "template",
|
"name": "template",
|
||||||
"display_name": "Template",
|
"display_name": "Template",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -84,14 +86,22 @@
|
||||||
"is_input": null,
|
"is_input": null,
|
||||||
"is_output": null,
|
"is_output": null,
|
||||||
"is_composition": null,
|
"is_composition": null,
|
||||||
"base_classes": ["object", "str", "Text"],
|
"base_classes": [
|
||||||
|
"object",
|
||||||
|
"str",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"name": "",
|
"name": "",
|
||||||
"display_name": "Prompt",
|
"display_name": "Prompt",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"template": ["user_input"]
|
"template": [
|
||||||
|
"user_input"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"full_path": null,
|
"full_path": null,
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
|
|
@ -140,7 +150,10 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"code": {
|
"code": {
|
||||||
"type": "code",
|
"type": "code",
|
||||||
|
|
@ -149,7 +162,7 @@
|
||||||
"list": false,
|
"list": false,
|
||||||
"show": true,
|
"show": true,
|
||||||
"multiline": true,
|
"multiline": true,
|
||||||
"value": "from typing import Optional\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 NestedDict, Text\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n field_order = [\n \"max_tokens\",\n \"model_kwargs\",\n \"model_name\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"temperature\",\n \"input_value\",\n \"system_message\",\n \"stream\",\n ]\n\n def build_config(self):\n return {\n \"input_value\": {\"display_name\": \"Input\"},\n \"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 \"model_kwargs\": {\n \"display_name\": \"Model Kwargs\",\n \"advanced\": True,\n },\n \"model_name\": {\n \"display_name\": \"Model Name\",\n \"advanced\": False,\n \"options\": MODEL_NAMES,\n },\n \"openai_api_base\": {\n \"display_name\": \"OpenAI API Base\",\n \"advanced\": True,\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 \"info\": \"The OpenAI API Key to use for the OpenAI model.\",\n \"advanced\": False,\n \"password\": True,\n },\n \"temperature\": {\n \"display_name\": \"Temperature\",\n \"advanced\": False,\n \"value\": 0.1,\n },\n \"stream\": {\n \"display_name\": \"Stream\",\n \"info\": STREAM_INFO_TEXT,\n \"advanced\": True,\n },\n \"system_message\": {\n \"display_name\": \"System Message\",\n \"info\": \"System message to pass to the model.\",\n \"advanced\": True,\n },\n }\n\n def build(\n self,\n input_value: Text,\n openai_api_key: str,\n temperature: float = 0.1,\n model_name: str = \"gpt-4o\",\n max_tokens: Optional[int] = 256,\n model_kwargs: NestedDict = {},\n openai_api_base: Optional[str] = None,\n stream: bool = False,\n system_message: Optional[str] = None,\n ) -> Text:\n if not openai_api_base:\n openai_api_base = \"https://api.openai.com/v1\"\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n\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,\n )\n\n return self.get_chat_result(output, stream, input_value, system_message)\n",
|
"value": "from typing import Optional\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 NestedDict, Text\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n field_order = [\n \"max_tokens\",\n \"model_kwargs\",\n \"model_name\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"temperature\",\n \"input_value\",\n \"system_message\",\n \"stream\",\n ]\n\n def build_config(self):\n return {\n \"input_value\": {\"display_name\": \"Input\", \"input_types\": [\"Text\", \"Record\"]},\n \"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 \"model_kwargs\": {\n \"display_name\": \"Model Kwargs\",\n \"advanced\": True,\n },\n \"model_name\": {\n \"display_name\": \"Model Name\",\n \"advanced\": False,\n \"options\": MODEL_NAMES,\n },\n \"openai_api_base\": {\n \"display_name\": \"OpenAI API Base\",\n \"advanced\": True,\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 \"info\": \"The OpenAI API Key to use for the OpenAI model.\",\n \"advanced\": False,\n \"password\": True,\n },\n \"temperature\": {\n \"display_name\": \"Temperature\",\n \"advanced\": False,\n \"value\": 0.1,\n },\n \"stream\": {\n \"display_name\": \"Stream\",\n \"info\": STREAM_INFO_TEXT,\n \"advanced\": True,\n },\n \"system_message\": {\n \"display_name\": \"System Message\",\n \"info\": \"System message to pass to the model.\",\n \"advanced\": True,\n },\n }\n\n def build(\n self,\n input_value: Text,\n openai_api_key: str,\n temperature: float = 0.1,\n model_name: str = \"gpt-4o\",\n max_tokens: Optional[int] = 256,\n model_kwargs: NestedDict = {},\n openai_api_base: Optional[str] = None,\n stream: bool = False,\n system_message: Optional[str] = None,\n ) -> Text:\n if not openai_api_base:\n openai_api_base = \"https://api.openai.com/v1\"\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n\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,\n )\n\n return self.get_chat_result(output, stream, input_value, system_message)\n",
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
|
|
@ -223,7 +236,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"openai_api_base": {
|
"openai_api_base": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -242,7 +257,9 @@
|
||||||
"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.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"openai_api_key": {
|
"openai_api_key": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -261,7 +278,9 @@
|
||||||
"info": "The OpenAI API Key to use for the OpenAI model.",
|
"info": "The OpenAI API Key to use for the OpenAI model.",
|
||||||
"load_from_db": true,
|
"load_from_db": true,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"value": "OPENAI_API_KEY"
|
"value": "OPENAI_API_KEY"
|
||||||
},
|
},
|
||||||
"stream": {
|
"stream": {
|
||||||
|
|
@ -300,7 +319,9 @@
|
||||||
"info": "System message to pass to the model.",
|
"info": "System message to pass to the model.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"temperature": {
|
"temperature": {
|
||||||
"type": "float",
|
"type": "float",
|
||||||
|
|
@ -331,7 +352,11 @@
|
||||||
},
|
},
|
||||||
"description": "Generates text using OpenAI LLMs.",
|
"description": "Generates text using OpenAI LLMs.",
|
||||||
"icon": "OpenAI",
|
"icon": "OpenAI",
|
||||||
"base_classes": ["object", "Text", "str"],
|
"base_classes": [
|
||||||
|
"object",
|
||||||
|
"Text",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"display_name": "OpenAI",
|
"display_name": "OpenAI",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -345,7 +370,9 @@
|
||||||
"stream": null,
|
"stream": null,
|
||||||
"system_message": null
|
"system_message": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [
|
"field_order": [
|
||||||
|
|
@ -416,7 +443,9 @@
|
||||||
"name": "input_value",
|
"name": "input_value",
|
||||||
"display_name": "Message",
|
"display_name": "Message",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -440,7 +469,9 @@
|
||||||
"info": "In case of Message being a Record, this template will be used to convert it to text.",
|
"info": "In case of Message being a Record, this template will be used to convert it to text.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"return_record": {
|
"return_record": {
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
|
|
@ -472,7 +503,10 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
"options": ["Machine", "User"],
|
"options": [
|
||||||
|
"Machine",
|
||||||
|
"User"
|
||||||
|
],
|
||||||
"name": "sender",
|
"name": "sender",
|
||||||
"display_name": "Sender Type",
|
"display_name": "Sender Type",
|
||||||
"advanced": true,
|
"advanced": true,
|
||||||
|
|
@ -480,7 +514,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"sender_name": {
|
"sender_name": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -500,7 +536,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"session_id": {
|
"session_id": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -519,13 +557,20 @@
|
||||||
"info": "If provided, the message will be stored in the memory.",
|
"info": "If provided, the message will be stored in the memory.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Display a chat message in the Playground.",
|
"description": "Display a chat message in the Playground.",
|
||||||
"icon": "ChatOutput",
|
"icon": "ChatOutput",
|
||||||
"base_classes": ["Record", "Text", "str", "object"],
|
"base_classes": [
|
||||||
|
"Record",
|
||||||
|
"Text",
|
||||||
|
"str",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"display_name": "Chat Output",
|
"display_name": "Chat Output",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -536,7 +581,10 @@
|
||||||
"return_record": null,
|
"return_record": null,
|
||||||
"record_template": null
|
"record_template": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text", "Record"],
|
"output_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -632,7 +680,10 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
"options": ["Machine", "User"],
|
"options": [
|
||||||
|
"Machine",
|
||||||
|
"User"
|
||||||
|
],
|
||||||
"name": "sender",
|
"name": "sender",
|
||||||
"display_name": "Sender Type",
|
"display_name": "Sender Type",
|
||||||
"advanced": true,
|
"advanced": true,
|
||||||
|
|
@ -640,7 +691,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"sender_name": {
|
"sender_name": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -660,7 +713,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"session_id": {
|
"session_id": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -679,13 +734,20 @@
|
||||||
"info": "If provided, the message will be stored in the memory.",
|
"info": "If provided, the message will be stored in the memory.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Get chat inputs from the Playground.",
|
"description": "Get chat inputs from the Playground.",
|
||||||
"icon": "ChatInput",
|
"icon": "ChatInput",
|
||||||
"base_classes": ["object", "Record", "str", "Text"],
|
"base_classes": [
|
||||||
|
"object",
|
||||||
|
"Record",
|
||||||
|
"str",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"display_name": "Chat Input",
|
"display_name": "Chat Input",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -695,7 +757,10 @@
|
||||||
"session_id": null,
|
"session_id": null,
|
||||||
"return_record": null
|
"return_record": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text", "Record"],
|
"output_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -723,11 +788,17 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "ChatOutput-njtka",
|
"id": "ChatOutput-njtka",
|
||||||
"inputTypes": ["Text"],
|
"inputTypes": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["object", "Text", "str"],
|
"baseClasses": [
|
||||||
|
"object",
|
||||||
|
"Text",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"dataType": "OpenAIModel",
|
"dataType": "OpenAIModel",
|
||||||
"id": "OpenAIModel-k39HS"
|
"id": "OpenAIModel-k39HS"
|
||||||
}
|
}
|
||||||
|
|
@ -747,11 +818,17 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "OpenAIModel-k39HS",
|
"id": "OpenAIModel-k39HS",
|
||||||
"inputTypes": ["Text"],
|
"inputTypes": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["object", "str", "Text"],
|
"baseClasses": [
|
||||||
|
"object",
|
||||||
|
"str",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dataType": "Prompt",
|
"dataType": "Prompt",
|
||||||
"id": "Prompt-uxBqP"
|
"id": "Prompt-uxBqP"
|
||||||
}
|
}
|
||||||
|
|
@ -771,11 +848,21 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "user_input",
|
"fieldName": "user_input",
|
||||||
"id": "Prompt-uxBqP",
|
"id": "Prompt-uxBqP",
|
||||||
"inputTypes": ["Document", "BaseOutputParser", "Record", "Text"],
|
"inputTypes": [
|
||||||
|
"Document",
|
||||||
|
"BaseOutputParser",
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["object", "Record", "str", "Text"],
|
"baseClasses": [
|
||||||
|
"object",
|
||||||
|
"Record",
|
||||||
|
"str",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dataType": "ChatInput",
|
"dataType": "ChatInput",
|
||||||
"id": "ChatInput-P3fgL"
|
"id": "ChatInput-P3fgL"
|
||||||
}
|
}
|
||||||
|
|
@ -797,4 +884,4 @@
|
||||||
"name": "Basic Prompting (Hello, World)",
|
"name": "Basic Prompting (Hello, World)",
|
||||||
"last_tested_version": "1.0.0a4",
|
"last_tested_version": "1.0.0a4",
|
||||||
"is_component": false
|
"is_component": false
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +45,9 @@
|
||||||
"name": "template",
|
"name": "template",
|
||||||
"display_name": "Template",
|
"display_name": "Template",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -136,14 +138,24 @@
|
||||||
"is_input": null,
|
"is_input": null,
|
||||||
"is_output": null,
|
"is_output": null,
|
||||||
"is_composition": null,
|
"is_composition": null,
|
||||||
"base_classes": ["object", "Text", "str"],
|
"base_classes": [
|
||||||
|
"object",
|
||||||
|
"Text",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"name": "",
|
"name": "",
|
||||||
"display_name": "Prompt",
|
"display_name": "Prompt",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"template": ["reference_1", "reference_2", "instructions"]
|
"template": [
|
||||||
|
"reference_1",
|
||||||
|
"reference_2",
|
||||||
|
"instructions"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"full_path": null,
|
"full_path": null,
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
|
|
@ -210,7 +222,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"value": [
|
"value": [
|
||||||
"https://www.promptingguide.ai/techniques/prompt_chaining"
|
"https://www.promptingguide.ai/techniques/prompt_chaining"
|
||||||
]
|
]
|
||||||
|
|
@ -219,13 +233,17 @@
|
||||||
},
|
},
|
||||||
"description": "Fetch content from one or more URLs.",
|
"description": "Fetch content from one or more URLs.",
|
||||||
"icon": "layout-template",
|
"icon": "layout-template",
|
||||||
"base_classes": ["Record"],
|
"base_classes": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"display_name": "URL",
|
"display_name": "URL",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"urls": null
|
"urls": null
|
||||||
},
|
},
|
||||||
"output_types": ["Record"],
|
"output_types": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -284,7 +302,9 @@
|
||||||
"name": "input_value",
|
"name": "input_value",
|
||||||
"display_name": "Message",
|
"display_name": "Message",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -308,7 +328,9 @@
|
||||||
"info": "In case of Message being a Record, this template will be used to convert it to text.",
|
"info": "In case of Message being a Record, this template will be used to convert it to text.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"return_record": {
|
"return_record": {
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
|
|
@ -340,7 +362,10 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
"options": ["Machine", "User"],
|
"options": [
|
||||||
|
"Machine",
|
||||||
|
"User"
|
||||||
|
],
|
||||||
"name": "sender",
|
"name": "sender",
|
||||||
"display_name": "Sender Type",
|
"display_name": "Sender Type",
|
||||||
"advanced": true,
|
"advanced": true,
|
||||||
|
|
@ -348,7 +373,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"sender_name": {
|
"sender_name": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -368,7 +395,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"session_id": {
|
"session_id": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -387,13 +416,20 @@
|
||||||
"info": "If provided, the message will be stored in the memory.",
|
"info": "If provided, the message will be stored in the memory.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Display a chat message in the Playground.",
|
"description": "Display a chat message in the Playground.",
|
||||||
"icon": "ChatOutput",
|
"icon": "ChatOutput",
|
||||||
"base_classes": ["Text", "Record", "object", "str"],
|
"base_classes": [
|
||||||
|
"Text",
|
||||||
|
"Record",
|
||||||
|
"object",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"display_name": "Chat Output",
|
"display_name": "Chat Output",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -404,7 +440,10 @@
|
||||||
"return_record": null,
|
"return_record": null,
|
||||||
"record_template": null
|
"record_template": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text", "Record"],
|
"output_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -444,7 +483,10 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"code": {
|
"code": {
|
||||||
"type": "code",
|
"type": "code",
|
||||||
|
|
@ -453,7 +495,7 @@
|
||||||
"list": false,
|
"list": false,
|
||||||
"show": true,
|
"show": true,
|
||||||
"multiline": true,
|
"multiline": true,
|
||||||
"value": "from typing import Optional\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 NestedDict, Text\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n field_order = [\n \"max_tokens\",\n \"model_kwargs\",\n \"model_name\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"temperature\",\n \"input_value\",\n \"system_message\",\n \"stream\",\n ]\n\n def build_config(self):\n return {\n \"input_value\": {\"display_name\": \"Input\"},\n \"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 \"model_kwargs\": {\n \"display_name\": \"Model Kwargs\",\n \"advanced\": True,\n },\n \"model_name\": {\n \"display_name\": \"Model Name\",\n \"advanced\": False,\n \"options\": MODEL_NAMES,\n },\n \"openai_api_base\": {\n \"display_name\": \"OpenAI API Base\",\n \"advanced\": True,\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 \"info\": \"The OpenAI API Key to use for the OpenAI model.\",\n \"advanced\": False,\n \"password\": True,\n },\n \"temperature\": {\n \"display_name\": \"Temperature\",\n \"advanced\": False,\n \"value\": 0.1,\n },\n \"stream\": {\n \"display_name\": \"Stream\",\n \"info\": STREAM_INFO_TEXT,\n \"advanced\": True,\n },\n \"system_message\": {\n \"display_name\": \"System Message\",\n \"info\": \"System message to pass to the model.\",\n \"advanced\": True,\n },\n }\n\n def build(\n self,\n input_value: Text,\n openai_api_key: str,\n temperature: float = 0.1,\n model_name: str = \"gpt-4o\",\n max_tokens: Optional[int] = 256,\n model_kwargs: NestedDict = {},\n openai_api_base: Optional[str] = None,\n stream: bool = False,\n system_message: Optional[str] = None,\n ) -> Text:\n if not openai_api_base:\n openai_api_base = \"https://api.openai.com/v1\"\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n\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,\n )\n\n return self.get_chat_result(output, stream, input_value, system_message)\n",
|
"value": "from typing import Optional\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 NestedDict, Text\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n field_order = [\n \"max_tokens\",\n \"model_kwargs\",\n \"model_name\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"temperature\",\n \"input_value\",\n \"system_message\",\n \"stream\",\n ]\n\n def build_config(self):\n return {\n \"input_value\": {\"display_name\": \"Input\", \"input_types\": [\"Text\", \"Record\"]},\n \"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 \"model_kwargs\": {\n \"display_name\": \"Model Kwargs\",\n \"advanced\": True,\n },\n \"model_name\": {\n \"display_name\": \"Model Name\",\n \"advanced\": False,\n \"options\": MODEL_NAMES,\n },\n \"openai_api_base\": {\n \"display_name\": \"OpenAI API Base\",\n \"advanced\": True,\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 \"info\": \"The OpenAI API Key to use for the OpenAI model.\",\n \"advanced\": False,\n \"password\": True,\n },\n \"temperature\": {\n \"display_name\": \"Temperature\",\n \"advanced\": False,\n \"value\": 0.1,\n },\n \"stream\": {\n \"display_name\": \"Stream\",\n \"info\": STREAM_INFO_TEXT,\n \"advanced\": True,\n },\n \"system_message\": {\n \"display_name\": \"System Message\",\n \"info\": \"System message to pass to the model.\",\n \"advanced\": True,\n },\n }\n\n def build(\n self,\n input_value: Text,\n openai_api_key: str,\n temperature: float = 0.1,\n model_name: str = \"gpt-4o\",\n max_tokens: Optional[int] = 256,\n model_kwargs: NestedDict = {},\n openai_api_base: Optional[str] = None,\n stream: bool = False,\n system_message: Optional[str] = None,\n ) -> Text:\n if not openai_api_base:\n openai_api_base = \"https://api.openai.com/v1\"\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n\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,\n )\n\n return self.get_chat_result(output, stream, input_value, system_message)\n",
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
|
|
@ -527,7 +569,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"openai_api_base": {
|
"openai_api_base": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -546,7 +590,9 @@
|
||||||
"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.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"openai_api_key": {
|
"openai_api_key": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -565,7 +611,9 @@
|
||||||
"info": "The OpenAI API Key to use for the OpenAI model.",
|
"info": "The OpenAI API Key to use for the OpenAI model.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"value": "OPENAI_API_KEY"
|
"value": "OPENAI_API_KEY"
|
||||||
},
|
},
|
||||||
"stream": {
|
"stream": {
|
||||||
|
|
@ -604,7 +652,9 @@
|
||||||
"info": "System message to pass to the model.",
|
"info": "System message to pass to the model.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"temperature": {
|
"temperature": {
|
||||||
"type": "float",
|
"type": "float",
|
||||||
|
|
@ -635,7 +685,11 @@
|
||||||
},
|
},
|
||||||
"description": "Generates text using OpenAI LLMs.",
|
"description": "Generates text using OpenAI LLMs.",
|
||||||
"icon": "OpenAI",
|
"icon": "OpenAI",
|
||||||
"base_classes": ["str", "Text", "object"],
|
"base_classes": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"display_name": "OpenAI",
|
"display_name": "OpenAI",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -649,7 +703,9 @@
|
||||||
"stream": null,
|
"stream": null,
|
||||||
"system_message": null
|
"system_message": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [
|
"field_order": [
|
||||||
|
|
@ -722,20 +778,28 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
"value": ["https://www.promptingguide.ai/introduction/basics"]
|
"Text"
|
||||||
|
],
|
||||||
|
"value": [
|
||||||
|
"https://www.promptingguide.ai/introduction/basics"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Fetch content from one or more URLs.",
|
"description": "Fetch content from one or more URLs.",
|
||||||
"icon": "layout-template",
|
"icon": "layout-template",
|
||||||
"base_classes": ["Record"],
|
"base_classes": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"display_name": "URL",
|
"display_name": "URL",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"urls": null
|
"urls": null
|
||||||
},
|
},
|
||||||
"output_types": ["Record"],
|
"output_types": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -795,7 +859,10 @@
|
||||||
"name": "input_value",
|
"name": "input_value",
|
||||||
"display_name": "Value",
|
"display_name": "Value",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Record", "Text"],
|
"input_types": [
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "Text or Record to be passed as input.",
|
"info": "Text or Record to be passed as input.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -819,20 +886,28 @@
|
||||||
"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.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Get text inputs from the Playground.",
|
"description": "Get text inputs from the Playground.",
|
||||||
"icon": "type",
|
"icon": "type",
|
||||||
"base_classes": ["object", "Text", "str"],
|
"base_classes": [
|
||||||
|
"object",
|
||||||
|
"Text",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"display_name": "Instructions",
|
"display_name": "Instructions",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"input_value": null,
|
"input_value": null,
|
||||||
"record_template": null
|
"record_template": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -861,11 +936,18 @@
|
||||||
"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"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["Record"],
|
"baseClasses": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"dataType": "URL",
|
"dataType": "URL",
|
||||||
"id": "URL-HYPkR"
|
"id": "URL-HYPkR"
|
||||||
}
|
}
|
||||||
|
|
@ -885,11 +967,17 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "ChatOutput-JPlxl",
|
"id": "ChatOutput-JPlxl",
|
||||||
"inputTypes": ["Text"],
|
"inputTypes": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["str", "Text", "object"],
|
"baseClasses": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"dataType": "OpenAIModel",
|
"dataType": "OpenAIModel",
|
||||||
"id": "OpenAIModel-gi29P"
|
"id": "OpenAIModel-gi29P"
|
||||||
}
|
}
|
||||||
|
|
@ -909,11 +997,18 @@
|
||||||
"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"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["Record"],
|
"baseClasses": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"dataType": "URL",
|
"dataType": "URL",
|
||||||
"id": "URL-2cX90"
|
"id": "URL-2cX90"
|
||||||
}
|
}
|
||||||
|
|
@ -933,11 +1028,20 @@
|
||||||
"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"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["object", "Text", "str"],
|
"baseClasses": [
|
||||||
|
"object",
|
||||||
|
"Text",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"dataType": "TextInput",
|
"dataType": "TextInput",
|
||||||
"id": "TextInput-og8Or"
|
"id": "TextInput-og8Or"
|
||||||
}
|
}
|
||||||
|
|
@ -957,11 +1061,17 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "OpenAIModel-gi29P",
|
"id": "OpenAIModel-gi29P",
|
||||||
"inputTypes": ["Text"],
|
"inputTypes": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["object", "Text", "str"],
|
"baseClasses": [
|
||||||
|
"object",
|
||||||
|
"Text",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"dataType": "Prompt",
|
"dataType": "Prompt",
|
||||||
"id": "Prompt-Rse03"
|
"id": "Prompt-Rse03"
|
||||||
}
|
}
|
||||||
|
|
@ -984,4 +1094,4 @@
|
||||||
"name": "Blog Writer",
|
"name": "Blog Writer",
|
||||||
"last_tested_version": "1.0.0a0",
|
"last_tested_version": "1.0.0a0",
|
||||||
"is_component": false
|
"is_component": false
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +45,9 @@
|
||||||
"name": "template",
|
"name": "template",
|
||||||
"display_name": "Template",
|
"display_name": "Template",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -110,14 +112,23 @@
|
||||||
"is_input": null,
|
"is_input": null,
|
||||||
"is_output": null,
|
"is_output": null,
|
||||||
"is_composition": null,
|
"is_composition": null,
|
||||||
"base_classes": ["object", "str", "Text"],
|
"base_classes": [
|
||||||
|
"object",
|
||||||
|
"str",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"name": "",
|
"name": "",
|
||||||
"display_name": "Prompt",
|
"display_name": "Prompt",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"template": ["Document", "Question"]
|
"template": [
|
||||||
|
"Document",
|
||||||
|
"Question"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"full_path": null,
|
"full_path": null,
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
|
|
@ -220,14 +231,18 @@
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "A generic file loader.",
|
"description": "A generic file loader.",
|
||||||
"base_classes": ["Record"],
|
"base_classes": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"display_name": "Files",
|
"display_name": "Files",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"path": null,
|
"path": null,
|
||||||
"silent_errors": null
|
"silent_errors": null
|
||||||
},
|
},
|
||||||
"output_types": ["Record"],
|
"output_types": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -323,7 +338,10 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
"options": ["Machine", "User"],
|
"options": [
|
||||||
|
"Machine",
|
||||||
|
"User"
|
||||||
|
],
|
||||||
"name": "sender",
|
"name": "sender",
|
||||||
"display_name": "Sender Type",
|
"display_name": "Sender Type",
|
||||||
"advanced": true,
|
"advanced": true,
|
||||||
|
|
@ -331,7 +349,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"sender_name": {
|
"sender_name": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -351,7 +371,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"session_id": {
|
"session_id": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -370,13 +392,20 @@
|
||||||
"info": "If provided, the message will be stored in the memory.",
|
"info": "If provided, the message will be stored in the memory.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Get chat inputs from the Playground.",
|
"description": "Get chat inputs from the Playground.",
|
||||||
"icon": "ChatInput",
|
"icon": "ChatInput",
|
||||||
"base_classes": ["str", "Record", "Text", "object"],
|
"base_classes": [
|
||||||
|
"str",
|
||||||
|
"Record",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"display_name": "Chat Input",
|
"display_name": "Chat Input",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -386,7 +415,10 @@
|
||||||
"session_id": null,
|
"session_id": null,
|
||||||
"return_record": null
|
"return_record": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text", "Record"],
|
"output_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -445,7 +477,9 @@
|
||||||
"name": "input_value",
|
"name": "input_value",
|
||||||
"display_name": "Message",
|
"display_name": "Message",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -481,7 +515,10 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
"options": ["Machine", "User"],
|
"options": [
|
||||||
|
"Machine",
|
||||||
|
"User"
|
||||||
|
],
|
||||||
"name": "sender",
|
"name": "sender",
|
||||||
"display_name": "Sender Type",
|
"display_name": "Sender Type",
|
||||||
"advanced": true,
|
"advanced": true,
|
||||||
|
|
@ -489,7 +526,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"sender_name": {
|
"sender_name": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -509,7 +548,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"session_id": {
|
"session_id": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -528,13 +569,20 @@
|
||||||
"info": "If provided, the message will be stored in the memory.",
|
"info": "If provided, the message will be stored in the memory.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Display a chat message in the Playground.",
|
"description": "Display a chat message in the Playground.",
|
||||||
"icon": "ChatOutput",
|
"icon": "ChatOutput",
|
||||||
"base_classes": ["str", "Record", "Text", "object"],
|
"base_classes": [
|
||||||
|
"str",
|
||||||
|
"Record",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"display_name": "Chat Output",
|
"display_name": "Chat Output",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -544,7 +592,10 @@
|
||||||
"session_id": null,
|
"session_id": null,
|
||||||
"return_record": null
|
"return_record": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text", "Record"],
|
"output_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -589,7 +640,10 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"code": {
|
"code": {
|
||||||
"type": "code",
|
"type": "code",
|
||||||
|
|
@ -598,7 +652,7 @@
|
||||||
"list": false,
|
"list": false,
|
||||||
"show": true,
|
"show": true,
|
||||||
"multiline": true,
|
"multiline": true,
|
||||||
"value": "from typing import Optional\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 NestedDict, Text\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n field_order = [\n \"max_tokens\",\n \"model_kwargs\",\n \"model_name\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"temperature\",\n \"input_value\",\n \"system_message\",\n \"stream\",\n ]\n\n def build_config(self):\n return {\n \"input_value\": {\"display_name\": \"Input\"},\n \"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 \"model_kwargs\": {\n \"display_name\": \"Model Kwargs\",\n \"advanced\": True,\n },\n \"model_name\": {\n \"display_name\": \"Model Name\",\n \"advanced\": False,\n \"options\": MODEL_NAMES,\n },\n \"openai_api_base\": {\n \"display_name\": \"OpenAI API Base\",\n \"advanced\": True,\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 \"info\": \"The OpenAI API Key to use for the OpenAI model.\",\n \"advanced\": False,\n \"password\": True,\n },\n \"temperature\": {\n \"display_name\": \"Temperature\",\n \"advanced\": False,\n \"value\": 0.1,\n },\n \"stream\": {\n \"display_name\": \"Stream\",\n \"info\": STREAM_INFO_TEXT,\n \"advanced\": True,\n },\n \"system_message\": {\n \"display_name\": \"System Message\",\n \"info\": \"System message to pass to the model.\",\n \"advanced\": True,\n },\n }\n\n def build(\n self,\n input_value: Text,\n openai_api_key: str,\n temperature: float = 0.1,\n model_name: str = \"gpt-4o\",\n max_tokens: Optional[int] = 256,\n model_kwargs: NestedDict = {},\n openai_api_base: Optional[str] = None,\n stream: bool = False,\n system_message: Optional[str] = None,\n ) -> Text:\n if not openai_api_base:\n openai_api_base = \"https://api.openai.com/v1\"\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n\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,\n )\n\n return self.get_chat_result(output, stream, input_value, system_message)\n",
|
"value": "from typing import Optional\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 NestedDict, Text\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n field_order = [\n \"max_tokens\",\n \"model_kwargs\",\n \"model_name\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"temperature\",\n \"input_value\",\n \"system_message\",\n \"stream\",\n ]\n\n def build_config(self):\n return {\n \"input_value\": {\"display_name\": \"Input\", \"input_types\": [\"Text\", \"Record\"]},\n \"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 \"model_kwargs\": {\n \"display_name\": \"Model Kwargs\",\n \"advanced\": True,\n },\n \"model_name\": {\n \"display_name\": \"Model Name\",\n \"advanced\": False,\n \"options\": MODEL_NAMES,\n },\n \"openai_api_base\": {\n \"display_name\": \"OpenAI API Base\",\n \"advanced\": True,\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 \"info\": \"The OpenAI API Key to use for the OpenAI model.\",\n \"advanced\": False,\n \"password\": True,\n },\n \"temperature\": {\n \"display_name\": \"Temperature\",\n \"advanced\": False,\n \"value\": 0.1,\n },\n \"stream\": {\n \"display_name\": \"Stream\",\n \"info\": STREAM_INFO_TEXT,\n \"advanced\": True,\n },\n \"system_message\": {\n \"display_name\": \"System Message\",\n \"info\": \"System message to pass to the model.\",\n \"advanced\": True,\n },\n }\n\n def build(\n self,\n input_value: Text,\n openai_api_key: str,\n temperature: float = 0.1,\n model_name: str = \"gpt-4o\",\n max_tokens: Optional[int] = 256,\n model_kwargs: NestedDict = {},\n openai_api_base: Optional[str] = None,\n stream: bool = False,\n system_message: Optional[str] = None,\n ) -> Text:\n if not openai_api_base:\n openai_api_base = \"https://api.openai.com/v1\"\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n\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,\n )\n\n return self.get_chat_result(output, stream, input_value, system_message)\n",
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
|
|
@ -672,7 +726,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"openai_api_base": {
|
"openai_api_base": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -691,7 +747,9 @@
|
||||||
"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.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"openai_api_key": {
|
"openai_api_key": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -710,7 +768,9 @@
|
||||||
"info": "The OpenAI API Key to use for the OpenAI model.",
|
"info": "The OpenAI API Key to use for the OpenAI model.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"value": "OPENAI_API_KEY"
|
"value": "OPENAI_API_KEY"
|
||||||
},
|
},
|
||||||
"stream": {
|
"stream": {
|
||||||
|
|
@ -749,7 +809,9 @@
|
||||||
"info": "System message to pass to the model.",
|
"info": "System message to pass to the model.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"temperature": {
|
"temperature": {
|
||||||
"type": "float",
|
"type": "float",
|
||||||
|
|
@ -780,7 +842,11 @@
|
||||||
},
|
},
|
||||||
"description": "Generates text using OpenAI LLMs.",
|
"description": "Generates text using OpenAI LLMs.",
|
||||||
"icon": "OpenAI",
|
"icon": "OpenAI",
|
||||||
"base_classes": ["object", "str", "Text"],
|
"base_classes": [
|
||||||
|
"object",
|
||||||
|
"str",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"display_name": "OpenAI",
|
"display_name": "OpenAI",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -794,7 +860,9 @@
|
||||||
"stream": null,
|
"stream": null,
|
||||||
"system_message": null
|
"system_message": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [
|
"field_order": [
|
||||||
|
|
@ -832,11 +900,21 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "Question",
|
"fieldName": "Question",
|
||||||
"id": "Prompt-tHwPf",
|
"id": "Prompt-tHwPf",
|
||||||
"inputTypes": ["Document", "BaseOutputParser", "Record", "Text"],
|
"inputTypes": [
|
||||||
|
"Document",
|
||||||
|
"BaseOutputParser",
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["str", "Record", "Text", "object"],
|
"baseClasses": [
|
||||||
|
"str",
|
||||||
|
"Record",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"dataType": "ChatInput",
|
"dataType": "ChatInput",
|
||||||
"id": "ChatInput-MsSJ9"
|
"id": "ChatInput-MsSJ9"
|
||||||
}
|
}
|
||||||
|
|
@ -856,11 +934,18 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "Document",
|
"fieldName": "Document",
|
||||||
"id": "Prompt-tHwPf",
|
"id": "Prompt-tHwPf",
|
||||||
"inputTypes": ["Document", "BaseOutputParser", "Record", "Text"],
|
"inputTypes": [
|
||||||
|
"Document",
|
||||||
|
"BaseOutputParser",
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["Record"],
|
"baseClasses": [
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"dataType": "File",
|
"dataType": "File",
|
||||||
"id": "File-6TEsD"
|
"id": "File-6TEsD"
|
||||||
}
|
}
|
||||||
|
|
@ -880,11 +965,17 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "OpenAIModel-Bt067",
|
"id": "OpenAIModel-Bt067",
|
||||||
"inputTypes": ["Text"],
|
"inputTypes": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["object", "str", "Text"],
|
"baseClasses": [
|
||||||
|
"object",
|
||||||
|
"str",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dataType": "Prompt",
|
"dataType": "Prompt",
|
||||||
"id": "Prompt-tHwPf"
|
"id": "Prompt-tHwPf"
|
||||||
}
|
}
|
||||||
|
|
@ -904,11 +995,17 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "ChatOutput-F5Awj",
|
"id": "ChatOutput-F5Awj",
|
||||||
"inputTypes": ["Text"],
|
"inputTypes": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["object", "str", "Text"],
|
"baseClasses": [
|
||||||
|
"object",
|
||||||
|
"str",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dataType": "OpenAIModel",
|
"dataType": "OpenAIModel",
|
||||||
"id": "OpenAIModel-Bt067"
|
"id": "OpenAIModel-Bt067"
|
||||||
}
|
}
|
||||||
|
|
@ -930,4 +1027,4 @@
|
||||||
"name": "Document QA",
|
"name": "Document QA",
|
||||||
"last_tested_version": "1.0.0a0",
|
"last_tested_version": "1.0.0a0",
|
||||||
"is_component": false
|
"is_component": false
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +83,10 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
"options": ["Machine", "User"],
|
"options": [
|
||||||
|
"Machine",
|
||||||
|
"User"
|
||||||
|
],
|
||||||
"name": "sender",
|
"name": "sender",
|
||||||
"display_name": "Sender Type",
|
"display_name": "Sender Type",
|
||||||
"advanced": true,
|
"advanced": true,
|
||||||
|
|
@ -91,7 +94,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"sender_name": {
|
"sender_name": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -111,7 +116,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"session_id": {
|
"session_id": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -130,14 +137,21 @@
|
||||||
"info": "If provided, the message will be stored in the memory.",
|
"info": "If provided, the message will be stored in the memory.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"value": "MySessionID"
|
"value": "MySessionID"
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Get chat inputs from the Playground.",
|
"description": "Get chat inputs from the Playground.",
|
||||||
"icon": "ChatInput",
|
"icon": "ChatInput",
|
||||||
"base_classes": ["Text", "object", "Record", "str"],
|
"base_classes": [
|
||||||
|
"Text",
|
||||||
|
"object",
|
||||||
|
"Record",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"display_name": "Chat Input",
|
"display_name": "Chat Input",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -147,7 +161,10 @@
|
||||||
"session_id": null,
|
"session_id": null,
|
||||||
"return_record": null
|
"return_record": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text", "Record"],
|
"output_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -206,7 +223,9 @@
|
||||||
"name": "input_value",
|
"name": "input_value",
|
||||||
"display_name": "Message",
|
"display_name": "Message",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -242,7 +261,10 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
"options": ["Machine", "User"],
|
"options": [
|
||||||
|
"Machine",
|
||||||
|
"User"
|
||||||
|
],
|
||||||
"name": "sender",
|
"name": "sender",
|
||||||
"display_name": "Sender Type",
|
"display_name": "Sender Type",
|
||||||
"advanced": true,
|
"advanced": true,
|
||||||
|
|
@ -250,7 +272,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"sender_name": {
|
"sender_name": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -270,7 +294,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"session_id": {
|
"session_id": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -289,14 +315,21 @@
|
||||||
"info": "If provided, the message will be stored in the memory.",
|
"info": "If provided, the message will be stored in the memory.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"value": "MySessionID"
|
"value": "MySessionID"
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Display a chat message in the Playground.",
|
"description": "Display a chat message in the Playground.",
|
||||||
"icon": "ChatOutput",
|
"icon": "ChatOutput",
|
||||||
"base_classes": ["Text", "object", "Record", "str"],
|
"base_classes": [
|
||||||
|
"Text",
|
||||||
|
"object",
|
||||||
|
"Record",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"display_name": "Chat Output",
|
"display_name": "Chat Output",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -306,7 +339,10 @@
|
||||||
"session_id": null,
|
"session_id": null,
|
||||||
"return_record": null
|
"return_record": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text", "Record"],
|
"output_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -382,7 +418,10 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
"options": ["Ascending", "Descending"],
|
"options": [
|
||||||
|
"Ascending",
|
||||||
|
"Descending"
|
||||||
|
],
|
||||||
"name": "order",
|
"name": "order",
|
||||||
"display_name": "Order",
|
"display_name": "Order",
|
||||||
"advanced": true,
|
"advanced": true,
|
||||||
|
|
@ -390,7 +429,9 @@
|
||||||
"info": "Order of the messages.",
|
"info": "Order of the messages.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"record_template": {
|
"record_template": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -410,7 +451,9 @@
|
||||||
"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.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"sender": {
|
"sender": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -423,7 +466,11 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
"options": ["Machine", "User", "Machine and User"],
|
"options": [
|
||||||
|
"Machine",
|
||||||
|
"User",
|
||||||
|
"Machine and User"
|
||||||
|
],
|
||||||
"name": "sender",
|
"name": "sender",
|
||||||
"display_name": "Sender Type",
|
"display_name": "Sender Type",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
|
|
@ -431,7 +478,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"sender_name": {
|
"sender_name": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -450,7 +499,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"session_id": {
|
"session_id": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -465,7 +516,9 @@
|
||||||
"name": "session_id",
|
"name": "session_id",
|
||||||
"display_name": "Session ID",
|
"display_name": "Session ID",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "Session ID of the chat history.",
|
"info": "Session ID of the chat history.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -476,7 +529,11 @@
|
||||||
},
|
},
|
||||||
"description": "Retrieves stored chat messages given a specific Session ID.",
|
"description": "Retrieves stored chat messages given a specific Session ID.",
|
||||||
"icon": "history",
|
"icon": "history",
|
||||||
"base_classes": ["str", "Text", "object"],
|
"base_classes": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"display_name": "Chat Memory",
|
"display_name": "Chat Memory",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -487,7 +544,9 @@
|
||||||
"order": null,
|
"order": null,
|
||||||
"record_template": null
|
"record_template": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -549,7 +608,9 @@
|
||||||
"name": "template",
|
"name": "template",
|
||||||
"display_name": "Template",
|
"display_name": "Template",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -614,14 +675,23 @@
|
||||||
"is_input": null,
|
"is_input": null,
|
||||||
"is_output": null,
|
"is_output": null,
|
||||||
"is_composition": null,
|
"is_composition": null,
|
||||||
"base_classes": ["Text", "str", "object"],
|
"base_classes": [
|
||||||
|
"Text",
|
||||||
|
"str",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"name": "",
|
"name": "",
|
||||||
"display_name": "Prompt",
|
"display_name": "Prompt",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"template": ["context", "user_message"]
|
"template": [
|
||||||
|
"context",
|
||||||
|
"user_message"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"full_path": null,
|
"full_path": null,
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
|
|
@ -670,7 +740,10 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"code": {
|
"code": {
|
||||||
"type": "code",
|
"type": "code",
|
||||||
|
|
@ -679,7 +752,7 @@
|
||||||
"list": false,
|
"list": false,
|
||||||
"show": true,
|
"show": true,
|
||||||
"multiline": true,
|
"multiline": true,
|
||||||
"value": "from typing import Optional\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 NestedDict, Text\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n field_order = [\n \"max_tokens\",\n \"model_kwargs\",\n \"model_name\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"temperature\",\n \"input_value\",\n \"system_message\",\n \"stream\",\n ]\n\n def build_config(self):\n return {\n \"input_value\": {\"display_name\": \"Input\"},\n \"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 \"model_kwargs\": {\n \"display_name\": \"Model Kwargs\",\n \"advanced\": True,\n },\n \"model_name\": {\n \"display_name\": \"Model Name\",\n \"advanced\": False,\n \"options\": MODEL_NAMES,\n },\n \"openai_api_base\": {\n \"display_name\": \"OpenAI API Base\",\n \"advanced\": True,\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 \"info\": \"The OpenAI API Key to use for the OpenAI model.\",\n \"advanced\": False,\n \"password\": True,\n },\n \"temperature\": {\n \"display_name\": \"Temperature\",\n \"advanced\": False,\n \"value\": 0.1,\n },\n \"stream\": {\n \"display_name\": \"Stream\",\n \"info\": STREAM_INFO_TEXT,\n \"advanced\": True,\n },\n \"system_message\": {\n \"display_name\": \"System Message\",\n \"info\": \"System message to pass to the model.\",\n \"advanced\": True,\n },\n }\n\n def build(\n self,\n input_value: Text,\n openai_api_key: str,\n temperature: float = 0.1,\n model_name: str = \"gpt-4o\",\n max_tokens: Optional[int] = 256,\n model_kwargs: NestedDict = {},\n openai_api_base: Optional[str] = None,\n stream: bool = False,\n system_message: Optional[str] = None,\n ) -> Text:\n if not openai_api_base:\n openai_api_base = \"https://api.openai.com/v1\"\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n\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,\n )\n\n return self.get_chat_result(output, stream, input_value, system_message)\n",
|
"value": "from typing import Optional\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 NestedDict, Text\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n field_order = [\n \"max_tokens\",\n \"model_kwargs\",\n \"model_name\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"temperature\",\n \"input_value\",\n \"system_message\",\n \"stream\",\n ]\n\n def build_config(self):\n return {\n \"input_value\": {\"display_name\": \"Input\", \"input_types\": [\"Text\", \"Record\"]},\n \"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 \"model_kwargs\": {\n \"display_name\": \"Model Kwargs\",\n \"advanced\": True,\n },\n \"model_name\": {\n \"display_name\": \"Model Name\",\n \"advanced\": False,\n \"options\": MODEL_NAMES,\n },\n \"openai_api_base\": {\n \"display_name\": \"OpenAI API Base\",\n \"advanced\": True,\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 \"info\": \"The OpenAI API Key to use for the OpenAI model.\",\n \"advanced\": False,\n \"password\": True,\n },\n \"temperature\": {\n \"display_name\": \"Temperature\",\n \"advanced\": False,\n \"value\": 0.1,\n },\n \"stream\": {\n \"display_name\": \"Stream\",\n \"info\": STREAM_INFO_TEXT,\n \"advanced\": True,\n },\n \"system_message\": {\n \"display_name\": \"System Message\",\n \"info\": \"System message to pass to the model.\",\n \"advanced\": True,\n },\n }\n\n def build(\n self,\n input_value: Text,\n openai_api_key: str,\n temperature: float = 0.1,\n model_name: str = \"gpt-4o\",\n max_tokens: Optional[int] = 256,\n model_kwargs: NestedDict = {},\n openai_api_base: Optional[str] = None,\n stream: bool = False,\n system_message: Optional[str] = None,\n ) -> Text:\n if not openai_api_base:\n openai_api_base = \"https://api.openai.com/v1\"\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n\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,\n )\n\n return self.get_chat_result(output, stream, input_value, system_message)\n",
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
|
|
@ -753,7 +826,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"openai_api_base": {
|
"openai_api_base": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -772,7 +847,9 @@
|
||||||
"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.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"openai_api_key": {
|
"openai_api_key": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -791,7 +868,9 @@
|
||||||
"info": "The OpenAI API Key to use for the OpenAI model.",
|
"info": "The OpenAI API Key to use for the OpenAI model.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"value": "OPENAI_API_KEY"
|
"value": "OPENAI_API_KEY"
|
||||||
},
|
},
|
||||||
"stream": {
|
"stream": {
|
||||||
|
|
@ -830,7 +909,9 @@
|
||||||
"info": "System message to pass to the model.",
|
"info": "System message to pass to the model.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"temperature": {
|
"temperature": {
|
||||||
"type": "float",
|
"type": "float",
|
||||||
|
|
@ -861,7 +942,11 @@
|
||||||
},
|
},
|
||||||
"description": "Generates text using OpenAI LLMs.",
|
"description": "Generates text using OpenAI LLMs.",
|
||||||
"icon": "OpenAI",
|
"icon": "OpenAI",
|
||||||
"base_classes": ["str", "object", "Text"],
|
"base_classes": [
|
||||||
|
"str",
|
||||||
|
"object",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"display_name": "OpenAI",
|
"display_name": "OpenAI",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -875,7 +960,9 @@
|
||||||
"stream": null,
|
"stream": null,
|
||||||
"system_message": null
|
"system_message": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [
|
"field_order": [
|
||||||
|
|
@ -927,7 +1014,10 @@
|
||||||
"name": "input_value",
|
"name": "input_value",
|
||||||
"display_name": "Value",
|
"display_name": "Value",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Record", "Text"],
|
"input_types": [
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "Text or Record to be passed as output.",
|
"info": "Text or Record to be passed as output.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -969,20 +1059,28 @@
|
||||||
"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.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Display a text output in the Playground.",
|
"description": "Display a text output in the Playground.",
|
||||||
"icon": "type",
|
"icon": "type",
|
||||||
"base_classes": ["str", "object", "Text"],
|
"base_classes": [
|
||||||
|
"str",
|
||||||
|
"object",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"display_name": "Inspect Memory",
|
"display_name": "Inspect Memory",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"input_value": null,
|
"input_value": null,
|
||||||
"record_template": null
|
"record_template": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -1011,10 +1109,19 @@
|
||||||
"fieldName": "context",
|
"fieldName": "context",
|
||||||
"type": "str",
|
"type": "str",
|
||||||
"id": "Prompt-ODkUx",
|
"id": "Prompt-ODkUx",
|
||||||
"inputTypes": ["Document", "BaseOutputParser", "Record", "Text"]
|
"inputTypes": [
|
||||||
|
"Document",
|
||||||
|
"BaseOutputParser",
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["str", "Text", "object"],
|
"baseClasses": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"dataType": "MemoryComponent",
|
"dataType": "MemoryComponent",
|
||||||
"id": "MemoryComponent-cdA1J"
|
"id": "MemoryComponent-cdA1J"
|
||||||
}
|
}
|
||||||
|
|
@ -1036,10 +1143,20 @@
|
||||||
"fieldName": "user_message",
|
"fieldName": "user_message",
|
||||||
"type": "str",
|
"type": "str",
|
||||||
"id": "Prompt-ODkUx",
|
"id": "Prompt-ODkUx",
|
||||||
"inputTypes": ["Document", "BaseOutputParser", "Record", "Text"]
|
"inputTypes": [
|
||||||
|
"Document",
|
||||||
|
"BaseOutputParser",
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["Text", "object", "Record", "str"],
|
"baseClasses": [
|
||||||
|
"Text",
|
||||||
|
"object",
|
||||||
|
"Record",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"dataType": "ChatInput",
|
"dataType": "ChatInput",
|
||||||
"id": "ChatInput-t7F8v"
|
"id": "ChatInput-t7F8v"
|
||||||
}
|
}
|
||||||
|
|
@ -1060,11 +1177,17 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "OpenAIModel-9RykF",
|
"id": "OpenAIModel-9RykF",
|
||||||
"inputTypes": ["Text"],
|
"inputTypes": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["Text", "str", "object"],
|
"baseClasses": [
|
||||||
|
"Text",
|
||||||
|
"str",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"dataType": "Prompt",
|
"dataType": "Prompt",
|
||||||
"id": "Prompt-ODkUx"
|
"id": "Prompt-ODkUx"
|
||||||
}
|
}
|
||||||
|
|
@ -1084,11 +1207,17 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "ChatOutput-P1jEe",
|
"id": "ChatOutput-P1jEe",
|
||||||
"inputTypes": ["Text"],
|
"inputTypes": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["str", "object", "Text"],
|
"baseClasses": [
|
||||||
|
"str",
|
||||||
|
"object",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dataType": "OpenAIModel",
|
"dataType": "OpenAIModel",
|
||||||
"id": "OpenAIModel-9RykF"
|
"id": "OpenAIModel-9RykF"
|
||||||
}
|
}
|
||||||
|
|
@ -1108,11 +1237,18 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "TextOutput-vrs6T",
|
"id": "TextOutput-vrs6T",
|
||||||
"inputTypes": ["Record", "Text"],
|
"inputTypes": [
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["str", "Text", "object"],
|
"baseClasses": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"dataType": "MemoryComponent",
|
"dataType": "MemoryComponent",
|
||||||
"id": "MemoryComponent-cdA1J"
|
"id": "MemoryComponent-cdA1J"
|
||||||
}
|
}
|
||||||
|
|
@ -1134,4 +1270,4 @@
|
||||||
"name": "Memory Chatbot",
|
"name": "Memory Chatbot",
|
||||||
"last_tested_version": "1.0.0a0",
|
"last_tested_version": "1.0.0a0",
|
||||||
"is_component": false
|
"is_component": false
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +45,9 @@
|
||||||
"name": "template",
|
"name": "template",
|
||||||
"display_name": "Template",
|
"display_name": "Template",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -84,14 +86,22 @@
|
||||||
"is_input": null,
|
"is_input": null,
|
||||||
"is_output": null,
|
"is_output": null,
|
||||||
"is_composition": null,
|
"is_composition": null,
|
||||||
"base_classes": ["object", "str", "Text"],
|
"base_classes": [
|
||||||
|
"object",
|
||||||
|
"str",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"name": "",
|
"name": "",
|
||||||
"display_name": "Prompt",
|
"display_name": "Prompt",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"template": ["document"]
|
"template": [
|
||||||
|
"document"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"full_path": null,
|
"full_path": null,
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
|
|
@ -155,7 +165,9 @@
|
||||||
"name": "template",
|
"name": "template",
|
||||||
"display_name": "Template",
|
"display_name": "Template",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -194,14 +206,22 @@
|
||||||
"is_input": null,
|
"is_input": null,
|
||||||
"is_output": null,
|
"is_output": null,
|
||||||
"is_composition": null,
|
"is_composition": null,
|
||||||
"base_classes": ["object", "str", "Text"],
|
"base_classes": [
|
||||||
|
"object",
|
||||||
|
"str",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"name": "",
|
"name": "",
|
||||||
"display_name": "Prompt",
|
"display_name": "Prompt",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"template": ["summary"]
|
"template": [
|
||||||
|
"summary"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"full_path": null,
|
"full_path": null,
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
|
|
@ -260,7 +280,9 @@
|
||||||
"name": "input_value",
|
"name": "input_value",
|
||||||
"display_name": "Message",
|
"display_name": "Message",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -284,7 +306,9 @@
|
||||||
"info": "In case of Message being a Record, this template will be used to convert it to text.",
|
"info": "In case of Message being a Record, this template will be used to convert it to text.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"return_record": {
|
"return_record": {
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
|
|
@ -316,7 +340,10 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
"options": ["Machine", "User"],
|
"options": [
|
||||||
|
"Machine",
|
||||||
|
"User"
|
||||||
|
],
|
||||||
"name": "sender",
|
"name": "sender",
|
||||||
"display_name": "Sender Type",
|
"display_name": "Sender Type",
|
||||||
"advanced": true,
|
"advanced": true,
|
||||||
|
|
@ -324,7 +351,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"sender_name": {
|
"sender_name": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -344,7 +373,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"session_id": {
|
"session_id": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -363,13 +394,20 @@
|
||||||
"info": "If provided, the message will be stored in the memory.",
|
"info": "If provided, the message will be stored in the memory.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Display a chat message in the Playground.",
|
"description": "Display a chat message in the Playground.",
|
||||||
"icon": "ChatOutput",
|
"icon": "ChatOutput",
|
||||||
"base_classes": ["object", "Record", "Text", "str"],
|
"base_classes": [
|
||||||
|
"object",
|
||||||
|
"Record",
|
||||||
|
"Text",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"display_name": "Chat Output",
|
"display_name": "Chat Output",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -380,7 +418,10 @@
|
||||||
"return_record": null,
|
"return_record": null,
|
||||||
"record_template": null
|
"record_template": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text", "Record"],
|
"output_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -435,7 +476,9 @@
|
||||||
"name": "input_value",
|
"name": "input_value",
|
||||||
"display_name": "Message",
|
"display_name": "Message",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -459,7 +502,9 @@
|
||||||
"info": "In case of Message being a Record, this template will be used to convert it to text.",
|
"info": "In case of Message being a Record, this template will be used to convert it to text.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"return_record": {
|
"return_record": {
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
|
|
@ -491,7 +536,10 @@
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
"options": ["Machine", "User"],
|
"options": [
|
||||||
|
"Machine",
|
||||||
|
"User"
|
||||||
|
],
|
||||||
"name": "sender",
|
"name": "sender",
|
||||||
"display_name": "Sender Type",
|
"display_name": "Sender Type",
|
||||||
"advanced": true,
|
"advanced": true,
|
||||||
|
|
@ -499,7 +547,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"sender_name": {
|
"sender_name": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -519,7 +569,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"session_id": {
|
"session_id": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -538,13 +590,20 @@
|
||||||
"info": "If provided, the message will be stored in the memory.",
|
"info": "If provided, the message will be stored in the memory.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Display a chat message in the Playground.",
|
"description": "Display a chat message in the Playground.",
|
||||||
"icon": "ChatOutput",
|
"icon": "ChatOutput",
|
||||||
"base_classes": ["object", "Record", "Text", "str"],
|
"base_classes": [
|
||||||
|
"object",
|
||||||
|
"Record",
|
||||||
|
"Text",
|
||||||
|
"str"
|
||||||
|
],
|
||||||
"display_name": "Chat Output",
|
"display_name": "Chat Output",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -555,7 +614,10 @@
|
||||||
"return_record": null,
|
"return_record": null,
|
||||||
"record_template": null
|
"record_template": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text", "Record"],
|
"output_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -610,7 +672,10 @@
|
||||||
"name": "input_value",
|
"name": "input_value",
|
||||||
"display_name": "Value",
|
"display_name": "Value",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Record", "Text"],
|
"input_types": [
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "Text or Record to be passed as input.",
|
"info": "Text or Record to be passed as input.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -634,20 +699,28 @@
|
||||||
"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.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Get text inputs from the Playground.",
|
"description": "Get text inputs from the Playground.",
|
||||||
"icon": "type",
|
"icon": "type",
|
||||||
"base_classes": ["str", "Text", "object"],
|
"base_classes": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"display_name": "Text Input",
|
"display_name": "Text Input",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"input_value": null,
|
"input_value": null,
|
||||||
"record_template": null
|
"record_template": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -689,7 +762,10 @@
|
||||||
"name": "input_value",
|
"name": "input_value",
|
||||||
"display_name": "Value",
|
"display_name": "Value",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Record", "Text"],
|
"input_types": [
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "Text or Record to be passed as output.",
|
"info": "Text or Record to be passed as output.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -731,20 +807,28 @@
|
||||||
"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.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Display a text output in the Playground.",
|
"description": "Display a text output in the Playground.",
|
||||||
"icon": "type",
|
"icon": "type",
|
||||||
"base_classes": ["str", "Text", "object"],
|
"base_classes": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"display_name": "First Prompt",
|
"display_name": "First Prompt",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"input_value": null,
|
"input_value": null,
|
||||||
"record_template": null
|
"record_template": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -789,7 +873,10 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"code": {
|
"code": {
|
||||||
"type": "code",
|
"type": "code",
|
||||||
|
|
@ -798,7 +885,7 @@
|
||||||
"list": false,
|
"list": false,
|
||||||
"show": true,
|
"show": true,
|
||||||
"multiline": true,
|
"multiline": true,
|
||||||
"value": "from typing import Optional\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 NestedDict, Text\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n field_order = [\n \"max_tokens\",\n \"model_kwargs\",\n \"model_name\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"temperature\",\n \"input_value\",\n \"system_message\",\n \"stream\",\n ]\n\n def build_config(self):\n return {\n \"input_value\": {\"display_name\": \"Input\"},\n \"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 \"model_kwargs\": {\n \"display_name\": \"Model Kwargs\",\n \"advanced\": True,\n },\n \"model_name\": {\n \"display_name\": \"Model Name\",\n \"advanced\": False,\n \"options\": MODEL_NAMES,\n },\n \"openai_api_base\": {\n \"display_name\": \"OpenAI API Base\",\n \"advanced\": True,\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 \"info\": \"The OpenAI API Key to use for the OpenAI model.\",\n \"advanced\": False,\n \"password\": True,\n },\n \"temperature\": {\n \"display_name\": \"Temperature\",\n \"advanced\": False,\n \"value\": 0.1,\n },\n \"stream\": {\n \"display_name\": \"Stream\",\n \"info\": STREAM_INFO_TEXT,\n \"advanced\": True,\n },\n \"system_message\": {\n \"display_name\": \"System Message\",\n \"info\": \"System message to pass to the model.\",\n \"advanced\": True,\n },\n }\n\n def build(\n self,\n input_value: Text,\n openai_api_key: str,\n temperature: float = 0.1,\n model_name: str = \"gpt-4o\",\n max_tokens: Optional[int] = 256,\n model_kwargs: NestedDict = {},\n openai_api_base: Optional[str] = None,\n stream: bool = False,\n system_message: Optional[str] = None,\n ) -> Text:\n if not openai_api_base:\n openai_api_base = \"https://api.openai.com/v1\"\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n\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,\n )\n\n return self.get_chat_result(output, stream, input_value, system_message)\n",
|
"value": "from typing import Optional\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 NestedDict, Text\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n field_order = [\n \"max_tokens\",\n \"model_kwargs\",\n \"model_name\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"temperature\",\n \"input_value\",\n \"system_message\",\n \"stream\",\n ]\n\n def build_config(self):\n return {\n \"input_value\": {\"display_name\": \"Input\", \"input_types\": [\"Text\", \"Record\"]},\n \"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 \"model_kwargs\": {\n \"display_name\": \"Model Kwargs\",\n \"advanced\": True,\n },\n \"model_name\": {\n \"display_name\": \"Model Name\",\n \"advanced\": False,\n \"options\": MODEL_NAMES,\n },\n \"openai_api_base\": {\n \"display_name\": \"OpenAI API Base\",\n \"advanced\": True,\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 \"info\": \"The OpenAI API Key to use for the OpenAI model.\",\n \"advanced\": False,\n \"password\": True,\n },\n \"temperature\": {\n \"display_name\": \"Temperature\",\n \"advanced\": False,\n \"value\": 0.1,\n },\n \"stream\": {\n \"display_name\": \"Stream\",\n \"info\": STREAM_INFO_TEXT,\n \"advanced\": True,\n },\n \"system_message\": {\n \"display_name\": \"System Message\",\n \"info\": \"System message to pass to the model.\",\n \"advanced\": True,\n },\n }\n\n def build(\n self,\n input_value: Text,\n openai_api_key: str,\n temperature: float = 0.1,\n model_name: str = \"gpt-4o\",\n max_tokens: Optional[int] = 256,\n model_kwargs: NestedDict = {},\n openai_api_base: Optional[str] = None,\n stream: bool = False,\n system_message: Optional[str] = None,\n ) -> Text:\n if not openai_api_base:\n openai_api_base = \"https://api.openai.com/v1\"\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n\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,\n )\n\n return self.get_chat_result(output, stream, input_value, system_message)\n",
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
|
|
@ -872,7 +959,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"openai_api_base": {
|
"openai_api_base": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -891,7 +980,9 @@
|
||||||
"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.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"openai_api_key": {
|
"openai_api_key": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -910,7 +1001,9 @@
|
||||||
"info": "The OpenAI API Key to use for the OpenAI model.",
|
"info": "The OpenAI API Key to use for the OpenAI model.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"value": "OPENAI_API_KEY"
|
"value": "OPENAI_API_KEY"
|
||||||
},
|
},
|
||||||
"stream": {
|
"stream": {
|
||||||
|
|
@ -949,7 +1042,9 @@
|
||||||
"info": "System message to pass to the model.",
|
"info": "System message to pass to the model.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"temperature": {
|
"temperature": {
|
||||||
"type": "float",
|
"type": "float",
|
||||||
|
|
@ -980,7 +1075,11 @@
|
||||||
},
|
},
|
||||||
"description": "Generates text using OpenAI LLMs.",
|
"description": "Generates text using OpenAI LLMs.",
|
||||||
"icon": "OpenAI",
|
"icon": "OpenAI",
|
||||||
"base_classes": ["str", "Text", "object"],
|
"base_classes": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"display_name": "OpenAI",
|
"display_name": "OpenAI",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -994,7 +1093,9 @@
|
||||||
"stream": null,
|
"stream": null,
|
||||||
"system_message": null
|
"system_message": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [
|
"field_order": [
|
||||||
|
|
@ -1046,7 +1147,10 @@
|
||||||
"name": "input_value",
|
"name": "input_value",
|
||||||
"display_name": "Value",
|
"display_name": "Value",
|
||||||
"advanced": false,
|
"advanced": false,
|
||||||
"input_types": ["Record", "Text"],
|
"input_types": [
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
"info": "Text or Record to be passed as output.",
|
"info": "Text or Record to be passed as output.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
|
|
@ -1088,20 +1192,28 @@
|
||||||
"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.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"_type": "CustomComponent"
|
"_type": "CustomComponent"
|
||||||
},
|
},
|
||||||
"description": "Display a text output in the Playground.",
|
"description": "Display a text output in the Playground.",
|
||||||
"icon": "type",
|
"icon": "type",
|
||||||
"base_classes": ["str", "Text", "object"],
|
"base_classes": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"display_name": "Second Prompt",
|
"display_name": "Second Prompt",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
"input_value": null,
|
"input_value": null,
|
||||||
"record_template": null
|
"record_template": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [],
|
"field_order": [],
|
||||||
|
|
@ -1146,7 +1258,10 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text",
|
||||||
|
"Record"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"code": {
|
"code": {
|
||||||
"type": "code",
|
"type": "code",
|
||||||
|
|
@ -1155,7 +1270,7 @@
|
||||||
"list": false,
|
"list": false,
|
||||||
"show": true,
|
"show": true,
|
||||||
"multiline": true,
|
"multiline": true,
|
||||||
"value": "from typing import Optional\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 NestedDict, Text\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n field_order = [\n \"max_tokens\",\n \"model_kwargs\",\n \"model_name\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"temperature\",\n \"input_value\",\n \"system_message\",\n \"stream\",\n ]\n\n def build_config(self):\n return {\n \"input_value\": {\"display_name\": \"Input\"},\n \"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 \"model_kwargs\": {\n \"display_name\": \"Model Kwargs\",\n \"advanced\": True,\n },\n \"model_name\": {\n \"display_name\": \"Model Name\",\n \"advanced\": False,\n \"options\": MODEL_NAMES,\n },\n \"openai_api_base\": {\n \"display_name\": \"OpenAI API Base\",\n \"advanced\": True,\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 \"info\": \"The OpenAI API Key to use for the OpenAI model.\",\n \"advanced\": False,\n \"password\": True,\n },\n \"temperature\": {\n \"display_name\": \"Temperature\",\n \"advanced\": False,\n \"value\": 0.1,\n },\n \"stream\": {\n \"display_name\": \"Stream\",\n \"info\": STREAM_INFO_TEXT,\n \"advanced\": True,\n },\n \"system_message\": {\n \"display_name\": \"System Message\",\n \"info\": \"System message to pass to the model.\",\n \"advanced\": True,\n },\n }\n\n def build(\n self,\n input_value: Text,\n openai_api_key: str,\n temperature: float = 0.1,\n model_name: str = \"gpt-4o\",\n max_tokens: Optional[int] = 256,\n model_kwargs: NestedDict = {},\n openai_api_base: Optional[str] = None,\n stream: bool = False,\n system_message: Optional[str] = None,\n ) -> Text:\n if not openai_api_base:\n openai_api_base = \"https://api.openai.com/v1\"\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n\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,\n )\n\n return self.get_chat_result(output, stream, input_value, system_message)\n",
|
"value": "from typing import Optional\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 NestedDict, Text\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n\n field_order = [\n \"max_tokens\",\n \"model_kwargs\",\n \"model_name\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"temperature\",\n \"input_value\",\n \"system_message\",\n \"stream\",\n ]\n\n def build_config(self):\n return {\n \"input_value\": {\"display_name\": \"Input\", \"input_types\": [\"Text\", \"Record\"]},\n \"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 \"model_kwargs\": {\n \"display_name\": \"Model Kwargs\",\n \"advanced\": True,\n },\n \"model_name\": {\n \"display_name\": \"Model Name\",\n \"advanced\": False,\n \"options\": MODEL_NAMES,\n },\n \"openai_api_base\": {\n \"display_name\": \"OpenAI API Base\",\n \"advanced\": True,\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 \"info\": \"The OpenAI API Key to use for the OpenAI model.\",\n \"advanced\": False,\n \"password\": True,\n },\n \"temperature\": {\n \"display_name\": \"Temperature\",\n \"advanced\": False,\n \"value\": 0.1,\n },\n \"stream\": {\n \"display_name\": \"Stream\",\n \"info\": STREAM_INFO_TEXT,\n \"advanced\": True,\n },\n \"system_message\": {\n \"display_name\": \"System Message\",\n \"info\": \"System message to pass to the model.\",\n \"advanced\": True,\n },\n }\n\n def build(\n self,\n input_value: Text,\n openai_api_key: str,\n temperature: float = 0.1,\n model_name: str = \"gpt-4o\",\n max_tokens: Optional[int] = 256,\n model_kwargs: NestedDict = {},\n openai_api_base: Optional[str] = None,\n stream: bool = False,\n system_message: Optional[str] = None,\n ) -> Text:\n if not openai_api_base:\n openai_api_base = \"https://api.openai.com/v1\"\n if openai_api_key:\n api_key = SecretStr(openai_api_key)\n else:\n api_key = None\n\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,\n )\n\n return self.get_chat_result(output, stream, input_value, system_message)\n",
|
||||||
"fileTypes": [],
|
"fileTypes": [],
|
||||||
"file_path": "",
|
"file_path": "",
|
||||||
"password": false,
|
"password": false,
|
||||||
|
|
@ -1229,7 +1344,9 @@
|
||||||
"info": "",
|
"info": "",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"openai_api_base": {
|
"openai_api_base": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -1248,7 +1365,9 @@
|
||||||
"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.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"openai_api_key": {
|
"openai_api_key": {
|
||||||
"type": "str",
|
"type": "str",
|
||||||
|
|
@ -1267,7 +1386,9 @@
|
||||||
"info": "The OpenAI API Key to use for the OpenAI model.",
|
"info": "The OpenAI API Key to use for the OpenAI model.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"],
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"value": ""
|
"value": ""
|
||||||
},
|
},
|
||||||
"stream": {
|
"stream": {
|
||||||
|
|
@ -1306,7 +1427,9 @@
|
||||||
"info": "System message to pass to the model.",
|
"info": "System message to pass to the model.",
|
||||||
"load_from_db": false,
|
"load_from_db": false,
|
||||||
"title_case": false,
|
"title_case": false,
|
||||||
"input_types": ["Text"]
|
"input_types": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"temperature": {
|
"temperature": {
|
||||||
"type": "float",
|
"type": "float",
|
||||||
|
|
@ -1337,7 +1460,11 @@
|
||||||
},
|
},
|
||||||
"description": "Generates text using OpenAI LLMs.",
|
"description": "Generates text using OpenAI LLMs.",
|
||||||
"icon": "OpenAI",
|
"icon": "OpenAI",
|
||||||
"base_classes": ["str", "Text", "object"],
|
"base_classes": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"display_name": "OpenAI",
|
"display_name": "OpenAI",
|
||||||
"documentation": "",
|
"documentation": "",
|
||||||
"custom_fields": {
|
"custom_fields": {
|
||||||
|
|
@ -1351,7 +1478,9 @@
|
||||||
"stream": null,
|
"stream": null,
|
||||||
"system_message": null
|
"system_message": null
|
||||||
},
|
},
|
||||||
"output_types": ["Text"],
|
"output_types": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"field_formatters": {},
|
"field_formatters": {},
|
||||||
"frozen": false,
|
"frozen": false,
|
||||||
"field_order": [
|
"field_order": [
|
||||||
|
|
@ -1389,11 +1518,20 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "document",
|
"fieldName": "document",
|
||||||
"id": "Prompt-amqBu",
|
"id": "Prompt-amqBu",
|
||||||
"inputTypes": ["Document", "BaseOutputParser", "Record", "Text"],
|
"inputTypes": [
|
||||||
|
"Document",
|
||||||
|
"BaseOutputParser",
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["str", "Text", "object"],
|
"baseClasses": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"dataType": "TextInput",
|
"dataType": "TextInput",
|
||||||
"id": "TextInput-sptaH"
|
"id": "TextInput-sptaH"
|
||||||
}
|
}
|
||||||
|
|
@ -1413,11 +1551,18 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "TextOutput-2MS4a",
|
"id": "TextOutput-2MS4a",
|
||||||
"inputTypes": ["Record", "Text"],
|
"inputTypes": [
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["object", "str", "Text"],
|
"baseClasses": [
|
||||||
|
"object",
|
||||||
|
"str",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dataType": "Prompt",
|
"dataType": "Prompt",
|
||||||
"id": "Prompt-amqBu"
|
"id": "Prompt-amqBu"
|
||||||
}
|
}
|
||||||
|
|
@ -1437,11 +1582,17 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "OpenAIModel-uYXZJ",
|
"id": "OpenAIModel-uYXZJ",
|
||||||
"inputTypes": ["Text"],
|
"inputTypes": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["object", "str", "Text"],
|
"baseClasses": [
|
||||||
|
"object",
|
||||||
|
"str",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dataType": "Prompt",
|
"dataType": "Prompt",
|
||||||
"id": "Prompt-amqBu"
|
"id": "Prompt-amqBu"
|
||||||
}
|
}
|
||||||
|
|
@ -1461,11 +1612,20 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "summary",
|
"fieldName": "summary",
|
||||||
"id": "Prompt-gTNiz",
|
"id": "Prompt-gTNiz",
|
||||||
"inputTypes": ["Document", "BaseOutputParser", "Record", "Text"],
|
"inputTypes": [
|
||||||
|
"Document",
|
||||||
|
"BaseOutputParser",
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["str", "Text", "object"],
|
"baseClasses": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"dataType": "OpenAIModel",
|
"dataType": "OpenAIModel",
|
||||||
"id": "OpenAIModel-uYXZJ"
|
"id": "OpenAIModel-uYXZJ"
|
||||||
}
|
}
|
||||||
|
|
@ -1485,11 +1645,17 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "ChatOutput-EJkG3",
|
"id": "ChatOutput-EJkG3",
|
||||||
"inputTypes": ["Text"],
|
"inputTypes": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["str", "Text", "object"],
|
"baseClasses": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"dataType": "OpenAIModel",
|
"dataType": "OpenAIModel",
|
||||||
"id": "OpenAIModel-uYXZJ"
|
"id": "OpenAIModel-uYXZJ"
|
||||||
}
|
}
|
||||||
|
|
@ -1509,11 +1675,18 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "TextOutput-MUDOR",
|
"id": "TextOutput-MUDOR",
|
||||||
"inputTypes": ["Record", "Text"],
|
"inputTypes": [
|
||||||
|
"Record",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["object", "str", "Text"],
|
"baseClasses": [
|
||||||
|
"object",
|
||||||
|
"str",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dataType": "Prompt",
|
"dataType": "Prompt",
|
||||||
"id": "Prompt-gTNiz"
|
"id": "Prompt-gTNiz"
|
||||||
}
|
}
|
||||||
|
|
@ -1533,11 +1706,17 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "OpenAIModel-XawYB",
|
"id": "OpenAIModel-XawYB",
|
||||||
"inputTypes": ["Text"],
|
"inputTypes": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["object", "str", "Text"],
|
"baseClasses": [
|
||||||
|
"object",
|
||||||
|
"str",
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"dataType": "Prompt",
|
"dataType": "Prompt",
|
||||||
"id": "Prompt-gTNiz"
|
"id": "Prompt-gTNiz"
|
||||||
}
|
}
|
||||||
|
|
@ -1557,11 +1736,17 @@
|
||||||
"targetHandle": {
|
"targetHandle": {
|
||||||
"fieldName": "input_value",
|
"fieldName": "input_value",
|
||||||
"id": "ChatOutput-DNmvg",
|
"id": "ChatOutput-DNmvg",
|
||||||
"inputTypes": ["Text"],
|
"inputTypes": [
|
||||||
|
"Text"
|
||||||
|
],
|
||||||
"type": "str"
|
"type": "str"
|
||||||
},
|
},
|
||||||
"sourceHandle": {
|
"sourceHandle": {
|
||||||
"baseClasses": ["str", "Text", "object"],
|
"baseClasses": [
|
||||||
|
"str",
|
||||||
|
"Text",
|
||||||
|
"object"
|
||||||
|
],
|
||||||
"dataType": "OpenAIModel",
|
"dataType": "OpenAIModel",
|
||||||
"id": "OpenAIModel-XawYB"
|
"id": "OpenAIModel-XawYB"
|
||||||
}
|
}
|
||||||
|
|
@ -1583,4 +1768,4 @@
|
||||||
"name": "Prompt Chaining",
|
"name": "Prompt Chaining",
|
||||||
"last_tested_version": "1.0.0a0",
|
"last_tested_version": "1.0.0a0",
|
||||||
"is_component": false
|
"is_component": false
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -11,10 +11,9 @@ if TYPE_CHECKING:
|
||||||
class TransactionModel(BaseModel):
|
class TransactionModel(BaseModel):
|
||||||
index: Optional[int] = Field(default=None)
|
index: Optional[int] = Field(default=None)
|
||||||
timestamp: Optional[datetime] = Field(default_factory=datetime.now, alias="timestamp")
|
timestamp: Optional[datetime] = Field(default_factory=datetime.now, alias="timestamp")
|
||||||
flow_id: str
|
vertex_id: str
|
||||||
source: str
|
inputs: dict
|
||||||
target: str
|
outputs: dict
|
||||||
target_args: dict
|
|
||||||
status: str
|
status: str
|
||||||
error: Optional[str] = None
|
error: Optional[str] = None
|
||||||
|
|
||||||
|
|
@ -23,13 +22,13 @@ class TransactionModel(BaseModel):
|
||||||
populate_by_name = True
|
populate_by_name = True
|
||||||
|
|
||||||
# validate target_args in case it is a JSON
|
# validate target_args in case it is a JSON
|
||||||
@field_validator("target_args", mode="before")
|
@field_validator("outputs", "inputs", mode="before")
|
||||||
def validate_target_args(cls, v):
|
def validate_target_args(cls, v):
|
||||||
if isinstance(v, str):
|
if isinstance(v, str):
|
||||||
return json.loads(v)
|
return json.loads(v)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
@field_serializer("target_args")
|
@field_serializer("outputs", "inputs")
|
||||||
def serialize_target_args(v):
|
def serialize_target_args(v):
|
||||||
if isinstance(v, dict):
|
if isinstance(v, dict):
|
||||||
return json.dumps(v)
|
return json.dumps(v)
|
||||||
|
|
@ -39,10 +38,9 @@ class TransactionModel(BaseModel):
|
||||||
class TransactionModelResponse(BaseModel):
|
class TransactionModelResponse(BaseModel):
|
||||||
index: Optional[int] = Field(default=None)
|
index: Optional[int] = Field(default=None)
|
||||||
timestamp: Optional[datetime] = Field(default_factory=datetime.now, alias="timestamp")
|
timestamp: Optional[datetime] = Field(default_factory=datetime.now, alias="timestamp")
|
||||||
flow_id: str
|
vertex_id: str
|
||||||
source: str
|
inputs: dict
|
||||||
target: str
|
outputs: dict
|
||||||
target_args: dict
|
|
||||||
status: str
|
status: str
|
||||||
error: Optional[str] = None
|
error: Optional[str] = None
|
||||||
|
|
||||||
|
|
@ -51,7 +49,7 @@ class TransactionModelResponse(BaseModel):
|
||||||
populate_by_name = True
|
populate_by_name = True
|
||||||
|
|
||||||
# validate target_args in case it is a JSON
|
# validate target_args in case it is a JSON
|
||||||
@field_validator("target_args", mode="before")
|
@field_validator("outputs", "inputs", mode="before")
|
||||||
def validate_target_args(cls, v):
|
def validate_target_args(cls, v):
|
||||||
if isinstance(v, str):
|
if isinstance(v, str):
|
||||||
return json.loads(v)
|
return json.loads(v)
|
||||||
|
|
@ -76,7 +74,6 @@ class MessageModel(BaseModel):
|
||||||
session_id: str
|
session_id: str
|
||||||
message: str
|
message: str
|
||||||
files: list[str] = []
|
files: list[str] = []
|
||||||
artifacts: dict
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
from_attributes = True
|
from_attributes = True
|
||||||
|
|
@ -88,12 +85,6 @@ class MessageModel(BaseModel):
|
||||||
return json.loads(v)
|
return json.loads(v)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
@field_validator("artifacts", mode="before")
|
|
||||||
def validate_target_args(cls, v):
|
|
||||||
if isinstance(v, str):
|
|
||||||
return json.loads(v)
|
|
||||||
return v
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_record(cls, record: "Record", flow_id: Optional[str] = None):
|
def from_record(cls, record: "Record", flow_id: Optional[str] = None):
|
||||||
# first check if the record has all the required fields
|
# first check if the record has all the required fields
|
||||||
|
|
@ -114,12 +105,6 @@ class MessageModel(BaseModel):
|
||||||
class MessageModelResponse(MessageModel):
|
class MessageModelResponse(MessageModel):
|
||||||
index: Optional[int] = Field(default=None)
|
index: Optional[int] = Field(default=None)
|
||||||
|
|
||||||
@field_validator("artifacts", mode="before")
|
|
||||||
def serialize_artifacts(v):
|
|
||||||
if isinstance(v, str):
|
|
||||||
return json.loads(v)
|
|
||||||
return v
|
|
||||||
|
|
||||||
@field_validator("index", mode="before")
|
@field_validator("index", mode="before")
|
||||||
def validate_id(cls, v):
|
def validate_id(cls, v):
|
||||||
if isinstance(v, float):
|
if isinstance(v, float):
|
||||||
|
|
|
||||||
|
|
@ -119,21 +119,16 @@ async def log_message(
|
||||||
sender_name: str,
|
sender_name: str,
|
||||||
message: str,
|
message: str,
|
||||||
session_id: str,
|
session_id: str,
|
||||||
artifacts: Optional[dict] = None,
|
files: Optional[list] = None,
|
||||||
flow_id: Optional[str] = None,
|
flow_id: Optional[str] = None,
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
from langflow.graph.vertex.base import Vertex
|
|
||||||
|
|
||||||
if isinstance(session_id, Vertex):
|
|
||||||
session_id = await session_id.build() # type: ignore
|
|
||||||
|
|
||||||
monitor_service = get_monitor_service()
|
monitor_service = get_monitor_service()
|
||||||
row = {
|
row = {
|
||||||
"sender": sender,
|
"sender": sender,
|
||||||
"sender_name": sender_name,
|
"sender_name": sender_name,
|
||||||
"message": message,
|
"message": message,
|
||||||
"artifacts": artifacts or {},
|
"files": files or [],
|
||||||
"session_id": session_id,
|
"session_id": session_id,
|
||||||
"timestamp": monitor_service.get_timestamp(),
|
"timestamp": monitor_service.get_timestamp(),
|
||||||
"flow_id": flow_id,
|
"flow_id": flow_id,
|
||||||
|
|
@ -190,7 +185,7 @@ def log_transaction(vertex: "Vertex", status, error=None):
|
||||||
data = {
|
data = {
|
||||||
"vertex_id": vertex.id,
|
"vertex_id": vertex.id,
|
||||||
"inputs": clean_params,
|
"inputs": clean_params,
|
||||||
"output": str(vertex.result),
|
"outputs": vertex.result.model_dump_json(),
|
||||||
"timestamp": monitor_service.get_timestamp(),
|
"timestamp": monitor_service.get_timestamp(),
|
||||||
"status": status,
|
"status": status,
|
||||||
"error": error,
|
"error": error,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue