-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deprecated imports while running langflow #2070
Comments
To resolve the deprecated import warning related to Replace: from langchain import RequestsWrapper With: from langchain_community.utilities.requests import TextRequestsWrapper Here is an example of how you can update your code to use from typing import Optional
from langchain_community.utilities.requests import TextRequestsWrapper
from langchain_core.documents import Document
from langflow import CustomComponent
from langflow.services.database.models.base import orjson_dumps
class GetRequest(CustomComponent):
display_name: str = "GET Request"
description: str = "Make a GET request to the given URL."
output_types: list[str] = ["Document"]
documentation: str = "https://docs.langflow.org/components/utilities#get-request"
beta: bool = True
field_config = {
"url": {
"display_name": "URL",
"info": "The URL to make the request to",
"is_list": True,
},
"headers": {
"display_name": "Headers",
"info": "The headers to send with the request.",
},
"code": {"show": False},
"timeout": {
"display_name": "Timeout",
"field_type": "int",
"info": "The timeout to use for the request.",
"value": 5,
},
}
def get_document(self, wrapper: TextRequestsWrapper, url: str, headers: Optional[dict], timeout: int) -> Document:
try:
response = wrapper.get(url, headers=headers, timeout=int(timeout))
try:
response_json = response.json()
result = orjson_dumps(response_json, indent_2=False)
except Exception:
result = response.text
self.repr_value = result
return Document(
page_content=result,
metadata={
"source": url,
"headers": headers,
"status_code": response.status_code,
},
)
except requests.Timeout:
return Document(
page_content="Request Timed Out",
metadata={"source": url, "headers": headers, "status_code": 408},
)
except Exception as exc:
return Document(
page_content=str(exc),
metadata={"source": url, "headers": headers, "status_code": 500},
)
def build(
self,
url: str,
headers: Optional[dict] = None,
timeout: int = 5,
) -> list[Document]:
if headers is None:
headers = {}
urls = url if isinstance(url, list) else [url]
wrapper = TextRequestsWrapper()
documents = [self.get_document(wrapper, u, headers, timeout) for u in urls]
self.repr_value = documents
return documents This update should resolve the deprecated import warning related to |
Most of them have been resolved with the latest langchain upgrade. If any other deprecations appear, please open a new ticket with the specific lines |
Getting the following deprecated imports issue in the langflow installation :
.pyenv\pyenv-win\versions\3.11.3\Lib\site-packages\langchain_api\module_import.py:120: LangChainDeprecationWarning: Importing RequestsWrapper from langchain is deprecated. Please replace deprecated imports:
with new imports of:
warn_deprecated(
The text was updated successfully, but these errors were encountered: