The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Fix HF endpoint returns blank for text-generation (#7386)
Hashem Alsaket1dd4236177c3
diff --git a/langchain/llms/huggingface_endpoint.py b/langchain/llms/huggingface_endpoint.pyindex ff83b0baea..34aa98d4ab 100644--- a/langchain/llms/huggingface_endpoint.py+++ b/langchain/llms/huggingface_endpoint.py@@ -137,8 +137,10 @@ class HuggingFaceEndpoint(LLM):f"Error raised by inference API: {generated_text['error']}")if self.task == "text-generation":- # Text generation return includes the starter text.- text = generated_text[0]["generated_text"][len(prompt) :]+ text = generated_text[0]["generated_text"]+ # Remove prompt if included in generated text.+ if text.startswith(prompt):+ text = text[len(prompt) :]elif self.task == "text2text-generation":text = generated_text[0]["generated_text"]elif self.task == "summarization":diff --git a/tests/integration_tests/vectorstores/test_pinecone.py b/tests/integration_tests/vectorstores/test_pinecone.pyindex 238f46f6cc..d1c6fa0c56 100644--- a/tests/integration_tests/vectorstores/test_pinecone.py+++ b/tests/integration_tests/vectorstores/test_pinecone.py@@ -2,9 +2,9 @@ import importlibimport osimport timeimport uuid-import numpy as npfrom typing import List+import numpy as npimport pineconeimport pytestdiff --git a/tests/integration_tests/vectorstores/test_qdrant.py b/tests/integration_tests/vectorstores/test_qdrant.pyindex de779dadf8..e46a6e36e6 100644--- a/tests/integration_tests/vectorstores/test_qdrant.py+++ b/tests/integration_tests/vectorstores/test_qdrant.py@@ -1,8 +1,8 @@"""Test Qdrant functionality."""import tempfilefrom typing import Callable, Optional-import numpy as np+import numpy as npimport pytestfrom qdrant_client.http import models as rest