Comments (2)
Hey
That's a good idea!
We have created a new way building a Component and we could adapt the components we have now to support this.
Here's how the ChatInput looks in the new format. What do you think?
from langflow.base.io.chat import ChatComponent
from langflow.field_typing import Text
from langflow.schema import Record
from langflow.template import Input, Output
class ChatInput(ChatComponent):
display_name = "Chat Input"
description = "Get chat inputs from the Playground."
icon = "ChatInput"
inputs = [
Input(
name="input_value",
type=str,
display_name="Message",
multiline=True,
input_types=[],
info="Message to be passed as input.",
),
Input(
name="sender",
type=str,
display_name="Sender Type",
options=["Machine", "User"],
value="User",
info="Type of sender.",
advanced=True,
),
Input(name="sender_name", type=str, display_name="Sender Name", info="Name of the sender.", value="User"),
Input(
name="session_id", type=str, display_name="Session ID", info="Session ID for the message.", advanced=True
),
]
outputs = [
Output(display_name="Message", name="message", method="text_response"),
Output(display_name="Record", name="record", method="record_response"),
]
def text_response(self) -> Text:
result = self.input_value
if self.session_id and isinstance(result, (Record, str)):
self.store_message(result, self.session_id, self.sender, self.sender_name)
return result
def record_response(self) -> Record:
record = Record(
data={
"text": self.input_value,
"sender": self.sender,
"sender_name": self.sender_name,
"session_id": self.session_id,
},
)
if self.session_id and isinstance(record, (Record, str)):
self.store_message(record, self.session_id, self.sender, self.sender_name)
return record
from langflow.
Hey
That's a good idea!
We have created a new way building a Component and we could adapt the components we have now to support this.
Here's how the ChatInput looks in the new format. What do you think?
from langflow.base.io.chat import ChatComponent from langflow.field_typing import Text from langflow.schema import Record from langflow.template import Input, Output class ChatInput(ChatComponent): display_name = "Chat Input" description = "Get chat inputs from the Playground." icon = "ChatInput" inputs = [ Input( name="input_value", type=str, display_name="Message", multiline=True, input_types=[], info="Message to be passed as input.", ), Input( name="sender", type=str, display_name="Sender Type", options=["Machine", "User"], value="User", info="Type of sender.", advanced=True, ), Input(name="sender_name", type=str, display_name="Sender Name", info="Name of the sender.", value="User"), Input( name="session_id", type=str, display_name="Session ID", info="Session ID for the message.", advanced=True ), ] outputs = [ Output(display_name="Message", name="message", method="text_response"), Output(display_name="Record", name="record", method="record_response"), ] def text_response(self) -> Text: result = self.input_value if self.session_id and isinstance(result, (Record, str)): self.store_message(result, self.session_id, self.sender, self.sender_name) return result def record_response(self) -> Record: record = Record( data={ "text": self.input_value, "sender": self.sender, "sender_name": self.sender_name, "session_id": self.session_id, }, ) if self.session_id and isinstance(record, (Record, str)): self.store_message(record, self.session_id, self.sender, self.sender_name) return record
@ogabrielluiz Hello!,
Thank you for the response. I was in the middle of development, and this is exactly the structure I was looking for!
Managing INPUT and OUTPUT as templates in this manner should make it easy to connect with various solutions, not just Agent Protocol.
It seems like there's someone trying to integrate Agent Protocol with Langchain and is currently working on it, but instead of waiting for that work, considering future integration with solutions like Lammaindex, Langflow itself will need IO templates that are integrated as templates.
(You came up with a great idea at the perfect time!)
Additionally, in the case of Agent Protocol, there is a concept of adding or downloading files as artifacts. This structure should also be predefined in the parent ChatComponent.
At this stage, since it seems like only the AUTOGPT team is actively integrating the Agent Protocol client, the structure needed for the artifact concept might not be immediately necessary.
from langflow.
Related Issues (20)
- Langflow show black screen on launch HOT 8
- feat: add Milvus components
- only getting first few letters of the output HOT 3
- [pre-release alpha bug] a46 with python 3.11.9 won't start HOT 5
- LANGFLOW black screen on launch HOT 2
- JSON for Tool calling agent that invokes multiple Flows as Tool HOT 5
- Integrating Custom Callback to Output Agent Steps in Recode Format HOT 2
- Duplicate "session_id" in response of API on pre-release. HOT 6
- Error in the Code Export: Boolean values are in the incorrect syntax. 'false' should be changed to 'False', 'true' should be changed to 'True'. HOT 2
- No Response when running the Flow using cURL or Python API HOT 2
- TypeError: RedisCache.upsert() got an unexpected keyword argument 'lock' HOT 1
- Error building node TextLoader HOT 1
- sqlite3.OperationalError: table _alembic_tmp_flow already exists during Langflow startup HOT 1
- Testing alpha release with docker compose: required keyword-only argument: 'recursive_guard' HOT 2
- [Feature Request] Add support for `dimensions` parameter in embedding models
- [Feature Request] Support secretes stored in Kubernetes
- [Feature Request] A generic SecretService to support store secrets
- langflow build hangs HOT 3
- [Tests] Add astra db integration tests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from langflow.