feat: messages nodes implemented but deactivated for now

This commit is contained in:
Gabriel Almeida 2023-04-03 20:49:19 -03:00
commit e0c96b2cbb
3 changed files with 37 additions and 5 deletions

View file

@ -13,10 +13,11 @@ agents:
prompts:
- PromptTemplate
- FewShotPromptTemplate
- ChatPromptTemplate
- SystemMessagePromptTemplate
- AIMessagePromptTemplate
- HumanMessagePromptTemplate
- ZeroShotPrompt
# Wait more tests
# - ChatPromptTemplate
# - SystemMessagePromptTemplate
# - HumanMessagePromptTemplate
llms:
- OpenAI

View file

@ -9,3 +9,24 @@ FORCE_SHOW_FIELDS = [
"max_value_length",
"max_tokens",
]
DEFAULT_PROMPT = """
I want you to act as a naming consultant for new companies.
Here are some examples of good company names:
- search engine, Google
- social media, Facebook
- video sharing, YouTube
The name should be short, catchy and easy to remember.
What is a good name for a company that makes {product}?
"""
SYSTEM_PROMPT = """
You are a helpful assistant that talks casually about life in general.
You are a good listener and you can talk about anything.
"""
HUMAN_PROMPT = "{input}"

View file

@ -2,6 +2,7 @@ from typing import Optional
from langchain.agents.mrkl import prompt
from langflow.template.base import FrontendNode, Template, TemplateField
from langflow.template.constants import DEFAULT_PROMPT, HUMAN_PROMPT, SYSTEM_PROMPT
from langflow.utils.constants import DEFAULT_PYTHON_FUNCTION
from langchain.agents import loading
@ -244,6 +245,15 @@ class PromptFrontendNode(FrontendNode):
def format_field(field: TemplateField, name: Optional[str] = None) -> None:
# if field.field_type == "StringPromptTemplate"
# change it to str
if field.field_type == "StringPromptTemplate":
if field.field_type == "StringPromptTemplate" and "Message" in name:
field.field_type = "str"
field.multiline = True
field.value = HUMAN_PROMPT if "Human" in field.name else SYSTEM_PROMPT
if field.name == "template":
field.value = DEFAULT_PROMPT
if (
"Union" in field.field_type
and "BaseMessagePromptTemplate" in field.field_type
):
field.field_type = "BaseMessagePromptTemplate"