Giter Club home page Giter Club logo

Comments (2)

ogabrielluiz avatar ogabrielluiz commented on July 19, 2024

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.

YamonBot avatar YamonBot commented on July 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.