Giter Club home page Giter Club logo

Comments (2)

dosubot avatar dosubot commented on July 19, 2024 2

To resolve the ValidationError when connecting ChatInput to OpenAI without a prompt, you need to ensure that the input_value is correctly formatted as a HumanMessage. The error indicates that the content field is expected to be a string but is being provided as a list, or vice versa.

Here's how you can fix it:

  1. Ensure input_value is a string: When adding input_value to the messages list, it should be a string. If input_value is already a Record, you need to convert it to a HumanMessage correctly.

  2. Modify the get_chat_result function: Ensure that input_value is properly converted to a HumanMessage.

Here is the relevant part of the code that needs to be checked and possibly modified:

def get_chat_result(self, runnable: BaseChatModel, stream: bool, input_value: str, system_message: Optional[str] = None):
    messages: list[Union[HumanMessage, SystemMessage]] = []
    if not input_value and not system_message:
        raise ValueError("The message you want to send to the model is empty.")
    if system_message:
        messages.append(SystemMessage(content=system_message))
    if input_value:
        messages.append(HumanMessage(content=input_value))
    if stream:
        return runnable.stream(messages)
    else:
        message = runnable.invoke(messages)
        result = message.content
        if isinstance(message, AIMessage):
            status_message = self.build_status_message(message)
            self.status = status_message
        else:
            self.status = result
        return result

Ensure that input_value is a string when passed to HumanMessage:

if input_value:
    if isinstance(input_value, Record):
        input_value = input_value.get_text()  # Convert Record to string
    messages.append(HumanMessage(content=input_value))

This ensures that input_value is correctly formatted as a string before being used to create a HumanMessage [1][2].

To continue talking to Dosu, mention @dosu.

from langflow.

msmygit avatar msmygit commented on July 19, 2024 1

Already reported earlier at #2182 for a58 and continues to be an issue with a59 version as well.

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.