"profile name are valid."
            ) from e
        return values
    def _embedding_func(self, text: str) -> List[float]:
        """Call out to Bedrock embedding endpoint."""
        # replace newlines, which can negatively affect performance.
        text = text.replace(os.linesep, " ")
        _model_kwargs = self.model_kwargs or {}
        input_body = {**_model_kwargs}
        input_body["inputText"] = text
        body = json.dumps(input_body)
        content_type = "application/json"
        accepts = "application/json"
        embeddings = []
        try:
            response = self.client.invoke_model(
                body=body,
                modelId=self.model_id,
                accept=accepts,
                contentType=content_type,
            )
            response_body = json.loads(response.get("body").read())
            embeddings = response_body.get("embedding")
        except Exception as e:
            raise ValueError(f"Error raised by inference endpoint: {e}")
        return embeddings
[docs]    def embed_documents(
        self, texts: List[str], chunk_size: int = 1
    ) -> List[List[float]]:
        """Compute doc embeddings using a Bedrock model.
        Args:
            texts: The list of texts to embed.
            chunk_size: Bedrock currently only allows single string
                inputs, so chunk size is always 1. This input is here
                only for compatibility with the embeddings interface.
        Returns:
            List of embeddings, one for each text.
        """
        results = []
        for text in texts:
            response = self._embedding_func(text)
            results.append(response)
        return results
[docs]    def embed_query(self, text: str) -> List[float]:
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/embeddings/bedrock.html