Comments (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:
-
Ensure
input_value
is a string: When addinginput_value
to themessages
list, it should be a string. Ifinput_value
is already aRecord
, you need to convert it to aHumanMessage
correctly. -
Modify the
get_chat_result
function: Ensure thatinput_value
is properly converted to aHumanMessage
.
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.
Already reported earlier at #2182 for a58 and continues to be an issue with a59 version as well.
from langflow.
Related Issues (20)
- Faiss search error HOT 2
- The outout of the Chat Input is not been recognized as text by OpenAI model HOT 4
- Error Building Component Error building Component Astra DB: {"errors":[{"message":"Request invalid: field 'command.name' value \"english-test\" not valid. Problem: must match \"[a-zA-Z][a-zA-Z0-9_]*\".","errorCode":"COMMAND_FIELD_INVALID"}]} HOT 1
- Encountering error in building ASTRA DB Search node in the canvas. Error Building Component Error building Component Astra DB Search: Invalid inputs provided. HOT 4
- API Request ERROR HOT 3
- [Feature Request]: Allow local cassandra connections
- idea
- [Request] Please add openrouter as LLM Model
- Nested chats HOT 1
- Module langflow.inputs not found HOT 1
- CommandError: Multiple head revisions are present for given argument 'head'; please specify a specific target revision, '<branchname>@head' to narrow to a specific head, or 'heads' for all heads HOT 1
- Questions about Run Flow HOT 3
- An error was thrown while using the groq component HOT 1
- Question: Hugging Face API HOT 1
- Issue with Chat Input component HOT 5
- Question: Inquiry on Session Management and Parameter Passing in Langflow API HOT 3
- Langflow Store Suspension HOT 1
- Documentation to use Flow as Tool HOT 3
- Method not Allowed on API HOT 1
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.