📝 docs(constants.py): add missing documentation for INPUT_KEY_INFO and OUTPUT_KEY_INFO variables
🐛 fix(memories.py): set info field for input_key and output_key fields to provide additional information to users
This commit is contained in:
parent
99be9830ad
commit
c959d7bdd5
2 changed files with 10 additions and 1 deletions
|
|
@ -58,3 +58,7 @@ The base URL of the OpenAI API. Defaults to https://api.openai.com/v1.
|
||||||
|
|
||||||
You can change this to use other APIs like JinaChat, LocalAI and Prem.
|
You can change this to use other APIs like JinaChat, LocalAI and Prem.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
INPUT_KEY_INFO = """The variable to be used as Chat Input when more than one variable is available."""
|
||||||
|
OUTPUT_KEY_INFO = """The variable to be used as Chat Output (e.g. answer in a ConversationalRetrievalChain)"""
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ from typing import Optional
|
||||||
|
|
||||||
from langflow.template.field.base import TemplateField
|
from langflow.template.field.base import TemplateField
|
||||||
from langflow.template.frontend_node.base import FrontendNode
|
from langflow.template.frontend_node.base import FrontendNode
|
||||||
|
from langflow.template.frontend_node.constants import INPUT_KEY_INFO, OUTPUT_KEY_INFO
|
||||||
from langflow.template.template.base import Template
|
from langflow.template.template.base import Template
|
||||||
from langchain.memory.chat_message_histories.postgres import DEFAULT_CONNECTION_STRING
|
from langchain.memory.chat_message_histories.postgres import DEFAULT_CONNECTION_STRING
|
||||||
from langchain.memory.chat_message_histories.mongodb import (
|
from langchain.memory.chat_message_histories.mongodb import (
|
||||||
|
|
@ -70,11 +71,15 @@ class MemoryFrontendNode(FrontendNode):
|
||||||
field.required = False
|
field.required = False
|
||||||
field.show = True
|
field.show = True
|
||||||
field.advanced = False
|
field.advanced = False
|
||||||
if field.name in ["input_key", "output_key"]:
|
if field.name in {"input_key", "output_key"}:
|
||||||
field.required = False
|
field.required = False
|
||||||
field.show = True
|
field.show = True
|
||||||
field.advanced = False
|
field.advanced = False
|
||||||
field.value = ""
|
field.value = ""
|
||||||
|
field.info = (
|
||||||
|
INPUT_KEY_INFO if field.name == "input_key" else OUTPUT_KEY_INFO
|
||||||
|
)
|
||||||
|
|
||||||
if field.name == "memory_key":
|
if field.name == "memory_key":
|
||||||
field.value = "chat_history"
|
field.value = "chat_history"
|
||||||
if field.name == "chat_memory":
|
if field.name == "chat_memory":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue