code: #  Copyright (c) 2023. LanceDB Developers
  #
  #  Licensed under the Apache License, Version 2.0 (the "License");
  #  you may not use this file except in compliance with the License.
  #  You may obtain a copy of the License at
  #      http://www.apache.org/licenses/LICENSE-2.0
  #
  #  Unless required by applicable law or agreed to in writing, software
  #  distributed under the License is distributed on an "AS IS" BASIS,
  #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  #  See the License for the specific language governing permissions and
  #  limitations under the License.
  import importlib
  import io
  import os
  
  import lancedb
  import numpy as np
  import pandas as pd
  import pytest
  import requests
  from lancedb.embeddings import get_registry
  from lancedb.pydantic import LanceModel, Vector
  
  # These are integration tests for embedding functions.
  # They are slow because they require downloading models
  # or connection to external api
  
  
  try:
      if importlib.util.find_spec("mlx.core") is not None:
          _mlx = True
      else:
          _mlx = None
  except Exception:
      _mlx = None
  
  try:
      if importlib.util.find_spec("imagebind") is not None:
          _imagebind = True
      else:
          _imagebind = None
  except Exception:
      _imagebind = None
  
  
  @pytest.mark.slow
  @pytest.mark.parametrize("alias", ["sentence-transformers", "openai"])
  def test_basic_text_embeddings(alias, tmp_path):
      db = lancedb.connect(tmp_path)
      registry = get_registry()
      func = registry.get(alias).create(max_retries=0)
      func2 = registry.get(alias).create(max_retries=0)
  
      class Words(LanceModel):
          text: str = func.SourceField()
          text2: str = func2.SourceField()
          vector: Vector(func.ndims()) = func.VectorField()
          vector2: Vector(func2.ndims()) = func2.VectorField()
  
      table = db.create_table("words", schema=Words)
      table.add(
          pd.DataFrame(
              {
                  "text": [
                      "hello world",
                      "goodbye world",
                      "fizz",
                      "buzz",
                      "foo",
                      "bar",
                      "baz",
                  ],
                  "text2": [
                      "to be or not to be",
                      "that is the question",
                      "for whether tis nobler",
                      "in the mind to suffer",
                      "the slings and arrows",
                      "of outrageous fortune",
                      "or to take arms",
                  ],
              }
          )
      )
  
      query = "greetings"
      actual = (
          table.search(query, vector_column_name="vector").limit(1).to_pydantic(Words)[0]
      )
  
      vec = func.compute_query_embeddings(query)[0]
      expected = (
          table.search(vec, vector_column_name="vector").limit(1).to_pydantic(Words)[0]
      )
      assert actual.text == expected.text
      assert actual.text == "hello world"
      assert not np.allclose(actual.vector, actual.vector2)
  
      actual = (
          table.search(query, vector_column_name="vector2").limit(1).to_pydantic(Words)[0]
      )
      assert actual.text != "hello world"
      assert not np.allclose(actual.vector, actual.vector2)
  
  
  @pytest.mark.slow
  def test_openclip(tmp_path):
      from PIL import Image
  
      db = lancedb.connect(tmp_path)
      registry = get_registry()
      func = registry.get("open-clip").create(max_retries=0)
  
      class Images(LanceModel):
          label: str
          image_uri: str = func.SourceField()
          image_bytes: bytes = func.SourceField()
          vector: Vector(func.ndims()) = func.VectorField()
          vec_from_bytes: Vector(func.ndims()) = func.VectorField()
  
      table = db.create_table("images", schema=Images)
      labels = ["cat", "cat", "dog", "dog", "horse", "horse"]
      uris = [
          "http://farm1.staticflickr.com/53/167798175_7c7845bbbd_z.jpg",
          "http://farm1.staticflickr.com/134/332220238_da527d8140_z.jpg",
          "http://farm9.staticflickr.com/8387/8602747737_2e5c2a45d4_z.jpg",
          "http://farm5.staticflickr.com/4092/5017326486_1f46057f5f_z.jpg",
          "http://farm9.staticflickr.com/8216/8434969557_d37882c42d_z.jpg",
          "http://farm6.staticflickr.com/5142/5835678453_4f3a4edb45_z.jpg",
      ]
      # get each uri as bytes
      image_bytes = [requests.get(uri).content for uri in uris]
      table.add(
          pd.DataFrame({"label": labels, "image_uri": uris, "image_bytes": image_bytes})
      )
  
      # text search
      actual = (
          table.search("man's best friend", vector_column_name="vector")
          .limit(1)
          .to_pydantic(Images)[0]
      )
      assert actual.label == "dog"
      frombytes = (
          table.search("man's best friend", vector_column_name="vec_from_bytes")
          .limit(1)
          .to_pydantic(Images)[0]
      )
      assert actual.label == frombytes.label
      assert np.allclose(actual.vector, frombytes.vector)
  
      # image search
      query_image_uri = "http://farm1.staticflickr.com/200/467715466_ed4a31801f_z.jpg"
      image_bytes = requests.get(query_image_uri).content
      query_image = Image.open(io.BytesIO(image_bytes))
      actual = (
          table.search(query_image, vector_column_name="vector")
          .limit(1)
          .to_pydantic(Images)[0]
      )
      assert actual.label == "dog"
      other = (
          table.search(query_image, vector_column_name="vec_from_bytes")
          .limit(1)
          .to_pydantic(Images)[0]
      )
      assert actual.label == other.label
  
      arrow_table = table.search().select(["vector", "vec_from_bytes"]).to_arrow()
      assert np.allclose(
          arrow_table["vector"].combine_chunks().values.to_numpy(),
          arrow_table["vec_from_bytes"].combine_chunks().values.to_numpy(),
      )
  
  
  @pytest.mark.skipif(
      _imagebind is None,
      reason="skip if imagebind not installed.",
  )
  @pytest.mark.slow
  def test_imagebind(tmp_path):
      import os
      import shutil
      import tempfile
  
      import lancedb.embeddings.imagebind
      import pandas as pd
      import requests
      from lancedb.embeddings import get_registry
      from lancedb.pydantic import LanceModel, Vector
  
      with tempfile.TemporaryDirectory() as temp_dir:
          print(f"Created temporary directory {temp_dir}")
  
          def download_images(image_uris):
              downloaded_image_paths = []
              for uri in image_uris:
                  try:
                      response = requests.get(uri, stream=True)
                      if response.status_code == 200:
                          # Extract image name from URI
                          image_name = os.path.basename(uri)
                          image_path = os.path.join(temp_dir, image_name)
                          with open(image_path, "wb") as out_file:
                              shutil.copyfileobj(response.raw, out_file)
                          downloaded_image_paths.append(image_path)
                  except Exception as e:  # noqa: PERF203
                      print(f"Failed to download {uri}. Error: {e}")
              return temp_dir, downloaded_image_paths
  
          db = lancedb.connect(tmp_path)
          registry = get_registry()
          func = registry.get("imagebind").create(max_retries=0)
  
          class Images(LanceModel):
              label: str
              image_uri: str = func.SourceField()
              vector: Vector(func.ndims()) = func.VectorField()
  
          table = db.create_table("images", schema=Images)
          labels = ["cat", "cat", "dog", "dog", "horse", "horse"]
          uris = [
              "http://farm1.staticflickr.com/53/167798175_7c7845bbbd_z.jpg",
              "http://farm1.staticflickr.com/134/332220238_da527d8140_z.jpg",
              "http://farm9.staticflickr.com/8387/8602747737_2e5c2a45d4_z.jpg",
              "http://farm5.staticflickr.com/4092/5017326486_1f46057f5f_z.jpg",
              "http://farm9.staticflickr.com/8216/8434969557_d37882c42d_z.jpg",
              "http://farm6.staticflickr.com/5142/5835678453_4f3a4edb45_z.jpg",
          ]
          temp_dir, downloaded_images = download_images(uris)
          table.add(pd.DataFrame({"label": labels, "image_uri": downloaded_images}))
          # text search
          actual = (
              table.search("man's best friend", vector_column_name="vector")
              .limit(1)
              .to_pydantic(Images)[0]
          )
          assert actual.label == "dog"
  
          # image search
          query_image_uri = [
              "https://live.staticflickr.com/65535/33336453970_491665f66e_h.jpg"
          ]
          temp_dir, downloaded_images = download_images(query_image_uri)
          query_image_uri = downloaded_images[0]
          actual = (
              table.search(query_image_uri, vector_column_name="vector")
              .limit(1)
              .to_pydantic(Images)[0]
          )
          assert actual.label == "dog"
  
      if os.path.isdir(temp_dir):
          shutil.rmtree(temp_dir)
          print(f"Deleted temporary directory {temp_dir}")
  
  
  @pytest.mark.slow
  @pytest.mark.skipif(
      os.environ.get("COHERE_API_KEY") is None, reason="COHERE_API_KEY not set"
  )  # also skip if cohere not installed
  def test_cohere_embedding_function():
      cohere = (
          get_registry()
          .get("cohere")
          .create(name="embed-multilingual-v2.0", max_retries=0)
      )
  
      class TextModel(LanceModel):
          text: str = cohere.SourceField()
          vector: Vector(cohere.ndims()) = cohere.VectorField()
  
      df = pd.DataFrame({"text": ["hello world", "goodbye world"]})
      db = lancedb.connect("~/lancedb")
      tbl = db.create_table("test", schema=TextModel, mode="overwrite")
  
      tbl.add(df)
      assert len(tbl.to_pandas()["vector"][0]) == cohere.ndims()
  
  
  @pytest.mark.slow
  def test_instructor_embedding(tmp_path):
      model = get_registry().get("instructor").create(max_retries=0)
  
      class TextModel(LanceModel):
          text: str = model.SourceField()
          vector: Vector(model.ndims()) = model.VectorField()
  
      df = pd.DataFrame({"text": ["hello world", "goodbye world"]})
      db = lancedb.connect(tmp_path)
      tbl = db.create_table("test", schema=TextModel, mode="overwrite")
  
      tbl.add(df)
      assert len(tbl.to_pandas()["vector"][0]) == model.ndims()
  
  
  @pytest.mark.slow
  @pytest.mark.skipif(
      os.environ.get("GOOGLE_API_KEY") is None, reason="GOOGLE_API_KEY not set"
  )
  def test_gemini_embedding(tmp_path):
      model = get_registry().get("gemini-text").create(max_retries=0)
  
      class TextModel(LanceModel):
          text: str = model.SourceField()
          vector: Vector(model.ndims()) = model.VectorField()
  
      df = pd.DataFrame({"text": ["hello world", "goodbye world"]})
      db = lancedb.connect(tmp_path)
      tbl = db.create_table("test", schema=TextModel, mode="overwrite")
  
      tbl.add(df)
      assert len(tbl.to_pandas()["vector"][0]) == model.ndims()
      assert tbl.search("hello").limit(1).to_pandas()["text"][0] == "hello world"
  
  
  @pytest.mark.skipif(
      _mlx is None,
      reason="mlx tests only required for apple users.",
  )
  @pytest.mark.slow
  def test_gte_embedding(tmp_path):
      import lancedb.embeddings.gte
  
      model = get_registry().get("gte-text").create()
  
      class TextModel(LanceModel):
          text: str = model.SourceField()
          vector: Vector(model.ndims()) = model.VectorField()
  
      df = pd.DataFrame({"text": ["hello world", "goodbye world"]})
      db = lancedb.connect(tmp_path)
      tbl = db.create_table("test", schema=TextModel, mode="overwrite")
  
      tbl.add(df)
      assert len(tbl.to_pandas()["vector"][0]) == model.ndims()
      assert tbl.search("hello").limit(1).to_pandas()["text"][0] == "hello world"
  
  
  def aws_setup():
      try:
          import boto3
  
          sts = boto3.client("sts")
          sts.get_caller_identity()
          return True
      except Exception:
          return False
  
  
  @pytest.mark.slow
  @pytest.mark.skipif(
      not aws_setup(), reason="AWS credentials not set or libraries not installed"
  )
  def test_bedrock_embedding(tmp_path):
      for name in [
          "amazon.titan-embed-text-v1",
          "cohere.embed-english-v3",
          "cohere.embed-multilingual-v3",
      ]:
          model = get_registry().get("bedrock-text").create(max_retries=0, name=name)
  
          class TextModel(LanceModel):
              text: str = model.SourceField()
              vector: Vector(model.ndims()) = model.VectorField()
  
          df = pd.DataFrame({"text": ["hello world", "goodbye world"]})
          db = lancedb.connect(tmp_path)
          tbl = db.create_table("test", schema=TextModel, mode="overwrite")
  
          tbl.add(df)
          assert len(tbl.to_pandas()["vector"][0]) == model.ndims()
  
  
  @pytest.mark.slow
  @pytest.mark.skipif(
      os.environ.get("OPENAI_API_KEY") is None, reason="OPENAI_API_KEY not set"
  )
  def test_openai_embedding(tmp_path):
      def _get_table(model):
          class TextModel(LanceModel):
              text: str = model.SourceField()
              vector: Vector(model.ndims()) = model.VectorField()
  
          db = lancedb.connect(tmp_path)
          tbl = db.create_table("test", schema=TextModel, mode="overwrite")
  
          return tbl
  
      model = get_registry().get("openai").create(max_retries=0)
      tbl = _get_table(model)
      df = pd.DataFrame({"text": ["hello world", "goodbye world"]})
  
      tbl.add(df)
      assert len(tbl.to_pandas()["vector"][0]) == model.ndims()
      assert tbl.search("hello").limit(1).to_pandas()["text"][0] == "hello world"
  
      model = (
          get_registry()
          .get("openai")
          .create(max_retries=0, name="text-embedding-3-large")
      )
      tbl = _get_table(model)
  
      tbl.add(df)
      assert len(tbl.to_pandas()["vector"][0]) == model.ndims()
      assert tbl.search("hello").limit(1).to_pandas()["text"][0] == "hello world"
  
      model = (
          get_registry()
          .get("openai")
          .create(max_retries=0, name="text-embedding-3-large", dim=1024)
      )
      tbl = _get_table(model)
  
      tbl.add(df)
      assert len(tbl.to_pandas()["vector"][0]) == model.ndims()
      assert tbl.search("hello").limit(1).to_pandas()["text"][0] == "hello world"
  
