The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
experimental: Fix divide by 0 error (#25439)
Luke66e30efa61f9
diff --git a/libs/experimental/langchain_experimental/text_splitter.py b/libs/experimental/langchain_experimental/text_splitter.pyindex 02e7d80916..be3a795b06 100644--- a/libs/experimental/langchain_experimental/text_splitter.py+++ b/libs/experimental/langchain_experimental/text_splitter.py@@ -180,7 +180,11 @@ class SemanticChunker(BaseDocumentTransformer):x = max(min(self.number_of_chunks, x1), x2)# Linear interpolation formula- y = y1 + ((y2 - y1) / (x2 - x1)) * (x - x1)+ if x2 == x1:+ y = y2+ else:+ y = y1 + ((y2 - y1) / (x2 - x1)) * (x - x1)+y = min(max(y, 0), 100)return cast(float, np.percentile(distances, y))