mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 20:17:29 +08:00
fix: empty arrays should convert to empty string in LLM prompts (#23590)
This commit is contained in:
parent
d98071a088
commit
7230497bf4
@ -119,6 +119,13 @@ class ObjectSegment(Segment):
|
|||||||
|
|
||||||
|
|
||||||
class ArraySegment(Segment):
|
class ArraySegment(Segment):
|
||||||
|
@property
|
||||||
|
def text(self) -> str:
|
||||||
|
# Return empty string for empty arrays instead of "[]"
|
||||||
|
if not self.value:
|
||||||
|
return ""
|
||||||
|
return super().text
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def markdown(self) -> str:
|
def markdown(self) -> str:
|
||||||
items = []
|
items = []
|
||||||
@ -155,6 +162,9 @@ class ArrayStringSegment(ArraySegment):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def text(self) -> str:
|
def text(self) -> str:
|
||||||
|
# Return empty string for empty arrays instead of "[]"
|
||||||
|
if not self.value:
|
||||||
|
return ""
|
||||||
return json.dumps(self.value, ensure_ascii=False)
|
return json.dumps(self.value, ensure_ascii=False)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user