apis: lancedb.connect lancedb.embeddings.get_registry
extract_api: [((1288, 1357), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""alias"""', "['sentence-transformers', 'openai']"], {}), "('alias', ['sentence-transformers', 'openai'])\n", (1311, 1357), False, 'import pytest\n'), ((5687, 5773), 'pytest.mark.skipif', 'pytest.mark.skipif', (['(_imagebind is None)'], {'reason': '"""skip if imagebind not installed."""'}), "(_imagebind is None, reason=\n    'skip if imagebind not installed.')\n", (5705, 5773), False, 'import pytest\n'), ((10771, 10859), 'pytest.mark.skipif', 'pytest.mark.skipif', (['(_mlx is None)'], {'reason': '"""mlx tests only required for apple users."""'}), "(_mlx is None, reason=\n    'mlx tests only required for apple users.')\n", (10789, 10859), False, 'import pytest\n'), ((1416, 1441), 'lancedb.connect', 'lancedb.connect', (['tmp_path'], {}), '(tmp_path)\n', (1431, 1441), False, 'import lancedb\n'), ((1457, 1471), 'lancedb.embeddings.get_registry', 'get_registry', ([], {}), '()\n', (1469, 1471), False, 'from lancedb.embeddings import get_registry\n'), ((3273, 3298), 'lancedb.connect', 'lancedb.connect', (['tmp_path'], {}), '(tmp_path)\n', (3288, 3298), False, 'import lancedb\n'), ((3314, 3328), 'lancedb.embeddings.get_registry', 'get_registry', ([], {}), '()\n', (3326, 3328), False, 'from lancedb.embeddings import get_registry\n'), ((4825, 4869), 'numpy.allclose', 'np.allclose', (['actual.vector', 'frombytes.vector'], {}), '(actual.vector, frombytes.vector)\n', (4836, 4869), True, 'import numpy as np\n'), ((8732, 8755), 'os.path.isdir', 'os.path.isdir', (['temp_dir'], {}), '(temp_dir)\n', (8745, 8755), False, 'import os\n'), ((9319, 9375), 'pandas.DataFrame', 'pd.DataFrame', (["{'text': ['hello world', 'goodbye world']}"], {}), "({'text': ['hello world', 'goodbye world']})\n", (9331, 9375), True, 'import pandas as pd\n'), ((9385, 9413), 'lancedb.connect', 'lancedb.connect', (['"""~/lancedb"""'], {}), "('~/lancedb')\n", (9400, 9413), False, 'import lancedb\n'), ((9836, 9892), 'pandas.DataFrame', 'pd.DataFrame', (["{'text': ['hello world', 'goodbye world']}"], {}), "({'text': ['hello world', 'goodbye world']})\n", (9848, 9892), True, 'import pandas as pd\n'), ((9902, 9927), 'lancedb.connect', 'lancedb.connect', (['tmp_path'], {}), '(tmp_path)\n', (9917, 9927), False, 'import lancedb\n'), ((10447, 10503), 'pandas.DataFrame', 'pd.DataFrame', (["{'text': ['hello world', 'goodbye world']}"], {}), "({'text': ['hello world', 'goodbye world']})\n", (10459, 10503), True, 'import pandas as pd\n'), ((10513, 10538), 'lancedb.connect', 'lancedb.connect', (['tmp_path'], {}), '(tmp_path)\n', (10528, 10538), False, 'import lancedb\n'), ((11149, 11205), 'pandas.DataFrame', 'pd.DataFrame', (["{'text': ['hello world', 'goodbye world']}"], {}), "({'text': ['hello world', 'goodbye world']})\n", (11161, 11205), True, 'import pandas as pd\n'), ((11215, 11240), 'lancedb.connect', 'lancedb.connect', (['tmp_path'], {}), '(tmp_path)\n', (11230, 11240), False, 'import lancedb\n'), ((13017, 13073), 'pandas.DataFrame', 'pd.DataFrame', (["{'text': ['hello world', 'goodbye world']}"], {}), "({'text': ['hello world', 'goodbye world']})\n", (13029, 13073), True, 'import pandas as pd\n'), ((967, 1003), 'importlib.util.find_spec', 'importlib.util.find_spec', (['"""mlx.core"""'], {}), "('mlx.core')\n", (991, 1003), False, 'import importlib\n'), ((1114, 1151), 'importlib.util.find_spec', 'importlib.util.find_spec', (['"""imagebind"""'], {}), "('imagebind')\n", (1138, 1151), False, 'import importlib\n'), ((1883, 2169), 'pandas.DataFrame', 'pd.DataFrame', (["{'text': ['hello world', 'goodbye world', 'fizz', 'buzz', 'foo', 'bar',\n    'baz'], 'text2': ['to be or not to be', 'that is the question',\n    'for whether tis nobler', 'in the mind to suffer',\n    'the slings and arrows', 'of outrageous fortune', 'or to take arms']}"], {}), "({'text': ['hello world', 'goodbye world', 'fizz', 'buzz',\n    'foo', 'bar', 'baz'], 'text2': ['to be or not to be',\n    'that is the question', 'for whether tis nobler',\n    'in the mind to suffer', 'the slings and arrows',\n    'of outrageous fortune', 'or to take arms']})\n", (1895, 2169), True, 'import pandas as pd\n'), ((2936, 2978), 'numpy.allclose', 'np.allclose', (['actual.vector', 'actual.vector2'], {}), '(actual.vector, actual.vector2)\n', (2947, 2978), True, 'import numpy as np\n'), ((3145, 3187), 'numpy.allclose', 'np.allclose', (['actual.vector', 'actual.vector2'], {}), '(actual.vector, actual.vector2)\n', (3156, 3187), True, 'import numpy as np\n'), ((4339, 4417), 'pandas.DataFrame', 'pd.DataFrame', (["{'label': labels, 'image_uri': uris, 'image_bytes': image_bytes}"], {}), "({'label': labels, 'image_uri': uris, 'image_bytes': image_bytes})\n", (4351, 4417), True, 'import pandas as pd\n'), ((4993, 5022), 'requests.get', 'requests.get', (['query_image_uri'], {}), '(query_image_uri)\n', (5005, 5022), False, 'import requests\n'), ((5060, 5083), 'io.BytesIO', 'io.BytesIO', (['image_bytes'], {}), '(image_bytes)\n', (5070, 5083), False, 'import io\n'), ((6075, 6104), 'tempfile.TemporaryDirectory', 'tempfile.TemporaryDirectory', ([], {}), '()\n', (6102, 6104), False, 'import tempfile\n'), ((7003, 7028), 'lancedb.connect', 'lancedb.connect', (['tmp_path'], {}), '(tmp_path)\n', (7018, 7028), False, 'import lancedb\n'), ((7048, 7062), 'lancedb.embeddings.get_registry', 'get_registry', ([], {}), '()\n', (7060, 7062), False, 'from lancedb.embeddings import get_registry\n'), ((8765, 8788), 'shutil.rmtree', 'shutil.rmtree', (['temp_dir'], {}), '(temp_dir)\n', (8778, 8788), False, 'import shutil\n'), ((8891, 8923), 'os.environ.get', 'os.environ.get', (['"""COHERE_API_KEY"""'], {}), "('COHERE_API_KEY')\n", (8905, 8923), False, 'import os\n'), ((10122, 10154), 'os.environ.get', 'os.environ.get', (['"""GOOGLE_API_KEY"""'], {}), "('GOOGLE_API_KEY')\n", (10136, 10154), False, 'import os\n'), ((11534, 11553), 'boto3.client', 'boto3.client', (['"""sts"""'], {}), "('sts')\n", (11546, 11553), False, 'import boto3\n'), ((12195, 12251), 'pandas.DataFrame', 'pd.DataFrame', (["{'text': ['hello world', 'goodbye world']}"], {}), "({'text': ['hello world', 'goodbye world']})\n", (12207, 12251), True, 'import pandas as pd\n'), ((12265, 12290), 'lancedb.connect', 'lancedb.connect', (['tmp_path'], {}), '(tmp_path)\n', (12280, 12290), False, 'import lancedb\n'), ((12796, 12821), 'lancedb.connect', 'lancedb.connect', (['tmp_path'], {}), '(tmp_path)\n', (12811, 12821), False, 'import lancedb\n'), ((12497, 12529), 'os.environ.get', 'os.environ.get', (['"""OPENAI_API_KEY"""'], {}), "('OPENAI_API_KEY')\n", (12511, 12529), False, 'import os\n'), ((4273, 4290), 'requests.get', 'requests.get', (['uri'], {}), '(uri)\n', (4285, 4290), False, 'import requests\n'), ((7984, 8047), 'pandas.DataFrame', 'pd.DataFrame', (["{'label': labels, 'image_uri': downloaded_images}"], {}), "({'label': labels, 'image_uri': downloaded_images})\n", (7996, 8047), True, 'import pandas as pd\n'), ((6344, 6374), 'requests.get', 'requests.get', (['uri'], {'stream': '(True)'}), '(uri, stream=True)\n', (6356, 6374), False, 'import requests\n'), ((9065, 9079), 'lancedb.embeddings.get_registry', 'get_registry', ([], {}), '()\n', (9077, 9079), False, 'from lancedb.embeddings import get_registry\n'), ((9637, 9651), 'lancedb.embeddings.get_registry', 'get_registry', ([], {}), '()\n', (9649, 9651), False, 'from lancedb.embeddings import get_registry\n'), ((10247, 10261), 'lancedb.embeddings.get_registry', 'get_registry', ([], {}), '()\n', (10259, 10261), False, 'from lancedb.embeddings import get_registry\n'), ((10965, 10979), 'lancedb.embeddings.get_registry', 'get_registry', ([], {}), '()\n', (10977, 10979), False, 'from lancedb.embeddings import get_registry\n'), ((12929, 12943), 'lancedb.embeddings.get_registry', 'get_registry', ([], {}), '()\n', (12941, 12943), False, 'from lancedb.embeddings import get_registry\n'), ((13256, 13270), 'lancedb.embeddings.get_registry', 'get_registry', ([], {}), '()\n', (13268, 13270), False, 'from lancedb.embeddings import get_registry\n'), ((13572, 13586), 'lancedb.embeddings.get_registry', 'get_registry', ([], {}), '()\n', (13584, 13586), False, 'from lancedb.embeddings import get_registry\n'), ((6518, 6539), 'os.path.basename', 'os.path.basename', (['uri'], {}), '(uri)\n', (6534, 6539), False, 'import os\n'), ((6577, 6611), 'os.path.join', 'os.path.join', (['temp_dir', 'image_name'], {}), '(temp_dir, image_name)\n', (6589, 6611), False, 'import os\n'), ((11967, 11981), 'lancedb.embeddings.get_registry', 'get_registry', ([], {}), '()\n', (11979, 11981), False, 'from lancedb.embeddings import get_registry\n'), ((6705, 6747), 'shutil.copyfileobj', 'shutil.copyfileobj', (['response.raw', 'out_file'], {}), '(response.raw, out_file)\n', (6723, 6747), False, 'import shutil\n')]