prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [0.26.0] openai/cli.py:440: RuntimeWarning: coroutine 'FineTune.stream_events' was never awaited
  ```
  bash$ openai api fine_tunes.create -t ./train_test_prepared.jsonl -m davinci
  Upload progress: 100%|██████████████████████████████████████████████████████████████████████████████| 112/112 [00:00<00:00, 88.5kit/s]
  Uploaded file from ./train_test_prepared.jsonl: file-ppEDNe0p6EomteEp3JFbBoFp
  Created fine-tune: ft-u9KskmmvSnBtVc4VDfbe7lyr
  Streaming events until fine-tuning is complete...
  
  (Ctrl-C will interrupt the stream, but not cancel the fine-tune)
  
  Stream interrupted (client disconnected).
  To resume the stream, run:
  
    openai api fine_tunes.follow -i ft-u9KskmmvSnBtVc4VDfbe7lyr
  
  /usr/lib/python3.10/site-packages/openai/cli.py:406: RuntimeWarning: coroutine 'FineTune.stream_events' was never awaited
    cls._stream_events(resp["id"])
  RuntimeWarning: Enable tracemalloc to get the object allocation traceback
  
  ```
  
  it is working fine with 0.25.0
  
  may be related:  dev-python/aiohttp-3.8.3
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `openai/api_resources/fine_tune.py`
  Content:
  ```
  1 from urllib.parse import quote_plus
  2 
  3 from openai import api_requestor, util, error
  4 from openai.api_resources.abstract import (
  5     CreateableAPIResource,
  6     ListableAPIResource,
  7     nested_resource_class_methods,
  8 )
  9 from openai.api_resources.abstract.deletable_api_resource import DeletableAPIResource
  10 from openai.openai_response import OpenAIResponse
  11 from openai.util import ApiType
  12 
  13 
  14 @nested_resource_class_methods("event", operations=["list"])
  15 class FineTune(ListableAPIResource, CreateableAPIResource, DeletableAPIResource):
  16     OBJECT_NAME = "fine-tunes"
  17 
  18     @classmethod
  19     def _prepare_cancel(
  20         cls,
  21         id,
  22         api_key=None,
  23         api_type=None,
  24         request_id=None,
  25         api_version=None,
  26         **params,
  27     ):
  28         base = cls.class_url()
  29         extn = quote_plus(id)
  30 
  31         typed_api_type, api_version = cls._get_api_type_and_version(
  32             api_type, api_version
  33         )
  34         if typed_api_type in (ApiType.AZURE, ApiType.AZURE_AD):
  35             url = "/%s%s/%s/cancel?api-version=%s" % (
  36                 cls.azure_api_prefix,
  37                 base,
  38                 extn,
  39                 api_version,
  40             )
  41         elif typed_api_type == ApiType.OPEN_AI:
  42             url = "%s/%s/cancel" % (base, extn)
  43         else:
  44             raise error.InvalidAPIType("Unsupported API type %s" % api_type)
  45 
  46         instance = cls(id, api_key, **params)
  47         return instance, url
  48 
  49     @classmethod
  50     def cancel(
  51         cls,
  52         id,
  53         api_key=None,
  54         api_type=None,
  55         request_id=None,
  56         api_version=None,
  57         **params,
  58     ):
  59         instance, url = cls._prepare_cancel(
  60             id,
  61             api_key,
  62             api_type,
  63             request_id,
  64             api_version,
  65             **params,
  66         )
  67         return instance.request("post", url, request_id=request_id)
  68 
  69     @classmethod
  70     def acancel(
  71         cls,
  72         id,
  73         api_key=None,
  74         api_type=None,
  75         request_id=None,
  76         api_version=None,
  77         **params,
  78     ):
  79         instance, url = cls._prepare_cancel(
  80             id,
  81             api_key,
  82             api_type,
  83             request_id,
  84             api_version,
  85             **params,
  86         )
  87         return instance.arequest("post", url, request_id=request_id)
  88 
  89     @classmethod
  90     def _prepare_stream_events(
  91         cls,
  92         id,
  93         api_key=None,
  94         api_base=None,
  95         api_type=None,
  96         request_id=None,
  97         api_version=None,
  98         organization=None,
  99         **params,
  100     ):
  101         base = cls.class_url()
  102         extn = quote_plus(id)
  103 
  104         requestor = api_requestor.APIRequestor(
  105             api_key,
  106             api_base=api_base,
  107             api_type=api_type,
  108             api_version=api_version,
  109             organization=organization,
  110         )
  111 
  112         typed_api_type, api_version = cls._get_api_type_and_version(
  113             api_type, api_version
  114         )
  115 
  116         if typed_api_type in (ApiType.AZURE, ApiType.AZURE_AD):
  117             url = "/%s%s/%s/events?stream=true&api-version=%s" % (
  118                 cls.azure_api_prefix,
  119                 base,
  120                 extn,
  121                 api_version,
  122             )
  123         elif typed_api_type == ApiType.OPEN_AI:
  124             url = "%s/%s/events?stream=true" % (base, extn)
  125         else:
  126             raise error.InvalidAPIType("Unsupported API type %s" % api_type)
  127 
  128         return requestor, url
  129 
  130     @classmethod
  131     async def stream_events(
  132         cls,
  133         id,
  134         api_key=None,
  135         api_base=None,
  136         api_type=None,
  137         request_id=None,
  138         api_version=None,
  139         organization=None,
  140         **params,
  141     ):
  142         requestor, url = cls._prepare_stream_events(
  143             id,
  144             api_key,
  145             api_base,
  146             api_type,
  147             request_id,
  148             api_version,
  149             organization,
  150             **params,
  151         )
  152 
  153         response, _, api_key = await requestor.arequest(
  154             "get", url, params, stream=True, request_id=request_id
  155         )
  156 
  157         assert not isinstance(response, OpenAIResponse)  # must be an iterator
  158         return (
  159             util.convert_to_openai_object(
  160                 line,
  161                 api_key,
  162                 api_version,
  163                 organization,
  164             )
  165             for line in response
  166         )
  167
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/openai/api_resources/fine_tune.py b/openai/api_resources/fine_tune.py
  --- a/openai/api_resources/fine_tune.py
  +++ b/openai/api_resources/fine_tune.py
  @@ -128,7 +128,45 @@
           return requestor, url
   
       @classmethod
  -    async def stream_events(
  +    def stream_events(
  +        cls,
  +        id,
  +        api_key=None,
  +        api_base=None,
  +        api_type=None,
  +        request_id=None,
  +        api_version=None,
  +        organization=None,
  +        **params,
  +    ):
  +        requestor, url = cls._prepare_stream_events(
  +            id,
  +            api_key,
  +            api_base,
  +            api_type,
  +            request_id,
  +            api_version,
  +            organization,
  +            **params,
  +        )
  +
  +        response, _, api_key = requestor.request(
  +            "get", url, params, stream=True, request_id=request_id
  +        )
  +
  +        assert not isinstance(response, OpenAIResponse)  # must be an iterator
  +        return (
  +            util.convert_to_openai_object(
  +                line,
  +                api_key,
  +                api_version,
  +                organization,
  +            )
  +            for line in response
  +        )
  +
  +    @classmethod
  +    async def astream_events(
           cls,
           id,
           api_key=None,
  
verification_info: {"golden_diff": "diff --git a/openai/api_resources/fine_tune.py b/openai/api_resources/fine_tune.py\n--- a/openai/api_resources/fine_tune.py\n+++ b/openai/api_resources/fine_tune.py\n@@ -128,7 +128,45 @@\n         return requestor, url\n \n     @classmethod\n-    async def stream_events(\n+    def stream_events(\n+        cls,\n+        id,\n+        api_key=None,\n+        api_base=None,\n+        api_type=None,\n+        request_id=None,\n+        api_version=None,\n+        organization=None,\n+        **params,\n+    ):\n+        requestor, url = cls._prepare_stream_events(\n+            id,\n+            api_key,\n+            api_base,\n+            api_type,\n+            request_id,\n+            api_version,\n+            organization,\n+            **params,\n+        )\n+\n+        response, _, api_key = requestor.request(\n+            \"get\", url, params, stream=True, request_id=request_id\n+        )\n+\n+        assert not isinstance(response, OpenAIResponse)  # must be an iterator\n+        return (\n+            util.convert_to_openai_object(\n+                line,\n+                api_key,\n+                api_version,\n+                organization,\n+            )\n+            for line in response\n+        )\n+\n+    @classmethod\n+    async def astream_events(\n         cls,\n         id,\n         api_key=None,\n", "issue": "[0.26.0] openai/cli.py:440: RuntimeWarning: coroutine 'FineTune.stream_events' was never awaited\n```\r\nbash$ openai api fine_tunes.create -t ./train_test_prepared.jsonl -m davinci\r\nUpload progress: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 112/112 [00:00<00:00, 88.5kit/s]\r\nUploaded file from ./train_test_prepared.jsonl: file-ppEDNe0p6EomteEp3JFbBoFp\r\nCreated fine-tune: ft-u9KskmmvSnBtVc4VDfbe7lyr\r\nStreaming events until fine-tuning is complete...\r\n\r\n(Ctrl-C will interrupt the stream, but not cancel the fine-tune)\r\n\r\nStream interrupted (client disconnected).\r\nTo resume the stream, run:\r\n\r\n  openai api fine_tunes.follow -i ft-u9KskmmvSnBtVc4VDfbe7lyr\r\n\r\n/usr/lib/python3.10/site-packages/openai/cli.py:406: RuntimeWarning: coroutine 'FineTune.stream_events' was never awaited\r\n  cls._stream_events(resp[\"id\"])\r\nRuntimeWarning: Enable tracemalloc to get the object allocation traceback\r\n\r\n```\r\n\r\nit is working fine with 0.25.0\r\n\r\nmay be related:  dev-python/aiohttp-3.8.3\r\n\n", "before_files": [{"content": "from urllib.parse import quote_plus\n\nfrom openai import api_requestor, util, error\nfrom openai.api_resources.abstract import (\n    CreateableAPIResource,\n    ListableAPIResource,\n    nested_resource_class_methods,\n)\nfrom openai.api_resources.abstract.deletable_api_resource import DeletableAPIResource\nfrom openai.openai_response import OpenAIResponse\nfrom openai.util import ApiType\n\n\n@nested_resource_class_methods(\"event\", operations=[\"list\"])\nclass FineTune(ListableAPIResource, CreateableAPIResource, DeletableAPIResource):\n    OBJECT_NAME = \"fine-tunes\"\n\n    @classmethod\n    def _prepare_cancel(\n        cls,\n        id,\n        api_key=None,\n        api_type=None,\n        request_id=None,\n        api_version=None,\n        **params,\n    ):\n        base = cls.class_url()\n        extn = quote_plus(id)\n\n        typed_api_type, api_version = cls._get_api_type_and_version(\n            api_type, api_version\n        )\n        if typed_api_type in (ApiType.AZURE, ApiType.AZURE_AD):\n            url = \"/%s%s/%s/cancel?api-version=%s\" % (\n                cls.azure_api_prefix,\n                base,\n                extn,\n                api_version,\n            )\n        elif typed_api_type == ApiType.OPEN_AI:\n            url = \"%s/%s/cancel\" % (base, extn)\n        else:\n            raise error.InvalidAPIType(\"Unsupported API type %s\" % api_type)\n\n        instance = cls(id, api_key, **params)\n        return instance, url\n\n    @classmethod\n    def cancel(\n        cls,\n        id,\n        api_key=None,\n        api_type=None,\n        request_id=None,\n        api_version=None,\n        **params,\n    ):\n        instance, url = cls._prepare_cancel(\n            id,\n            api_key,\n            api_type,\n            request_id,\n            api_version,\n            **params,\n        )\n        return instance.request(\"post\", url, request_id=request_id)\n\n    @classmethod\n    def acancel(\n        cls,\n        id,\n        api_key=None,\n        api_type=None,\n        request_id=None,\n        api_version=None,\n        **params,\n    ):\n        instance, url = cls._prepare_cancel(\n            id,\n            api_key,\n            api_type,\n            request_id,\n            api_version,\n            **params,\n        )\n        return instance.arequest(\"post\", url, request_id=request_id)\n\n    @classmethod\n    def _prepare_stream_events(\n        cls,\n        id,\n        api_key=None,\n        api_base=None,\n        api_type=None,\n        request_id=None,\n        api_version=None,\n        organization=None,\n        **params,\n    ):\n        base = cls.class_url()\n        extn = quote_plus(id)\n\n        requestor = api_requestor.APIRequestor(\n            api_key,\n            api_base=api_base,\n            api_type=api_type,\n            api_version=api_version,\n            organization=organization,\n        )\n\n        typed_api_type, api_version = cls._get_api_type_and_version(\n            api_type, api_version\n        )\n\n        if typed_api_type in (ApiType.AZURE, ApiType.AZURE_AD):\n            url = \"/%s%s/%s/events?stream=true&api-version=%s\" % (\n                cls.azure_api_prefix,\n                base,\n                extn,\n                api_version,\n            )\n        elif typed_api_type == ApiType.OPEN_AI:\n            url = \"%s/%s/events?stream=true\" % (base, extn)\n        else:\n            raise error.InvalidAPIType(\"Unsupported API type %s\" % api_type)\n\n        return requestor, url\n\n    @classmethod\n    async def stream_events(\n        cls,\n        id,\n        api_key=None,\n        api_base=None,\n        api_type=None,\n        request_id=None,\n        api_version=None,\n        organization=None,\n        **params,\n    ):\n        requestor, url = cls._prepare_stream_events(\n            id,\n            api_key,\n            api_base,\n            api_type,\n            request_id,\n            api_version,\n            organization,\n            **params,\n        )\n\n        response, _, api_key = await requestor.arequest(\n            \"get\", url, params, stream=True, request_id=request_id\n        )\n\n        assert not isinstance(response, OpenAIResponse)  # must be an iterator\n        return (\n            util.convert_to_openai_object(\n                line,\n                api_key,\n                api_version,\n                organization,\n            )\n            for line in response\n        )\n", "path": "openai/api_resources/fine_tune.py"}], "after_files": [{"content": "from urllib.parse import quote_plus\n\nfrom openai import api_requestor, util, error\nfrom openai.api_resources.abstract import (\n    CreateableAPIResource,\n    ListableAPIResource,\n    nested_resource_class_methods,\n)\nfrom openai.api_resources.abstract.deletable_api_resource import DeletableAPIResource\nfrom openai.openai_response import OpenAIResponse\nfrom openai.util import ApiType\n\n\n@nested_resource_class_methods(\"event\", operations=[\"list\"])\nclass FineTune(ListableAPIResource, CreateableAPIResource, DeletableAPIResource):\n    OBJECT_NAME = \"fine-tunes\"\n\n    @classmethod\n    def _prepare_cancel(\n        cls,\n        id,\n        api_key=None,\n        api_type=None,\n        request_id=None,\n        api_version=None,\n        **params,\n    ):\n        base = cls.class_url()\n        extn = quote_plus(id)\n\n        typed_api_type, api_version = cls._get_api_type_and_version(\n            api_type, api_version\n        )\n        if typed_api_type in (ApiType.AZURE, ApiType.AZURE_AD):\n            url = \"/%s%s/%s/cancel?api-version=%s\" % (\n                cls.azure_api_prefix,\n                base,\n                extn,\n                api_version,\n            )\n        elif typed_api_type == ApiType.OPEN_AI:\n            url = \"%s/%s/cancel\" % (base, extn)\n        else:\n            raise error.InvalidAPIType(\"Unsupported API type %s\" % api_type)\n\n        instance = cls(id, api_key, **params)\n        return instance, url\n\n    @classmethod\n    def cancel(\n        cls,\n        id,\n        api_key=None,\n        api_type=None,\n        request_id=None,\n        api_version=None,\n        **params,\n    ):\n        instance, url = cls._prepare_cancel(\n            id,\n            api_key,\n            api_type,\n            request_id,\n            api_version,\n            **params,\n        )\n        return instance.request(\"post\", url, request_id=request_id)\n\n    @classmethod\n    def acancel(\n        cls,\n        id,\n        api_key=None,\n        api_type=None,\n        request_id=None,\n        api_version=None,\n        **params,\n    ):\n        instance, url = cls._prepare_cancel(\n            id,\n            api_key,\n            api_type,\n            request_id,\n            api_version,\n            **params,\n        )\n        return instance.arequest(\"post\", url, request_id=request_id)\n\n    @classmethod\n    def _prepare_stream_events(\n        cls,\n        id,\n        api_key=None,\n        api_base=None,\n        api_type=None,\n        request_id=None,\n        api_version=None,\n        organization=None,\n        **params,\n    ):\n        base = cls.class_url()\n        extn = quote_plus(id)\n\n        requestor = api_requestor.APIRequestor(\n            api_key,\n            api_base=api_base,\n            api_type=api_type,\n            api_version=api_version,\n            organization=organization,\n        )\n\n        typed_api_type, api_version = cls._get_api_type_and_version(\n            api_type, api_version\n        )\n\n        if typed_api_type in (ApiType.AZURE, ApiType.AZURE_AD):\n            url = \"/%s%s/%s/events?stream=true&api-version=%s\" % (\n                cls.azure_api_prefix,\n                base,\n                extn,\n                api_version,\n            )\n        elif typed_api_type == ApiType.OPEN_AI:\n            url = \"%s/%s/events?stream=true\" % (base, extn)\n        else:\n            raise error.InvalidAPIType(\"Unsupported API type %s\" % api_type)\n\n        return requestor, url\n\n    @classmethod\n    def stream_events(\n        cls,\n        id,\n        api_key=None,\n        api_base=None,\n        api_type=None,\n        request_id=None,\n        api_version=None,\n        organization=None,\n        **params,\n    ):\n        requestor, url = cls._prepare_stream_events(\n            id,\n            api_key,\n            api_base,\n            api_type,\n            request_id,\n            api_version,\n            organization,\n            **params,\n        )\n\n        response, _, api_key = requestor.request(\n            \"get\", url, params, stream=True, request_id=request_id\n        )\n\n        assert not isinstance(response, OpenAIResponse)  # must be an iterator\n        return (\n            util.convert_to_openai_object(\n                line,\n                api_key,\n                api_version,\n                organization,\n            )\n            for line in response\n        )\n\n    @classmethod\n    async def astream_events(\n        cls,\n        id,\n        api_key=None,\n        api_base=None,\n        api_type=None,\n        request_id=None,\n        api_version=None,\n        organization=None,\n        **params,\n    ):\n        requestor, url = cls._prepare_stream_events(\n            id,\n            api_key,\n            api_base,\n            api_type,\n            request_id,\n            api_version,\n            organization,\n            **params,\n        )\n\n        response, _, api_key = await requestor.arequest(\n            \"get\", url, params, stream=True, request_id=request_id\n        )\n\n        assert not isinstance(response, OpenAIResponse)  # must be an iterator\n        return (\n            util.convert_to_openai_object(\n                line,\n                api_key,\n                api_version,\n                organization,\n            )\n            for line in response\n        )\n", "path": "openai/api_resources/fine_tune.py"}]}