From 8dbf4cbe80f93f2ed427d8331c2bb575564f7213 Mon Sep 17 00:00:00 2001 From: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:21:30 -0400 Subject: [PATCH 1/2] Add notice about security-sensitive experimental code to experimental README. (#9936) It renders like this: https://github.com/langchain-ai/langchain/tree/pg/experimental-readme/libs/experimental ![image](https://github.com/langchain-ai/langchain/assets/2348618/a5f9569d-96f6-44c6-8559-921adb3e337d) --- libs/experimental/README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libs/experimental/README.md b/libs/experimental/README.md index c65686df78..adf8a06422 100644 --- a/libs/experimental/README.md +++ b/libs/experimental/README.md @@ -1,3 +1,16 @@ # 🦜️🧪 LangChain Experimental -This repository holds more experimental LangChain code. \ No newline at end of file +This package holds experimental LangChain code, intended for research and experimental +uses. + +> [!WARNING] +> Portions of the code in this package may be dangerous if not properly deployed +> in a sandboxed environment. Please be wary of deploying experimental code +> to production unless you've taken appropriate precautions and +> have already discussed it with your security team. + +Some of the code here may be marked with security notices. However, +given the exploratory and experimental nature of the code in this package, +the lack of a security notice on a piece of code does not mean that +the code in question does not require additional security considerations +in order to be safe to use. From 0fb95ebe6688d3f2c2524cf078ac1f1534c17a5f Mon Sep 17 00:00:00 2001 From: Corvus Lee <51771215+corvuslee@users.noreply.github.com> Date: Tue, 29 Aug 2023 19:38:52 +0100 Subject: [PATCH 2/2] Docs: enrich SageMaker endpoint embeddings with docstrings and examples (#9924) Description: added comments to address the relationship between input/output transformations and the customised inference.py script. --- .../text_embedding/sagemaker-endpoint.ipynb | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/extras/integrations/text_embedding/sagemaker-endpoint.ipynb b/docs/extras/integrations/text_embedding/sagemaker-endpoint.ipynb index 96d09be4b1..fe5299ae6f 100644 --- a/docs/extras/integrations/text_embedding/sagemaker-endpoint.ipynb +++ b/docs/extras/integrations/text_embedding/sagemaker-endpoint.ipynb @@ -48,10 +48,31 @@ " accepts = \"application/json\"\n", "\n", " def transform_input(self, inputs: list[str], model_kwargs: Dict) -> bytes:\n", - " input_str = json.dumps({\"inputs\": inputs, **model_kwargs})\n", + " \"\"\"\n", + " Transforms the input into bytes that can be consumed by SageMaker endpoint.\n", + " Args:\n", + " inputs: List of input strings.\n", + " model_kwargs: Additional keyword arguments to be passed to the endpoint.\n", + " Returns:\n", + " The transformed bytes input.\n", + " \"\"\"\n", + " # Example: inference.py expects a JSON string with a \"inputs\" key:\n", + " input_str = json.dumps({\"inputs\": inputs, **model_kwargs}) \n", " return input_str.encode(\"utf-8\")\n", "\n", " def transform_output(self, output: bytes) -> List[List[float]]:\n", + " \"\"\"\n", + " Transforms the bytes output from the endpoint into a list of embeddings.\n", + " Args:\n", + " output: The bytes output from SageMaker endpoint.\n", + " Returns:\n", + " The transformed output - list of embeddings\n", + " Note:\n", + " The length of the outer list is the number of input strings.\n", + " The length of the inner lists is the embedding dimension.\n", + " \"\"\"\n", + " # Example: inference.py returns a JSON string with the list of\n", + " # embeddings in a \"vectors\" key:\n", " response_json = json.loads(output.read().decode(\"utf-8\"))\n", " return response_json[\"vectors\"]\n", "\n", @@ -60,7 +81,6 @@ "\n", "\n", "embeddings = SagemakerEndpointEmbeddings(\n", - " # endpoint_name=\"endpoint-name\",\n", " # credentials_profile_name=\"credentials-profile-name\",\n", " endpoint_name=\"huggingface-pytorch-inference-2023-03-21-16-14-03-834\",\n", " region_name=\"us-east-1\",\n",