Skip to content

Commit 2c3c773

Browse files
authored
Merge pull request #41 from Bobholamovic/dev/agent
Fix Gradio Demo Bugs
2 parents c6e29f9 + 6483c82 commit 2c3c773

File tree

6 files changed

+336
-398
lines changed

6 files changed

+336
-398
lines changed

erniebot/auth.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,10 @@ def retrieve_entry(self, api_type: str,
6969

7070
return key, val
7171

72-
def add_or_update_entry(
73-
self,
74-
api_type: str,
75-
key: Hashable,
76-
value: Union[str, Callable[[], str]]) -> Optional[str]:
72+
def upsert_entry(self,
73+
api_type: str,
74+
key: Hashable,
75+
value: Union[str, Callable[[], str]]) -> Optional[str]:
7776
with self._cond:
7877
self._writes += 1
7978
while self._reads > 0 or self._is_writing:
@@ -167,7 +166,7 @@ def _retrieve_from_cache(self) -> Optional[str]:
167166
self._cache_key)[1]
168167

169168
def _update_cache(self, init: bool) -> str:
170-
token = _GlobalAuthCache().add_or_update_entry(
169+
token = _GlobalAuthCache().upsert_entry(
171170
self.api_type.name,
172171
self._cache_key,
173172
functools.partial(

erniebot/resources/abc/cancellable.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import abc
1516
from typing import (Any, Dict, Optional, Tuple)
1617

17-
from typing_extensions import Protocol, runtime_checkable
18-
1918
from erniebot.response import EBResponse
2019
from erniebot.types import (ParamsType, HeadersType)
2120
from .protocol import Resource
2221

2322

24-
@runtime_checkable
25-
class Cancellable(Resource, Protocol):
26-
"""Cancellable resource protocol."""
23+
class Cancellable(Resource):
24+
"""Cancellable resource."""
2725

2826
@classmethod
2927
def cancel(cls, **kwargs: Any) -> EBResponse:
@@ -68,6 +66,7 @@ async def acancel_resource(self, **cancel_kwargs: Any) -> EBResponse:
6866
resp = self._postprocess_cancel(resp)
6967
return resp
7068

69+
@abc.abstractmethod
7170
def _prepare_cancel(self,
7271
kwargs: Dict[str, Any]) -> Tuple[str,
7372
Optional[ParamsType],

erniebot/resources/abc/creatable.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import abc
1516
from typing import (Any, AsyncIterator, Dict, Iterator, Optional, Tuple, Union)
1617

17-
from typing_extensions import Protocol, runtime_checkable
18-
1918
from erniebot.response import EBResponse
2019
from erniebot.types import (ParamsType, HeadersType, FilesType, ResponseT)
2120
from .protocol import Resource
2221

2322

24-
@runtime_checkable
25-
class Creatable(Resource, Protocol):
26-
"""Creatable resource protocol."""
23+
class Creatable(Resource):
24+
"""Creatable resource."""
2725

2826
@classmethod
2927
def create(cls, **kwargs: Any) -> Union[EBResponse, Iterator[EBResponse]]:
@@ -76,6 +74,7 @@ async def acreate_resource(
7674
resp = self._postprocess_create(resp) # type: ignore
7775
return resp
7876

77+
@abc.abstractmethod
7978
def _prepare_create(self,
8079
kwargs: Dict[str, Any]) -> Tuple[str,
8180
Optional[ParamsType],

erniebot/resources/abc/queryable.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import abc
1516
from typing import (Any, Dict, Optional, Tuple)
1617

17-
from typing_extensions import Protocol, runtime_checkable
18-
1918
from erniebot.response import EBResponse
2019
from erniebot.types import (ParamsType, HeadersType)
2120
from .protocol import Resource
2221

2322

24-
@runtime_checkable
25-
class Queryable(Resource, Protocol):
26-
"""Queryable resource protocol."""
23+
class Queryable(Resource):
24+
"""Queryable resource."""
2725

2826
@classmethod
2927
def query(cls, **kwargs: Any) -> EBResponse:
@@ -68,6 +66,7 @@ async def aquery_resource(self, **query_kwargs: Any) -> EBResponse:
6866
resp = self._postprocess_query(resp)
6967
return resp
7068

69+
@abc.abstractmethod
7170
def _prepare_query(self,
7271
kwargs: Dict[str, Any]) -> Tuple[str,
7372
Optional[ParamsType],

0 commit comments

Comments
 (0)