Closed sanjin1985 closed 5 hours ago
Hello @sanjin1985! I'm here to help you with any bugs, questions, or contributions you have for Dify. I'm Dosu, a bot that's ready to assist you while you wait for a human maintainer.
To resolve the validation error in Pydantic where the "DocumentContext score" input should be a valid float but received a NoneType
, ensure that the score
field is allowed to be None
by using the Optional
type. The code should define score
as Optional[float]
, which means it can be either a float or None
. Here's an example of how it should be defined:
from typing import Optional
from pydantic import BaseModel
class DocumentContext(BaseModel):
content: str
score: Optional[float] = None
Make sure that when you create an instance of DocumentContext
, you are either providing a valid float for score
or leaving it as None
. Check the data being passed to ensure it aligns with these expectations. In the context of the Dify platform, verify that the score
is being correctly set in the DocumentContext
instances. For example, in the DatasetRetrieval
class, ensure that the score
is retrieved from item.metadata.get("score")
and is correctly populated with a float or None
before creating the DocumentContext
instance [1][2].
To continue talking to Dosu, mention @dosu.
Duplicated
Self Checks
Dify version
Version 0.9.1
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
✔️ Expected Behavior
how to resolve the problem?
❌ Actual Behavior
No response