Merge branch 'main' into dev

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-06-24 07:41:29 -07:00 committed by GitHub
commit bc334ca638
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 4849 additions and 7997 deletions

View file

@ -2,6 +2,7 @@ import ThemedImage from "@theme/ThemedImage";
import useBaseUrl from "@docusaurus/useBaseUrl";
import ZoomableImage from "/src/theme/ZoomableImage.js";
import ReactPlayer from "react-player";
import Admonition from "@theme/Admonition";
# Prompt Customization

View file

@ -32,7 +32,7 @@ Pipx can fetch the missing Python version for you with `--fetch-missing-python`,
## Having a problem?
If you encounter a problem, see [Common Installation Issues](/migration/possible-installation-issues).
If you encounter a problem, see [Common Installation Issues](/getting-started/possible-installation-issues).
To get help in the Langflow CLI:

View file

@ -102,7 +102,7 @@ You can now connect Output components to any other component (that has a Text ou
Langflow 1.0 allows you to rename and edit the description of each component, making it easier to understand and interact with the flow. Learn how to customize your component names and descriptions for improved clarity.
[Learn more about Component Descriptions](../getting-started/workspace#component-parameters)
[Learn more about Component Descriptions](../getting-started/workspace#flows--components)
## Passing Tweaks and Inputs in the API

View file

@ -1,96 +1,184 @@
import ZoomableImage from "/src/theme/ZoomableImage.js";
# A new chapter for Langflow
# First things first
## First things first
**Thank you all for being part of the Langflow community**. The journey so far has been amazing and we are happy to have you with us.
**Thank you all for being part of the Langflow community**. The journey so far has been amazing, and we are thrilled to have you with us.
We have some exciting news to share with you. Langflow is changing, and we want to tell you all about it.
We have some exciting news to share with you. Langflow is evolving, and we want to tell you all about it!
## Where have we been?
## What's new?
We spent the last few months working on a new version of Langflow. We wanted to make it more powerful, more flexible, and easier to use.
We're moving from version 0.6 straight to 1.0 (preview). This is a big change, and we want to explain why we're doing it and what it means for you.
In the past year, we learned a lot from the community and our users. We saw the potential of Langflow and the need for a visual, interactive platform for building conversational AI applications (and beyond). You thought us the importance of a platform that is easy to use, but also powerful and controllable, and that made clear to us how Langflow's transparency could be improved.
## Why?
Below are some of the new features we included to make that happen!
In the past year, we learned a lot from the community and our users. We saw the potential of Langflow and the need for a more powerful and flexible tool for building conversational AI applications (and beyond).
We realized that Langflow was hiding things from you that would really help you build better and more complex conversational AI applications. So we decided to make a big change.
### Same Component, Multiple Outputs
## The only way to go is forward
Components can now have more than a single output, allowing for unique flexibility in creating complex flows. The game-changer is output routing — it allows for so many new capabilities its almost silly to describe!
From all the people we talked to, we learned that the most important thing for (most of) them is to have a tool that is easy to use, but also powerful and controllable. They also told us that Langflow's transparency could be improved.
1. Branch to one or more subsequent components;
2. Apply logic operations like if/else and exploit decision-making;
3. Create classification models that choose between paths;
4. Enable the development of agent architectures from scratch;
5. Build an orchestrator that routes between agents.
In those points, we saw an opportunity to make Langflow much more powerful and flexible, while also making it easier to use and understand.
<ZoomableImage
alt="Multiple Outputs"
sources={{
light: "/img/multiple_outputs.webp",
dark: "/img/multiple_outputs.webp",
}}
style={{ width: "80%", margin: "20px auto" }}
/>
One key change you'll notice is that projects now require you to define Inputs and Outputs.
This is a big change, but it's also a big improvement.
It allows you to define the structure of your conversation and the data that flows through it.
This makes it easier to understand and control your conversation.
### Flow + Composition
This change comes with a new way of visualizing your projects. Before 1.0 you would connect Components to ultimately build one final Component that was processed behind the scenes.
Now, each step of the process is defined by you, is visible on the workspace, and can be monitored and controlled by you. This makes it so that Composition is now just another way of building in Langflow. **Now data flows through your project more transparently**.
One key change you'll notice is that projects now require you to define **Inputs** and **Outputs**. They allow you to define the structure of your conversation and how data flows through it. This change comes with a new way of visualizing your projects.
The caveat is existing projects may need some new Components to get them back to their full functionality.
[We've made this as easy as possible](../migration/compatibility), and there will be improvements to it as we get feedback in our Discord server and on GitHub.
Before 1.0 you would connect components to ultimately build one final component that was processed behind the scenes. Now, each step of the process is defined by you, is visible on the workspace, and can be monitored and controlled.
## Custom Interactions
This makes it so that composition is now just **another way** of building in Langflow and **data flows through your project more transparently**. This means that the easy stuff is *really* easy and the complex parts are still possible!
The moment we decided to make this change, we saw the potential to make Langflow even more yours.
By having a clear definition of Inputs and Outputs, we could build the experience around that which led us to create the **Playground**.
- **Flow:** Data is processed by one component and then passed to the next component in line for immediate execution.
- **Composition**: Allows components to not only forward data but also share states for modular building.
When building a project testing and debugging is crucial. The Playground is a tool that changes dynamically based on the Inputs and Outputs you defined in your project.
For example, a flow can sequentially process text, and after a few steps, trigger an agent. It can access functions that wait to be called or to respond. This blend of flow and composition brings an unprecedented level of flexibility and control to data workflows in LLM-based apps and agents that use multiple models and APIs working together to achieve tasks.
For example, let's say you are building a simple RAG application. Generally, you have an Input, some references that come from a Vector Store Search, a Prompt and the answer.
Now, you could plug the output of your Prompt into a [Text Output](../components/inputs-and-outputs), rename that to "Prompt Result" and see the output of your Prompt in the Playground.
<ZoomableImage
alt="Flow + Composition"
sources={{
light: "/img/flow-composition.webp",
dark: "/img/flow-composition.webp",
}}
style={{ width: "80%", margin: "20px auto" }}
/>
{/* Add image here of the described above */}
### Memory Management
This is just one example of how the Playground can help you build and debug your projects.
Langflow 1.0 natively allows every chat message to be stored, and a single flow can have multiple memory sessions. This enables you to create multiple “memories” for agents to store and recall specific information as needed.
We have many planned features for the Playground, and we're excited to see how you use it and what you think of it.
You can edit and remove previous messages to inspect and validate a models response behavior. Control, explore, and manage conversation histories to get your models acting just right.
## An easier start
<ZoomableImage
alt="Playground"
sources={{
light: "/img/playground.png",
dark: "/img/playground.png",
}}
style={{ width: "80%", margin: "20px auto" }}
/>
The experience for the first-time user is also something we wanted to improve.
### Component Freeze 🥶
Meet the new and improved **New Project** screen. It's now easier to start a new project, and you can choose from a list of starter projects to get you started.
Component output freezing is back in Langflow, and its cooler than ever!
{/* Add new project image */}
Once a component runs, you can now lock its previous output state to prevent it from re-running.
We wanted to create start projects that would help you learn about new features and also give you a head start on your projects.
Avoid spending extra tokens and remove repetition when output should be constant — plus it's great for debugging and prototyping!
<ZoomableImage
alt="Component Freeze"
sources={{
light: "/img/component-freeze.jpeg",
dark: "/img/component-freeze.jpeg",
}}
style={{ width: "80%", margin: "20px auto" }}
/>
### Output Preview
Each component now includes an output visualizer that opens a pop-up screen, allowing you to easily inspect and monitor transmissions between components. It provides instant feedback on your workflows, letting you see results as they are processed. 🔍
<ZoomableImage
alt="Output Preview"
sources={{
light: "/img/output-preview.gif",
dark: "/img/output-preview.gif",
}}
style={{ width: "80%", margin: "20px auto" }}
/>
### Inputs and Outputs Handling
Inputs and outputs finally make more sense to us, and hopefully to you too.
Were proposing Langflow-native types to keep things consistent, but not limited to use any Python type. For instance, a Chat Input component sends out what we call a Message object (text + metadata like date, time, and sender), but maybe you want to introduce external types from your favorite Python package? Go wild. Each native type will have their own visualization modes and will evolve according to new integrations added.
### Custom Endpoint Name
Now you can pick a custom name for your endpoint used to call your flow from the API.
<ZoomableImage
alt="Custom Endpoint Name"
sources={{
light: "/img/custom-endpoint.webp",
dark: "/img/custom-endpoint.webp",
}}
style={{ width: "80%", margin: "20px auto" }}
/>
### Logs & Monitoring
A new logs page has been added! Now, both component executions and message history from the chat can be inspected in an interactive table. This will make it easier to debug, inspect, and manage messages passing through components.
<ZoomableImage
alt="Logs and Monitoring"
sources={{
light: "img/logs-monitoring.webp",
dark: "img/logs-monitoring.webp",
}}
style={{ width: "80%", margin: "20px auto" }}
/>
### Folders 📁
We introduced folders on the home page to help categorize flows and components. Create, remove and edit them to keep your work organized.
### Playground
By having a clear definition of Inputs and Outputs, we could build the experience around that, which led us to create the Playground. When building a project, testing and debugging are crucial. The Playground is an interface that changes dynamically based on the Inputs and Outputs you defined in your project.
For example, let's say you are building a simple RAG application. Generally, you have an Input, some references that come from a Vector Store Search, a Prompt, and the answer. Now, you could plug the output of your Prompt into a Text Output, rename that to "Prompt Result," and see the output of your Prompt in the Playground. We have many planned features for the Playground, and we're excited to see how you'll explore it!
### Multi-Modal
Langflow is now multi-modal! It can now handle images and more soon!
<ZoomableImage
alt="Multi Modal"
sources={{
light: "/img/multi-modal.png",
dark: "/img/multi-modal.png",
}}
style={{ width: "80%", margin: "20px auto" }}
/>
Weve also improved project organization, global variables and overall settings, added Python 3.12 compatibility, keyboard shortcuts and a lot of new and fun experimental components!
## An Easier Start
The experience for first-time users is something we wanted to improve. For that we created a couple of Starter Projects. It's now much easier to start a new project, and you can choose from a list of starter projects to get you going.
For now, we have:
- **[Basic Prompting (Hello, World)](/starter-projects/basic-prompting)**: A simple flow that shows you how to use the Prompt Component and how to talk like a pirate.
- **[Vector Store RAG](/tutorials/rag-with-astradb)**: A flow that shows you how to ingest data into a Vector Store and then use it to run a RAG application.
- **[Memory Chatbot](/starter-projects/memory-chatbot)**: This one shows you how to create a simple chatbot that can remember things about the user.
- **[Document QA](/starter-projects/document-qa)**: This flow shows you how to build a simple flow that helps you get answers about a document.
- **[Blog Writer](/starter-projects/blog-writer)**: Shows you how you can expand on the Prompt variables and be creative about what inputs you add to it.
- **Basic Prompting (Hello, World)**: Learn the basics of a Prompt Component.
- **Vector Store RAG**: Ingest data into a Vector Store and then use it to run a RAG application.
- **Memory Chatbot**: Create a simple chatbot that can remember things about the user.
- **Document QA**: Build a simple flow that helps you get answers about a document.
- **Blog Writer**: Expand on the Prompt variables and be creative about what inputs you add to it.
As always, your feedback is invaluable, so please let us know what you think of the new starter projects and what you would like to see in the future.
Please let us know what other starter projects you would like to see in the future!
## Less is more
---
We added many new Components to Langflow and updated some of the existing ones, and we will deprecate some of them.
## What's Next?
The idea is that Langflow has evolved, and we want to make sure that the Components you use are the best they can be.
Some of them don't work well with the others, and some of them are just not needed anymore.
Langflow has gone through a big change, and we are excited to see how you use it and what you think of it. We plan to add more types of Input and Output like Image and Audio, and we also plan to add more Components to help you build more complex projects.
We are working on a list of Components that will be deprecated.
In the preview stages of 1.0, we will have a smaller list of Components so that we make sure that the ones we have are the best they can be.
Regardless, community feedback is very important in this matter, so please let us know what you think of the new Components and which ones you miss.
We are excited to see the community embracing Langflow as their number one AI builder and eagerly wait to see what new inspiring projects will come out of this release! A big thanks to everyone who's supporting or being part of this community in any way. ✨
We are aiming at having a more stable and reliable set of Components that helps you get quickly to useful results.
This also means that your contributions in the [Langflow Store](https://langflow.store) and throughout the community are more important than ever.
Sincerely,
## What's next?
Langflow went through a big change, and we are excited to see how you use it and what you think of it.
We plan to add more types of Input and Output like Image and Audio, and we also plan to add more Components to help you build more complex projects.
We also have some experimental features like a State Management System (so cool!) and a new way of building Grouped Components that we are excited to show you.
## Reach out
One last time, we want to thank you for being part of the Langflow community. Your feedback is invaluable, and we want to hear from you.
**The Langflow Team 🚀**

BIN
docs/static/img/component-freeze.jpeg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

BIN
docs/static/img/custom-endpoint.webp vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
docs/static/img/flow-composition.webp vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

BIN
docs/static/img/logs-monitoring.webp vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
docs/static/img/multi-modal.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
docs/static/img/multiple_outputs.webp vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
docs/static/img/output-preview.gif vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 MiB

BIN
docs/static/img/playground.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 KiB

View file

@ -2,11 +2,10 @@
"data": {
"edges": [
{
"className": "",
"data": {
"sourceHandle": {
"dataType": "ChatInput",
"id": "ChatInput-cIXVH",
"id": "ChatInput-pxptT",
"name": "message",
"output_types": [
"Message"
@ -14,7 +13,7 @@
},
"targetHandle": {
"fieldName": "user_input",
"id": "Prompt-Ejl8w",
"id": "Prompt-1S5SU",
"inputTypes": [
"Message",
"Text"
@ -22,18 +21,17 @@
"type": "str"
}
},
"id": "reactflow__edge-ChatInput-cIXVH{œdataTypeœ:œChatInputœ,œidœ:œChatInput-cIXVHœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt-Ejl8w{œfieldNameœ:œuser_inputœ,œidœ:œPrompt-Ejl8wœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}",
"source": "ChatInput-cIXVH",
"sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-cIXVHœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}",
"target": "Prompt-Ejl8w",
"targetHandle": "{œfieldNameœ: œuser_inputœ, œidœ: œPrompt-Ejl8wœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}"
"id": "reactflow__edge-ChatInput-pxptT{œdataTypeœ:œChatInputœ,œidœ:œChatInput-pxptTœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt-1S5SU{œfieldNameœ:œuser_inputœ,œidœ:œPrompt-1S5SUœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}",
"source": "ChatInput-pxptT",
"sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-pxptTœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}",
"target": "Prompt-1S5SU",
"targetHandle": "{œfieldNameœ: œuser_inputœ, œidœ: œPrompt-1S5SUœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}"
},
{
"className": "",
"data": {
"sourceHandle": {
"dataType": "Prompt",
"id": "Prompt-Ejl8w",
"id": "Prompt-1S5SU",
"name": "prompt",
"output_types": [
"Message"
@ -41,25 +39,24 @@
},
"targetHandle": {
"fieldName": "input_value",
"id": "OpenAIModel-FAF7r",
"id": "OpenAIModel-nJXWj",
"inputTypes": [
"Message"
],
"type": "str"
}
},
"id": "reactflow__edge-Prompt-Ejl8w{œdataTypeœ:œPromptœ,œidœ:œPrompt-Ejl8wœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-FAF7r{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-FAF7rœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
"source": "Prompt-Ejl8w",
"sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-Ejl8wœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}",
"target": "OpenAIModel-FAF7r",
"targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-FAF7rœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
"id": "reactflow__edge-Prompt-1S5SU{œdataTypeœ:œPromptœ,œidœ:œPrompt-1S5SUœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-nJXWj{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-nJXWjœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
"source": "Prompt-1S5SU",
"sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-1S5SUœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}",
"target": "OpenAIModel-nJXWj",
"targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-nJXWjœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
},
{
"className": "",
"data": {
"sourceHandle": {
"dataType": "OpenAIModel",
"id": "OpenAIModel-FAF7r",
"id": "OpenAIModel-nJXWj",
"name": "text_output",
"output_types": [
"Message"
@ -67,147 +64,24 @@
},
"targetHandle": {
"fieldName": "input_value",
"id": "ChatOutput-riTzX",
"id": "ChatOutput-XP4bj",
"inputTypes": [
"Message"
],
"type": "str"
}
},
"id": "reactflow__edge-OpenAIModel-FAF7r{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-FAF7rœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-riTzX{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-riTzXœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
"source": "OpenAIModel-FAF7r",
"sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-FAF7rœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}",
"target": "ChatOutput-riTzX",
"targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-riTzXœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
"id": "reactflow__edge-OpenAIModel-nJXWj{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-nJXWjœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-XP4bj{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-XP4bjœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
"source": "OpenAIModel-nJXWj",
"sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-nJXWjœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}",
"target": "ChatOutput-XP4bj",
"targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-XP4bjœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
}
],
"nodes": [
{
"data": {
"description": "Create a prompt template with dynamic variables.",
"display_name": "Prompt",
"edited": false,
"id": "Prompt-Ejl8w",
"node": {
"base_classes": [
"Message"
],
"beta": false,
"conditional_paths": [],
"custom_fields": {
"template": [
"user_input"
]
},
"description": "Create a prompt template with dynamic variables.",
"display_name": "Prompt",
"documentation": "",
"edited": true,
"field_order": [
"template"
],
"frozen": false,
"icon": "prompts",
"output_types": [],
"outputs": [
{
"cache": true,
"display_name": "Prompt Message",
"hidden": false,
"method": "build_prompt",
"name": "prompt",
"selected": "Message",
"types": [
"Message"
],
"value": "__UNDEFINED__"
}
],
"pinned": false,
"template": {
"_type": "Component",
"code": {
"advanced": true,
"dynamic": true,
"fileTypes": [],
"file_path": "",
"info": "",
"list": false,
"load_from_db": false,
"multiline": true,
"name": "code",
"password": false,
"placeholder": "",
"required": true,
"show": true,
"title_case": false,
"type": "code",
"value": "from langflow.base.prompts.api_utils import process_prompt_template\nfrom langflow.custom import Component\nfrom langflow.io import Output, PromptInput\nfrom langflow.schema.message import Message\nfrom langflow.template.utils import update_template_values\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt\"\n description: str = \"Create a prompt template with dynamic variables.\"\n icon = \"prompts\"\n trace_type = \"prompt\"\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt Message\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n async def build_prompt(\n self,\n ) -> Message:\n prompt = await Message.from_template_and_variables(**self._attributes)\n self.status = prompt.text\n return prompt\n\n def post_code_processing(self, new_build_config: dict, current_build_config: dict):\n \"\"\"\n This function is called after the code validation is done.\n \"\"\"\n frontend_node = super().post_code_processing(new_build_config, current_build_config)\n template = frontend_node[\"template\"][\"template\"][\"value\"]\n _ = process_prompt_template(\n template=template,\n name=\"template\",\n custom_fields=frontend_node[\"custom_fields\"],\n frontend_node_template=frontend_node[\"template\"],\n )\n # Now that template is updated, we need to grab any values that were set in the current_build_config\n # and update the frontend_node with those values\n update_template_values(frontend_template=frontend_node, raw_template=current_build_config[\"template\"])\n return frontend_node\n"
},
"template": {
"advanced": false,
"display_name": "Template",
"dynamic": false,
"info": "",
"list": false,
"name": "template",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"type": "prompt",
"value": "Answer the user as if you were a pirate.\n\nUser: {user_input}\n\nAnswer: "
},
"user_input": {
"advanced": false,
"display_name": "user_input",
"dynamic": false,
"field_type": "str",
"fileTypes": [],
"file_path": "",
"info": "",
"input_types": [
"Message",
"Text"
],
"list": false,
"load_from_db": false,
"multiline": true,
"name": "user_input",
"password": false,
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"type": "str",
"value": ""
}
}
},
"type": "Prompt"
},
"dragging": false,
"height": 422,
"id": "Prompt-Ejl8w",
"position": {
"x": 43.70859256635981,
"y": 1115.5304359666682
},
"positionAbsolute": {
"x": 43.70859256635981,
"y": 1115.5304359666682
},
"selected": false,
"type": "genericNode",
"width": 384
},
{
"data": {
"description": "Get chat inputs from the Playground.",
"display_name": "Chat Input",
"edited": false,
"id": "ChatInput-cIXVH",
"id": "ChatInput-pxptT",
"node": {
"base_classes": [
"Message"
@ -218,7 +92,7 @@
"description": "Get chat inputs from the Playground.",
"display_name": "Chat Input",
"documentation": "",
"edited": true,
"edited": false,
"field_order": [
"input_value",
"sender",
@ -262,7 +136,7 @@
"show": true,
"title_case": false,
"type": "code",
"value": "from langflow.base.data.utils import IMG_FILE_TYPES, TEXT_FILE_TYPES\nfrom langflow.base.io.chat import ChatComponent\nfrom langflow.io import DropdownInput, FileInput, MultilineInput, Output, TextInput\nfrom langflow.schema.message import Message\n\n\nclass ChatInput(ChatComponent):\n display_name = \"Chat Input\"\n description = \"Get chat inputs from the Playground.\"\n icon = \"ChatInput\"\n\n inputs = [\n MultilineInput(\n name=\"input_value\",\n display_name=\"Text\",\n value=\"\",\n info=\"Message to be passed as input.\",\n ),\n DropdownInput(\n name=\"sender\",\n display_name=\"Sender Type\",\n options=[\"Machine\", \"User\"],\n value=\"User\",\n info=\"Type of sender.\",\n advanced=True,\n ),\n TextInput(\n name=\"sender_name\",\n display_name=\"Sender Name\",\n info=\"Name of the sender.\",\n value=\"User\",\n advanced=True,\n ),\n TextInput(name=\"session_id\", display_name=\"Session ID\", info=\"Session ID for the message.\", advanced=True),\n FileInput(\n name=\"files\",\n display_name=\"Files\",\n file_types=TEXT_FILE_TYPES + IMG_FILE_TYPES,\n info=\"Files to be sent with the message.\",\n advanced=True,\n is_list=True,\n ),\n ]\n outputs = [\n Output(display_name=\"Message\", name=\"message\", method=\"message_response\"),\n ]\n\n def message_response(self) -> Message:\n message = Message(\n text=self.input_value,\n sender=self.sender,\n sender_name=self.sender_name,\n session_id=self.session_id,\n files=self.files,\n )\n if self.session_id and isinstance(message, Message) and isinstance(message.text, str):\n self.store_message(message)\n self.message.value = message\n\n self.status = message\n return message\n"
"value": "from langflow.base.data.utils import IMG_FILE_TYPES, TEXT_FILE_TYPES\nfrom langflow.base.io.chat import ChatComponent\nfrom langflow.io import DropdownInput, FileInput, MessageTextInput, MultilineInput, Output\nfrom langflow.schema.message import Message\n\n\nclass ChatInput(ChatComponent):\n display_name = \"Chat Input\"\n description = \"Get chat inputs from the Playground.\"\n icon = \"ChatInput\"\n\n inputs = [\n MultilineInput(\n name=\"input_value\",\n display_name=\"Text\",\n value=\"\",\n info=\"Message to be passed as input.\",\n ),\n DropdownInput(\n name=\"sender\",\n display_name=\"Sender Type\",\n options=[\"Machine\", \"User\"],\n value=\"User\",\n info=\"Type of sender.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"sender_name\",\n display_name=\"Sender Name\",\n info=\"Name of the sender.\",\n value=\"User\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"session_id\", display_name=\"Session ID\", info=\"Session ID for the message.\", advanced=True\n ),\n FileInput(\n name=\"files\",\n display_name=\"Files\",\n file_types=TEXT_FILE_TYPES + IMG_FILE_TYPES,\n info=\"Files to be sent with the message.\",\n advanced=True,\n is_list=True,\n ),\n ]\n outputs = [\n Output(display_name=\"Message\", name=\"message\", method=\"message_response\"),\n ]\n\n def message_response(self) -> Message:\n message = Message(\n text=self.input_value,\n sender=self.sender,\n sender_name=self.sender_name,\n session_id=self.session_id,\n files=self.files,\n )\n if self.session_id and isinstance(message, Message) and isinstance(message.text, str):\n self.store_message(message)\n self.message.value = message\n\n self.status = message\n return message\n"
},
"files": {
"advanced": true,
@ -390,14 +264,14 @@
},
"dragging": false,
"height": 308,
"id": "ChatInput-cIXVH",
"id": "ChatInput-pxptT",
"position": {
"x": -521.3324537445985,
"y": 1089.7620993695407
"x": -493.6459512396177,
"y": 1083.200545525551
},
"positionAbsolute": {
"x": -521.3324537445985,
"y": 1089.7620993695407
"x": -493.6459512396177,
"y": 1083.200545525551
},
"selected": false,
"type": "genericNode",
@ -405,10 +279,132 @@
},
{
"data": {
"description": "Generates text using OpenAI LLMs.",
"display_name": "OpenAI",
"edited": false,
"id": "OpenAIModel-FAF7r",
"description": "Create a prompt template with dynamic variables.",
"display_name": "Prompt",
"id": "Prompt-1S5SU",
"node": {
"base_classes": [
"Message"
],
"beta": false,
"conditional_paths": [],
"custom_fields": {
"template": [
"user_input"
]
},
"description": "Create a prompt template with dynamic variables.",
"display_name": "Prompt",
"documentation": "",
"edited": false,
"error": null,
"field_order": [
"template"
],
"frozen": false,
"full_path": null,
"icon": "prompts",
"is_composition": null,
"is_input": null,
"is_output": null,
"name": "",
"output_types": [],
"outputs": [
{
"cache": true,
"display_name": "Prompt Message",
"hidden": false,
"method": "build_prompt",
"name": "prompt",
"selected": "Message",
"types": [
"Message"
],
"value": "__UNDEFINED__"
}
],
"pinned": false,
"template": {
"_type": "Component",
"code": {
"advanced": true,
"dynamic": true,
"fileTypes": [],
"file_path": "",
"info": "",
"list": false,
"load_from_db": false,
"multiline": true,
"name": "code",
"password": false,
"placeholder": "",
"required": true,
"show": true,
"title_case": false,
"type": "code",
"value": "from langflow.base.prompts.api_utils import process_prompt_template\nfrom langflow.custom import Component\nfrom langflow.io import Output, PromptInput\nfrom langflow.schema.message import Message\nfrom langflow.template.utils import update_template_values\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt\"\n description: str = \"Create a prompt template with dynamic variables.\"\n icon = \"prompts\"\n trace_type = \"prompt\"\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt Message\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n async def build_prompt(\n self,\n ) -> Message:\n prompt = await Message.from_template_and_variables(**self._attributes)\n self.status = prompt.text\n return prompt\n\n def post_code_processing(self, new_build_config: dict, current_build_config: dict):\n \"\"\"\n This function is called after the code validation is done.\n \"\"\"\n frontend_node = super().post_code_processing(new_build_config, current_build_config)\n template = frontend_node[\"template\"][\"template\"][\"value\"]\n _ = process_prompt_template(\n template=template,\n name=\"template\",\n custom_fields=frontend_node[\"custom_fields\"],\n frontend_node_template=frontend_node[\"template\"],\n )\n # Now that template is updated, we need to grab any values that were set in the current_build_config\n # and update the frontend_node with those values\n update_template_values(frontend_template=frontend_node, raw_template=current_build_config[\"template\"])\n return frontend_node\n"
},
"template": {
"advanced": false,
"display_name": "Template",
"dynamic": false,
"info": "",
"list": false,
"name": "template",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"type": "prompt",
"value": "Answer the user as if you were a pirate.\n\nUser: {user_input}\n\nAnswer: "
},
"user_input": {
"advanced": false,
"display_name": "user_input",
"dynamic": false,
"field_type": "str",
"fileTypes": [],
"file_path": "",
"info": "",
"input_types": [
"Message",
"Text"
],
"list": false,
"load_from_db": false,
"multiline": true,
"name": "user_input",
"password": false,
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"type": "str",
"value": ""
}
}
},
"type": "Prompt"
},
"dragging": false,
"height": 422,
"id": "Prompt-1S5SU",
"position": {
"x": 56.354011530798516,
"y": 1157.2005405164796
},
"positionAbsolute": {
"x": 56.354011530798516,
"y": 1157.2005405164796
},
"selected": false,
"type": "genericNode",
"width": 384
},
{
"data": {
"id": "OpenAIModel-nJXWj",
"node": {
"base_classes": [
"LanguageModel",
@ -420,7 +416,7 @@
"description": "Generates text using OpenAI LLMs.",
"display_name": "OpenAI",
"documentation": "",
"edited": true,
"edited": false,
"field_order": [
"input_value",
"max_tokens",
@ -668,14 +664,14 @@
},
"dragging": false,
"height": 621,
"id": "OpenAIModel-FAF7r",
"id": "OpenAIModel-nJXWj",
"position": {
"x": 584.9288140250019,
"y": 1149.0790574268922
"x": 624.3539730827923,
"y": 1053.2005475562555
},
"positionAbsolute": {
"x": 584.9288140250019,
"y": 1149.0790574268922
"x": 624.3539730827923,
"y": 1053.2005475562555
},
"selected": false,
"type": "genericNode",
@ -683,10 +679,7 @@
},
{
"data": {
"description": "Display a chat message in the Playground.",
"display_name": "Chat Output",
"edited": false,
"id": "ChatOutput-riTzX",
"id": "ChatOutput-XP4bj",
"node": {
"base_classes": [
"Message"
@ -697,7 +690,7 @@
"description": "Display a chat message in the Playground.",
"display_name": "Chat Output",
"documentation": "",
"edited": true,
"edited": false,
"field_order": [
"input_value",
"sender",
@ -740,7 +733,7 @@
"show": true,
"title_case": false,
"type": "code",
"value": "from langflow.base.io.chat import ChatComponent\nfrom langflow.io import DropdownInput, Output, TextInput\nfrom langflow.schema.message import Message\n\n\nclass ChatOutput(ChatComponent):\n display_name = \"Chat Output\"\n description = \"Display a chat message in the Playground.\"\n icon = \"ChatOutput\"\n\n inputs = [\n TextInput(\n name=\"input_value\",\n display_name=\"Text\",\n info=\"Message to be passed as output.\",\n ),\n DropdownInput(\n name=\"sender\",\n display_name=\"Sender Type\",\n options=[\"Machine\", \"User\"],\n value=\"Machine\",\n advanced=True,\n info=\"Type of sender.\",\n ),\n TextInput(\n name=\"sender_name\", display_name=\"Sender Name\", info=\"Name of the sender.\", value=\"AI\", advanced=True\n ),\n TextInput(name=\"session_id\", display_name=\"Session ID\", info=\"Session ID for the message.\", advanced=True),\n TextInput(\n name=\"data_template\",\n display_name=\"Data Template\",\n value=\"{text}\",\n advanced=True,\n info=\"Template to convert Data to Text. If left empty, it will be dynamically set to the Data's text key.\",\n ),\n ]\n outputs = [\n Output(display_name=\"Message\", name=\"message\", method=\"message_response\"),\n ]\n\n def message_response(self) -> Message:\n message = Message(\n text=self.input_value,\n sender=self.sender,\n sender_name=self.sender_name,\n session_id=self.session_id,\n )\n if self.session_id and isinstance(message, Message) and isinstance(message.text, str):\n self.store_message(message)\n self.message.value = message\n\n self.status = message\n return message\n"
"value": "from langflow.base.io.chat import ChatComponent\nfrom langflow.io import DropdownInput, MessageTextInput, Output\nfrom langflow.schema.message import Message\n\n\nclass ChatOutput(ChatComponent):\n display_name = \"Chat Output\"\n description = \"Display a chat message in the Playground.\"\n icon = \"ChatOutput\"\n\n inputs = [\n MessageTextInput(\n name=\"input_value\",\n display_name=\"Text\",\n info=\"Message to be passed as output.\",\n ),\n DropdownInput(\n name=\"sender\",\n display_name=\"Sender Type\",\n options=[\"Machine\", \"User\"],\n value=\"Machine\",\n advanced=True,\n info=\"Type of sender.\",\n ),\n MessageTextInput(\n name=\"sender_name\", display_name=\"Sender Name\", info=\"Name of the sender.\", value=\"AI\", advanced=True\n ),\n MessageTextInput(\n name=\"session_id\", display_name=\"Session ID\", info=\"Session ID for the message.\", advanced=True\n ),\n MessageTextInput(\n name=\"data_template\",\n display_name=\"Data Template\",\n value=\"{text}\",\n advanced=True,\n info=\"Template to convert Data to Text. If left empty, it will be dynamically set to the Data's text key.\",\n ),\n ]\n outputs = [\n Output(display_name=\"Message\", name=\"message\", method=\"message_response\"),\n ]\n\n def message_response(self) -> Message:\n message = Message(\n text=self.input_value,\n sender=self.sender,\n sender_name=self.sender_name,\n session_id=self.session_id,\n )\n if self.session_id and isinstance(message, Message) and isinstance(message.text, str):\n self.store_message(message)\n self.message.value = message\n\n self.status = message\n return message\n"
},
"data_template": {
"advanced": true,
@ -846,14 +839,14 @@
},
"dragging": false,
"height": 308,
"id": "ChatOutput-riTzX",
"id": "ChatOutput-XP4bj",
"position": {
"x": 1157.3374592784412,
"y": 1160.9424490383622
"x": 1219.477374823274,
"y": 1200.950216973985
},
"positionAbsolute": {
"x": 1157.3374592784412,
"y": 1160.9424490383622
"x": 1219.477374823274,
"y": 1200.950216973985
},
"selected": false,
"type": "genericNode",
@ -861,14 +854,14 @@
}
],
"viewport": {
"x": 382.9033026612555,
"y": -365.74767124549675,
"zoom": 0.5000000338450783
"x": 392.1085223509972,
"y": -327.49805229761307,
"zoom": 0.5000000676901589
}
},
"description": "This flow will get you experimenting with the basics of the UI, the Chat and the Prompt component. \n\nTry changing the Template in it to see how the model behaves. \nYou can change it to this and a Text Input into the `type_of_person` variable : \"Answer the user as if you were a pirate.\n\nUser: {user_input}\n\nAnswer: \" ",
"endpoint_name": null,
"id": "52f28cee-19d7-48c4-ac36-12a6cc32206b",
"id": "f652abdc-7ef2-4e52-a00b-847b7aa32cee",
"is_component": false,
"last_tested_version": "1.0.0rc1",
"name": "Basic Prompting (Hello, World)"

View file

@ -2,11 +2,10 @@
"data": {
"edges": [
{
"className": "",
"data": {
"sourceHandle": {
"dataType": "Memory",
"id": "Memory-A4OPp",
"id": "Memory-uy2TA",
"name": "messages_text",
"output_types": [
"Message"
@ -14,7 +13,7 @@
},
"targetHandle": {
"fieldName": "context",
"id": "Prompt-xhlQ7",
"id": "Prompt-m9rUs",
"inputTypes": [
"Message",
"Text"
@ -22,18 +21,17 @@
"type": "str"
}
},
"id": "reactflow__edge-Memory-A4OPp{œdataTypeœ:œMemoryœ,œidœ:œMemory-A4OPpœ,œnameœ:œmessages_textœ,œoutput_typesœ:[œMessageœ]}-Prompt-xhlQ7{œfieldNameœ:œcontextœ,œidœ:œPrompt-xhlQ7œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}",
"source": "Memory-A4OPp",
"sourceHandle": "{œdataTypeœ: œMemoryœ, œidœ: œMemory-A4OPpœ, œnameœ: œmessages_textœ, œoutput_typesœ: [œMessageœ]}",
"target": "Prompt-xhlQ7",
"targetHandle": "{œfieldNameœ: œcontextœ, œidœ: œPrompt-xhlQ7œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}"
"id": "reactflow__edge-Memory-uy2TA{œdataTypeœ:œMemoryœ,œidœ:œMemory-uy2TAœ,œnameœ:œmessages_textœ,œoutput_typesœ:[œMessageœ]}-Prompt-m9rUs{œfieldNameœ:œcontextœ,œidœ:œPrompt-m9rUsœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}",
"source": "Memory-uy2TA",
"sourceHandle": "{œdataTypeœ: œMemoryœ, œidœ: œMemory-uy2TAœ, œnameœ: œmessages_textœ, œoutput_typesœ: [œMessageœ]}",
"target": "Prompt-m9rUs",
"targetHandle": "{œfieldNameœ: œcontextœ, œidœ: œPrompt-m9rUsœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}"
},
{
"className": "",
"data": {
"sourceHandle": {
"dataType": "ChatInput",
"id": "ChatInput-ENTF8",
"id": "ChatInput-hSTqh",
"name": "message",
"output_types": [
"Message"
@ -41,7 +39,7 @@
},
"targetHandle": {
"fieldName": "user_message",
"id": "Prompt-xhlQ7",
"id": "Prompt-m9rUs",
"inputTypes": [
"Message",
"Text"
@ -49,18 +47,17 @@
"type": "str"
}
},
"id": "reactflow__edge-ChatInput-ENTF8{œdataTypeœ:œChatInputœ,œidœ:œChatInput-ENTF8œ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt-xhlQ7{œfieldNameœ:œuser_messageœ,œidœ:œPrompt-xhlQ7œ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}",
"source": "ChatInput-ENTF8",
"sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-ENTF8œ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}",
"target": "Prompt-xhlQ7",
"targetHandle": "{œfieldNameœ: œuser_messageœ, œidœ: œPrompt-xhlQ7œ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}"
"id": "reactflow__edge-ChatInput-hSTqh{œdataTypeœ:œChatInputœ,œidœ:œChatInput-hSTqhœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt-m9rUs{œfieldNameœ:œuser_messageœ,œidœ:œPrompt-m9rUsœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}",
"source": "ChatInput-hSTqh",
"sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-hSTqhœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}",
"target": "Prompt-m9rUs",
"targetHandle": "{œfieldNameœ: œuser_messageœ, œidœ: œPrompt-m9rUsœ, œinputTypesœ: [œMessageœ, œTextœ], œtypeœ: œstrœ}"
},
{
"className": "",
"data": {
"sourceHandle": {
"dataType": "Prompt",
"id": "Prompt-xhlQ7",
"id": "Prompt-m9rUs",
"name": "prompt",
"output_types": [
"Message"
@ -68,25 +65,24 @@
},
"targetHandle": {
"fieldName": "input_value",
"id": "OpenAIModel-ZBIVC",
"id": "OpenAIModel-WmUtU",
"inputTypes": [
"Message"
],
"type": "str"
}
},
"id": "reactflow__edge-Prompt-xhlQ7{œdataTypeœ:œPromptœ,œidœ:œPrompt-xhlQ7œ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-ZBIVC{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-ZBIVCœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
"source": "Prompt-xhlQ7",
"sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-xhlQ7œ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}",
"target": "OpenAIModel-ZBIVC",
"targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-ZBIVCœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
"id": "reactflow__edge-Prompt-m9rUs{œdataTypeœ:œPromptœ,œidœ:œPrompt-m9rUsœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-WmUtU{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-WmUtUœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
"source": "Prompt-m9rUs",
"sourceHandle": "{œdataTypeœ: œPromptœ, œidœ: œPrompt-m9rUsœ, œnameœ: œpromptœ, œoutput_typesœ: [œMessageœ]}",
"target": "OpenAIModel-WmUtU",
"targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œOpenAIModel-WmUtUœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
},
{
"className": "",
"data": {
"sourceHandle": {
"dataType": "OpenAIModel",
"id": "OpenAIModel-ZBIVC",
"id": "OpenAIModel-WmUtU",
"name": "text_output",
"output_types": [
"Message"
@ -94,27 +90,24 @@
},
"targetHandle": {
"fieldName": "input_value",
"id": "ChatOutput-e8ruq",
"id": "ChatOutput-LIvGN",
"inputTypes": [
"Message"
],
"type": "str"
}
},
"id": "reactflow__edge-OpenAIModel-ZBIVC{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-ZBIVCœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-e8ruq{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-e8ruqœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
"source": "OpenAIModel-ZBIVC",
"sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-ZBIVCœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}",
"target": "ChatOutput-e8ruq",
"targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-e8ruqœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
"id": "reactflow__edge-OpenAIModel-WmUtU{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-WmUtUœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-LIvGN{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-LIvGNœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
"source": "OpenAIModel-WmUtU",
"sourceHandle": "{œdataTypeœ: œOpenAIModelœ, œidœ: œOpenAIModel-WmUtUœ, œnameœ: œtext_outputœ, œoutput_typesœ: [œMessageœ]}",
"target": "ChatOutput-LIvGN",
"targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-LIvGNœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
}
],
"nodes": [
{
"data": {
"description": "Retrieves stored chat messages.",
"display_name": "Memory",
"edited": false,
"id": "Memory-A4OPp",
"id": "Memory-uy2TA",
"node": {
"base_classes": [
"Data",
@ -124,9 +117,9 @@
"conditional_paths": [],
"custom_fields": {},
"description": "Retrieves stored chat messages.",
"display_name": "Memory",
"display_name": "Chat Memory",
"documentation": "",
"edited": true,
"edited": false,
"field_order": [
"sender",
"sender_name",
@ -182,7 +175,7 @@
"show": true,
"title_case": false,
"type": "code",
"value": "from langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DropdownInput, IntInput, MultilineInput, Output, MessageTextInput\nfrom langflow.memory import get_messages\nfrom langflow.schema import Data\nfrom langflow.schema.message import Message\n\n\nclass MemoryComponent(Component):\n display_name = \"Chat Memory\"\n description = \"Retrieves stored chat messages.\"\n icon = \"message-square-more\"\n\n inputs = [\n DropdownInput(\n name=\"sender\",\n display_name=\"Sender Type\",\n options=[\"Machine\", \"User\", \"Machine and User\"],\n value=\"Machine and User\",\n info=\"Type of sender.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"sender_name\",\n display_name=\"Sender Name\",\n info=\"Name of the sender.\",\n advanced=True,\n ),\n IntInput(\n name=\"n_messages\",\n display_name=\"Number of Messages\",\n value=100,\n info=\"Number of messages to retrieve.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"session_id\",\n display_name=\"Session ID\",\n info=\"Session ID of the chat history.\",\n advanced=True,\n ),\n DropdownInput(\n name=\"order\",\n display_name=\"Order\",\n options=[\"Ascending\", \"Descending\"],\n value=\"Ascending\",\n info=\"Order of the messages.\",\n advanced=True,\n ),\n MultilineInput(\n name=\"template\",\n display_name=\"Template\",\n info=\"The template to use for formatting the data. It can contain the keys {text}, {sender} or any other key in the message data.\",\n value=\"{sender_name}: {text}\",\n advanced=True,\n ),\n ]\n\n outputs = [\n Output(display_name=\"Chat History\", name=\"messages\", method=\"retrieve_messages\"),\n Output(display_name=\"Messages (Text)\", name=\"messages_text\", method=\"retrieve_messages_as_text\"),\n ]\n\n def retrieve_messages(self) -> Data:\n sender = self.sender\n sender_name = self.sender_name\n session_id = self.session_id\n n_messages = self.n_messages\n order = \"DESC\" if self.order == \"Descending\" else \"ASC\"\n\n if sender == \"Machine and User\":\n sender = None\n\n messages = get_messages(\n sender=sender,\n sender_name=sender_name,\n session_id=session_id,\n limit=n_messages,\n order=order,\n )\n self.status = messages\n return messages\n\n def retrieve_messages_as_text(self) -> Message:\n messages_text = data_to_text(self.template, self.retrieve_messages())\n self.status = messages_text\n return Message(text=messages_text)\n"
"value": "from langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DropdownInput, IntInput, MessageTextInput, MultilineInput, Output\nfrom langflow.memory import get_messages\nfrom langflow.schema import Data\nfrom langflow.schema.message import Message\n\n\nclass MemoryComponent(Component):\n display_name = \"Chat Memory\"\n description = \"Retrieves stored chat messages.\"\n icon = \"message-square-more\"\n\n inputs = [\n DropdownInput(\n name=\"sender\",\n display_name=\"Sender Type\",\n options=[\"Machine\", \"User\", \"Machine and User\"],\n value=\"Machine and User\",\n info=\"Type of sender.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"sender_name\",\n display_name=\"Sender Name\",\n info=\"Name of the sender.\",\n advanced=True,\n ),\n IntInput(\n name=\"n_messages\",\n display_name=\"Number of Messages\",\n value=100,\n info=\"Number of messages to retrieve.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"session_id\",\n display_name=\"Session ID\",\n info=\"Session ID of the chat history.\",\n advanced=True,\n ),\n DropdownInput(\n name=\"order\",\n display_name=\"Order\",\n options=[\"Ascending\", \"Descending\"],\n value=\"Ascending\",\n info=\"Order of the messages.\",\n advanced=True,\n ),\n MultilineInput(\n name=\"template\",\n display_name=\"Template\",\n info=\"The template to use for formatting the data. It can contain the keys {text}, {sender} or any other key in the message data.\",\n value=\"{sender_name}: {text}\",\n advanced=True,\n ),\n ]\n\n outputs = [\n Output(display_name=\"Chat History\", name=\"messages\", method=\"retrieve_messages\"),\n Output(display_name=\"Messages (Text)\", name=\"messages_text\", method=\"retrieve_messages_as_text\"),\n ]\n\n def retrieve_messages(self) -> Data:\n sender = self.sender\n sender_name = self.sender_name\n session_id = self.session_id\n n_messages = self.n_messages\n order = \"DESC\" if self.order == \"Descending\" else \"ASC\"\n\n if sender == \"Machine and User\":\n sender = None\n\n messages = get_messages(\n sender=sender,\n sender_name=sender_name,\n session_id=session_id,\n limit=n_messages,\n order=order,\n )\n self.status = messages\n return messages\n\n def retrieve_messages_as_text(self) -> Message:\n messages_text = data_to_text(self.template, self.retrieve_messages())\n self.status = messages_text\n return Message(text=messages_text)\n"
},
"n_messages": {
"advanced": true,
@ -195,6 +188,7 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_metadata": true,
"type": "int",
"value": 100
},
@ -212,6 +206,7 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_metadata": true,
"type": "str",
"value": "Ascending"
},
@ -230,6 +225,7 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_metadata": true,
"type": "str",
"value": "Machine and User"
},
@ -248,6 +244,8 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"trace_as_metadata": true,
"type": "str",
"value": ""
},
@ -266,6 +264,8 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"trace_as_metadata": true,
"type": "str",
"value": ""
},
@ -285,6 +285,8 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"trace_as_metadata": true,
"type": "str",
"value": "{sender_name}: {text}"
}
@ -293,15 +295,15 @@
"type": "Memory"
},
"dragging": false,
"height": 267,
"id": "Memory-A4OPp",
"height": 266,
"id": "Memory-uy2TA",
"position": {
"x": 1258.8089948698466,
"y": 547.1243849102437
"x": 1264.7588980556088,
"y": 506.6868269980502
},
"positionAbsolute": {
"x": 1258.8089948698466,
"y": 547.1243849102437
"x": 1264.7588980556088,
"y": 506.6868269980502
},
"selected": false,
"type": "genericNode",
@ -309,10 +311,157 @@
},
{
"data": {
"description": "Get chat inputs from the Playground.",
"display_name": "Chat Input",
"edited": false,
"id": "ChatInput-ENTF8",
"description": "Create a prompt template with dynamic variables.",
"display_name": "Prompt",
"id": "Prompt-m9rUs",
"node": {
"base_classes": [
"Message"
],
"beta": false,
"conditional_paths": [],
"custom_fields": {
"template": [
"context",
"user_message"
]
},
"description": "Create a prompt template with dynamic variables.",
"display_name": "Prompt",
"documentation": "",
"edited": false,
"error": null,
"field_order": [
"template"
],
"frozen": false,
"full_path": null,
"icon": "prompts",
"is_composition": null,
"is_input": null,
"is_output": null,
"name": "",
"output_types": [],
"outputs": [
{
"cache": true,
"display_name": "Prompt Message",
"hidden": false,
"method": "build_prompt",
"name": "prompt",
"selected": "Message",
"types": [
"Message"
],
"value": "__UNDEFINED__"
}
],
"pinned": false,
"template": {
"_type": "Component",
"code": {
"advanced": true,
"dynamic": true,
"fileTypes": [],
"file_path": "",
"info": "",
"list": false,
"load_from_db": false,
"multiline": true,
"name": "code",
"password": false,
"placeholder": "",
"required": true,
"show": true,
"title_case": false,
"type": "code",
"value": "from langflow.base.prompts.api_utils import process_prompt_template\nfrom langflow.custom import Component\nfrom langflow.io import Output, PromptInput\nfrom langflow.schema.message import Message\nfrom langflow.template.utils import update_template_values\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt\"\n description: str = \"Create a prompt template with dynamic variables.\"\n icon = \"prompts\"\n trace_type = \"prompt\"\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt Message\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n async def build_prompt(\n self,\n ) -> Message:\n prompt = await Message.from_template_and_variables(**self._attributes)\n self.status = prompt.text\n return prompt\n\n def post_code_processing(self, new_build_config: dict, current_build_config: dict):\n \"\"\"\n This function is called after the code validation is done.\n \"\"\"\n frontend_node = super().post_code_processing(new_build_config, current_build_config)\n template = frontend_node[\"template\"][\"template\"][\"value\"]\n _ = process_prompt_template(\n template=template,\n name=\"template\",\n custom_fields=frontend_node[\"custom_fields\"],\n frontend_node_template=frontend_node[\"template\"],\n )\n # Now that template is updated, we need to grab any values that were set in the current_build_config\n # and update the frontend_node with those values\n update_template_values(frontend_template=frontend_node, raw_template=current_build_config[\"template\"])\n return frontend_node\n"
},
"context": {
"advanced": false,
"display_name": "context",
"dynamic": false,
"field_type": "str",
"fileTypes": [],
"file_path": "",
"info": "",
"input_types": [
"Message",
"Text"
],
"list": false,
"load_from_db": false,
"multiline": true,
"name": "context",
"password": false,
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"type": "str",
"value": ""
},
"template": {
"advanced": false,
"display_name": "Template",
"dynamic": false,
"info": "",
"list": false,
"name": "template",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"type": "prompt",
"value": "{context}\n\nUser: {user_message}\nAI: "
},
"user_message": {
"advanced": false,
"display_name": "user_message",
"dynamic": false,
"field_type": "str",
"fileTypes": [],
"file_path": "",
"info": "",
"input_types": [
"Message",
"Text"
],
"list": false,
"load_from_db": false,
"multiline": true,
"name": "user_message",
"password": false,
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"type": "str",
"value": ""
}
}
},
"type": "Prompt"
},
"dragging": false,
"height": 515,
"id": "Prompt-m9rUs",
"position": {
"x": 1880.8227904110583,
"y": 625.8049209882275
},
"positionAbsolute": {
"x": 1880.8227904110583,
"y": 625.8049209882275
},
"selected": false,
"type": "genericNode",
"width": 384
},
{
"data": {
"id": "ChatInput-hSTqh",
"node": {
"base_classes": [
"Message"
@ -323,7 +472,7 @@
"description": "Get chat inputs from the Playground.",
"display_name": "Chat Input",
"documentation": "",
"edited": true,
"edited": false,
"field_order": [
"input_value",
"sender",
@ -493,16 +642,16 @@
},
"type": "ChatInput"
},
"dragging": true,
"height": 309,
"id": "ChatInput-ENTF8",
"dragging": false,
"height": 308,
"id": "ChatInput-hSTqh",
"position": {
"x": 1261.3748612945249,
"y": 912.733279525042
"x": 1275.9262193671882,
"y": 836.1228056896347
},
"positionAbsolute": {
"x": 1261.3748612945249,
"y": 912.733279525042
"x": 1275.9262193671882,
"y": 836.1228056896347
},
"selected": false,
"type": "genericNode",
@ -510,10 +659,7 @@
},
{
"data": {
"description": "Generates text using OpenAI LLMs.",
"display_name": "OpenAI",
"edited": false,
"id": "OpenAIModel-ZBIVC",
"id": "OpenAIModel-WmUtU",
"node": {
"base_classes": [
"LanguageModel",
@ -525,7 +671,7 @@
"description": "Generates text using OpenAI LLMs.",
"display_name": "OpenAI",
"documentation": "",
"edited": true,
"edited": false,
"field_order": [
"input_value",
"max_tokens",
@ -603,6 +749,8 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"trace_as_metadata": true,
"type": "str",
"value": ""
},
@ -617,6 +765,7 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_metadata": true,
"type": "int",
"value": ""
},
@ -631,6 +780,7 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"type": "dict",
"value": {}
},
@ -651,6 +801,7 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_metadata": true,
"type": "str",
"value": "gpt-4-turbo"
},
@ -666,6 +817,7 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_metadata": true,
"type": "str",
"value": ""
},
@ -696,6 +848,7 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"type": "dict",
"value": {}
},
@ -710,6 +863,7 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_metadata": true,
"type": "int",
"value": 1
},
@ -724,6 +878,7 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_metadata": true,
"type": "bool",
"value": false
},
@ -739,6 +894,7 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_metadata": true,
"type": "str",
"value": ""
},
@ -753,6 +909,7 @@
"required": false,
"show": true,
"title_case": false,
"trace_as_metadata": true,
"type": "float",
"value": 0.1
}
@ -761,15 +918,15 @@
"type": "OpenAIModel"
},
"dragging": false,
"height": 622,
"id": "OpenAIModel-ZBIVC",
"height": 621,
"id": "OpenAIModel-WmUtU",
"position": {
"x": 2495.6628431453228,
"y": 669.9567653609598
"x": 2428.0215346784357,
"y": 569.9683144303319
},
"positionAbsolute": {
"x": 2495.6628431453228,
"y": 669.9567653609598
"x": 2428.0215346784357,
"y": 569.9683144303319
},
"selected": false,
"type": "genericNode",
@ -777,10 +934,7 @@
},
{
"data": {
"description": "Display a chat message in the Playground.",
"display_name": "Chat Output",
"edited": false,
"id": "ChatOutput-e8ruq",
"id": "ChatOutput-LIvGN",
"node": {
"base_classes": [
"Message"
@ -791,7 +945,7 @@
"description": "Display a chat message in the Playground.",
"display_name": "Chat Output",
"documentation": "",
"edited": true,
"edited": false,
"field_order": [
"input_value",
"sender",
@ -940,164 +1094,14 @@
},
"dragging": false,
"height": 308,
"id": "ChatOutput-e8ruq",
"id": "ChatOutput-LIvGN",
"position": {
"x": 3028.2686266398873,
"y": 888.0854888768531
"x": 2988.248820475989,
"y": 705.837390387878
},
"positionAbsolute": {
"x": 3028.2686266398873,
"y": 888.0854888768531
},
"selected": false,
"type": "genericNode",
"width": 384
},
{
"data": {
"description": "Create a prompt template with dynamic variables.",
"display_name": "Prompt",
"id": "Prompt-xhlQ7",
"node": {
"base_classes": [
"Message"
],
"beta": false,
"conditional_paths": [],
"custom_fields": {
"template": [
"context",
"user_message"
]
},
"description": "Create a prompt template with dynamic variables.",
"display_name": "Prompt",
"documentation": "",
"edited": false,
"error": null,
"field_order": [
"template"
],
"frozen": false,
"full_path": null,
"icon": "prompts",
"is_composition": null,
"is_input": null,
"is_output": null,
"name": "",
"output_types": [],
"outputs": [
{
"cache": true,
"display_name": "Prompt Message",
"hidden": false,
"method": "build_prompt",
"name": "prompt",
"selected": "Message",
"types": [
"Message"
],
"value": "__UNDEFINED__"
}
],
"pinned": false,
"template": {
"_type": "Component",
"code": {
"advanced": true,
"dynamic": true,
"fileTypes": [],
"file_path": "",
"info": "",
"list": false,
"load_from_db": false,
"multiline": true,
"name": "code",
"password": false,
"placeholder": "",
"required": true,
"show": true,
"title_case": false,
"type": "code",
"value": "from langflow.base.prompts.api_utils import process_prompt_template\nfrom langflow.custom import Component\nfrom langflow.io import Output, PromptInput\nfrom langflow.schema.message import Message\nfrom langflow.template.utils import update_template_values\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt\"\n description: str = \"Create a prompt template with dynamic variables.\"\n icon = \"prompts\"\n trace_type = \"prompt\"\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt Message\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n async def build_prompt(\n self,\n ) -> Message:\n prompt = await Message.from_template_and_variables(**self._attributes)\n self.status = prompt.text\n return prompt\n\n def post_code_processing(self, new_build_config: dict, current_build_config: dict):\n \"\"\"\n This function is called after the code validation is done.\n \"\"\"\n frontend_node = super().post_code_processing(new_build_config, current_build_config)\n template = frontend_node[\"template\"][\"template\"][\"value\"]\n _ = process_prompt_template(\n template=template,\n name=\"template\",\n custom_fields=frontend_node[\"custom_fields\"],\n frontend_node_template=frontend_node[\"template\"],\n )\n # Now that template is updated, we need to grab any values that were set in the current_build_config\n # and update the frontend_node with those values\n update_template_values(frontend_template=frontend_node, raw_template=current_build_config[\"template\"])\n return frontend_node\n"
},
"context": {
"advanced": false,
"display_name": "context",
"dynamic": false,
"field_type": "str",
"fileTypes": [],
"file_path": "",
"info": "",
"input_types": [
"Message",
"Text"
],
"list": false,
"load_from_db": false,
"multiline": true,
"name": "context",
"password": false,
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"type": "str",
"value": ""
},
"template": {
"advanced": false,
"display_name": "Template",
"dynamic": false,
"info": "",
"list": false,
"name": "template",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"trace_as_input": true,
"type": "prompt",
"value": "{context}\n\nUser: {user_message}\nAI: "
},
"user_message": {
"advanced": false,
"display_name": "user_message",
"dynamic": false,
"field_type": "str",
"fileTypes": [],
"file_path": "",
"info": "",
"input_types": [
"Message",
"Text"
],
"list": false,
"load_from_db": false,
"multiline": true,
"name": "user_message",
"password": false,
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"type": "str",
"value": ""
}
}
},
"type": "Prompt"
},
"dragging": false,
"height": 517,
"id": "Prompt-xhlQ7",
"position": {
"x": 1879.4280156201567,
"y": 674.3958274263156
},
"positionAbsolute": {
"x": 1879.4280156201567,
"y": 674.3958274263156
"x": 2988.248820475989,
"y": 705.837390387878
},
"selected": false,
"type": "genericNode",
@ -1105,14 +1109,14 @@
}
],
"viewport": {
"x": -592.532107710133,
"y": -149.32118023592653,
"x": -586.5321077101332,
"y": -103.32118023592653,
"zoom": 0.5372819347267049
}
},
"description": "This project can be used as a starting point for building a Chat experience with user specific memory. You can set a different Session ID to start a new message history.",
"endpoint_name": null,
"id": "909c382d-d215-4d50-91b3-dcb6f3ffd93c",
"id": "2a47bc35-69ca-4d8b-9895-2a7fab222b9f",
"is_component": false,
"last_tested_version": "1.0.0rc1",
"name": "Memory Chatbot"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long