prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  BUG: UnicodeDecodeError caused by xinference/model/llm/llm_family.json
  ### Describe the bug
  Windows cmd runned xinference found Error: "**UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 8905: illegal multibyte sequence**"
  
  ### To Reproduce
  To help us to reproduce this bug, please provide information below:
  
  1. python version: 3.10
  2. xinference version: v0.1.0
  
  ### Expected behavior
  Edit the file: xinference/model/llm/__init__.py
  Line number: 129
  Add arg encoding: open(json_path, encoding='utf-8')
  
  
  
  
  </issue>
  <code>
  [start of xinference/model/llm/__init__.py]
  1 # Copyright 2022-2023 XProbe Inc.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #      http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 import json
  16 import logging
  17 import os
  18 import platform
  19 from typing import List, Optional, Tuple, Type
  20 
  21 from .core import LLM
  22 from .llm_family import (
  23     GgmlLLMSpecV1,
  24     LLMFamilyV1,
  25     LLMSpecV1,
  26     PromptStyleV1,
  27     PytorchLLMSpecV1,
  28 )
  29 
  30 _LLM_CLASSES: List[Type[LLM]] = []
  31 
  32 LLM_FAMILIES: List["LLMFamilyV1"] = []
  33 
  34 logger = logging.getLogger(__name__)
  35 
  36 
  37 def _is_linux():
  38     return platform.system() == "Linux"
  39 
  40 
  41 def _has_cuda_device():
  42     cuda_visible_devices = os.environ.get("CUDA_VISIBLE_DEVICES")
  43     if cuda_visible_devices:
  44         return True
  45     else:
  46         from xorbits._mars.resource import cuda_count
  47 
  48         return cuda_count() > 0
  49 
  50 
  51 def match_llm(
  52     model_name: str,
  53     model_format: Optional[str] = None,
  54     model_size_in_billions: Optional[int] = None,
  55     quantization: Optional[str] = None,
  56     is_local_deployment: bool = False,
  57 ) -> Optional[Tuple[LLMFamilyV1, LLMSpecV1, str]]:
  58     """
  59     Find an LLM family, spec, and quantization that satisfy given criteria.
  60     """
  61     for family in LLM_FAMILIES:
  62         if model_name != family.model_name:
  63             continue
  64         for spec in family.model_specs:
  65             if (
  66                 model_format
  67                 and model_format != spec.model_format
  68                 or model_size_in_billions
  69                 and model_size_in_billions != spec.model_size_in_billions
  70                 or quantization
  71                 and quantization not in spec.quantizations
  72             ):
  73                 continue
  74             if quantization:
  75                 return family, spec, quantization
  76             else:
  77                 # by default, choose the most coarse-grained quantization.
  78                 # TODO: too hacky.
  79                 quantizations = spec.quantizations
  80                 quantizations.sort()
  81                 for q in quantizations:
  82                     if (
  83                         is_local_deployment
  84                         and not (_is_linux() and _has_cuda_device())
  85                         and q == "4-bit"
  86                     ):
  87                         logger.warning(
  88                             "Skipping %s for non-linux or non-cuda local deployment .",
  89                             q,
  90                         )
  91                         continue
  92                     return family, spec, q
  93     return None
  94 
  95 
  96 def match_llm_cls(
  97     llm_family: LLMFamilyV1, llm_spec: "LLMSpecV1"
  98 ) -> Optional[Type[LLM]]:
  99     """
  100     Find an LLM implementation for given LLM family and spec.
  101     """
  102     for cls in _LLM_CLASSES:
  103         if cls.match(llm_family, llm_spec):
  104             return cls
  105     return None
  106 
  107 
  108 def _install():
  109     from .ggml.chatglm import ChatglmCppChatModel
  110     from .ggml.llamacpp import LlamaCppChatModel, LlamaCppModel
  111     from .pytorch.baichuan import BaichuanPytorchChatModel
  112     from .pytorch.chatglm import ChatglmPytorchChatModel
  113     from .pytorch.core import PytorchChatModel, PytorchModel
  114     from .pytorch.falcon import FalconPytorchChatModel, FalconPytorchModel
  115     from .pytorch.vicuna import VicunaPytorchChatModel
  116 
  117     _LLM_CLASSES.extend(
  118         [
  119             ChatglmCppChatModel,
  120             LlamaCppModel,
  121             LlamaCppChatModel,
  122             PytorchModel,
  123             PytorchChatModel,
  124             BaichuanPytorchChatModel,
  125             VicunaPytorchChatModel,
  126             FalconPytorchModel,
  127             FalconPytorchChatModel,
  128             ChatglmPytorchChatModel,
  129         ]
  130     )
  131 
  132     json_path = os.path.join(
  133         os.path.dirname(os.path.abspath(__file__)), "llm_family.json"
  134     )
  135     for json_obj in json.load(open(json_path)):
  136         LLM_FAMILIES.append(LLMFamilyV1.parse_obj(json_obj))
  137
  [end of xinference/model/llm/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/xinference/model/llm/__init__.py b/xinference/model/llm/__init__.py
  --- a/xinference/model/llm/__init__.py
  +++ b/xinference/model/llm/__init__.py
  @@ -12,6 +12,7 @@
   # See the License for the specific language governing permissions and
   # limitations under the License.
   
  +import codecs
   import json
   import logging
   import os
  @@ -132,5 +133,5 @@
       json_path = os.path.join(
           os.path.dirname(os.path.abspath(__file__)), "llm_family.json"
       )
  -    for json_obj in json.load(open(json_path)):
  +    for json_obj in json.load(codecs.open(json_path, "r", encoding="utf-8")):
           LLM_FAMILIES.append(LLMFamilyV1.parse_obj(json_obj))
  
verification_info: {"golden_diff": "diff --git a/xinference/model/llm/__init__.py b/xinference/model/llm/__init__.py\n--- a/xinference/model/llm/__init__.py\n+++ b/xinference/model/llm/__init__.py\n@@ -12,6 +12,7 @@\n # See the License for the specific language governing permissions and\n # limitations under the License.\n \n+import codecs\n import json\n import logging\n import os\n@@ -132,5 +133,5 @@\n     json_path = os.path.join(\n         os.path.dirname(os.path.abspath(__file__)), \"llm_family.json\"\n     )\n-    for json_obj in json.load(open(json_path)):\n+    for json_obj in json.load(codecs.open(json_path, \"r\", encoding=\"utf-8\")):\n         LLM_FAMILIES.append(LLMFamilyV1.parse_obj(json_obj))\n", "issue": "BUG: UnicodeDecodeError caused by xinference/model/llm/llm_family.json\n### Describe the bug\r\nWindows cmd runned xinference found Error: \"**UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 8905: illegal multibyte sequence**\"\r\n\r\n### To Reproduce\r\nTo help us to reproduce this bug, please provide information below:\r\n\r\n1. python version: 3.10\r\n2. xinference version: v0.1.0\r\n\r\n### Expected behavior\r\nEdit the file: xinference/model/llm/__init__.py\r\nLine number: 129\r\nAdd arg encoding: open(json_path, encoding='utf-8')\r\n\r\n\r\n\n", "before_files": [{"content": "# Copyright 2022-2023 XProbe Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport json\nimport logging\nimport os\nimport platform\nfrom typing import List, Optional, Tuple, Type\n\nfrom .core import LLM\nfrom .llm_family import (\n    GgmlLLMSpecV1,\n    LLMFamilyV1,\n    LLMSpecV1,\n    PromptStyleV1,\n    PytorchLLMSpecV1,\n)\n\n_LLM_CLASSES: List[Type[LLM]] = []\n\nLLM_FAMILIES: List[\"LLMFamilyV1\"] = []\n\nlogger = logging.getLogger(__name__)\n\n\ndef _is_linux():\n    return platform.system() == \"Linux\"\n\n\ndef _has_cuda_device():\n    cuda_visible_devices = os.environ.get(\"CUDA_VISIBLE_DEVICES\")\n    if cuda_visible_devices:\n        return True\n    else:\n        from xorbits._mars.resource import cuda_count\n\n        return cuda_count() > 0\n\n\ndef match_llm(\n    model_name: str,\n    model_format: Optional[str] = None,\n    model_size_in_billions: Optional[int] = None,\n    quantization: Optional[str] = None,\n    is_local_deployment: bool = False,\n) -> Optional[Tuple[LLMFamilyV1, LLMSpecV1, str]]:\n    \"\"\"\n    Find an LLM family, spec, and quantization that satisfy given criteria.\n    \"\"\"\n    for family in LLM_FAMILIES:\n        if model_name != family.model_name:\n            continue\n        for spec in family.model_specs:\n            if (\n                model_format\n                and model_format != spec.model_format\n                or model_size_in_billions\n                and model_size_in_billions != spec.model_size_in_billions\n                or quantization\n                and quantization not in spec.quantizations\n            ):\n                continue\n            if quantization:\n                return family, spec, quantization\n            else:\n                # by default, choose the most coarse-grained quantization.\n                # TODO: too hacky.\n                quantizations = spec.quantizations\n                quantizations.sort()\n                for q in quantizations:\n                    if (\n                        is_local_deployment\n                        and not (_is_linux() and _has_cuda_device())\n                        and q == \"4-bit\"\n                    ):\n                        logger.warning(\n                            \"Skipping %s for non-linux or non-cuda local deployment .\",\n                            q,\n                        )\n                        continue\n                    return family, spec, q\n    return None\n\n\ndef match_llm_cls(\n    llm_family: LLMFamilyV1, llm_spec: \"LLMSpecV1\"\n) -> Optional[Type[LLM]]:\n    \"\"\"\n    Find an LLM implementation for given LLM family and spec.\n    \"\"\"\n    for cls in _LLM_CLASSES:\n        if cls.match(llm_family, llm_spec):\n            return cls\n    return None\n\n\ndef _install():\n    from .ggml.chatglm import ChatglmCppChatModel\n    from .ggml.llamacpp import LlamaCppChatModel, LlamaCppModel\n    from .pytorch.baichuan import BaichuanPytorchChatModel\n    from .pytorch.chatglm import ChatglmPytorchChatModel\n    from .pytorch.core import PytorchChatModel, PytorchModel\n    from .pytorch.falcon import FalconPytorchChatModel, FalconPytorchModel\n    from .pytorch.vicuna import VicunaPytorchChatModel\n\n    _LLM_CLASSES.extend(\n        [\n            ChatglmCppChatModel,\n            LlamaCppModel,\n            LlamaCppChatModel,\n            PytorchModel,\n            PytorchChatModel,\n            BaichuanPytorchChatModel,\n            VicunaPytorchChatModel,\n            FalconPytorchModel,\n            FalconPytorchChatModel,\n            ChatglmPytorchChatModel,\n        ]\n    )\n\n    json_path = os.path.join(\n        os.path.dirname(os.path.abspath(__file__)), \"llm_family.json\"\n    )\n    for json_obj in json.load(open(json_path)):\n        LLM_FAMILIES.append(LLMFamilyV1.parse_obj(json_obj))\n", "path": "xinference/model/llm/__init__.py"}]}