|
12 | 12 | from io import TextIOWrapper, StringIO |
13 | 13 | from json import JSONDecodeError |
14 | 14 | from typing import Generic, Any, TypeVar |
15 | | -from collections.abc import Callable, Mapping |
| 15 | +from collections.abc import Awaitable, Callable, Mapping |
16 | 16 | import warnings |
17 | 17 |
|
18 | 18 | from pydantic import JsonValue, ValidationError |
@@ -1027,22 +1027,22 @@ def _is_method_overridden(self, method_name: str) -> bool: |
1027 | 1027 | # the method object directly from the Processor class, then it has been overridden. |
1028 | 1028 | return instance_class_method_obj is not base_class_method_obj |
1029 | 1029 |
|
1030 | | - async def _process_fallback(self, **kwargs) -> Result | Reject: |
| 1030 | + def _process_fallback(self, **kwargs) -> Result | Reject: |
1031 | 1031 | warnings.warn( |
1032 | 1032 | f"{type(self).__name__} uses the deprecated 'process' method. " |
1033 | 1033 | "Implement 'process_input' and/or 'process_response' instead.", |
1034 | 1034 | DeprecationWarning, |
1035 | 1035 | stacklevel=2, |
1036 | 1036 | ) |
1037 | | - return await self._handle_process_function(self.process, **kwargs) |
| 1037 | + return self.process(**kwargs) |
1038 | 1038 |
|
1039 | | - async def process_input( |
| 1039 | + def process_input( |
1040 | 1040 | self, |
1041 | 1041 | prompt: PROMPT, |
1042 | 1042 | metadata: Metadata, |
1043 | 1043 | parameters: PARAMS, |
1044 | 1044 | request: Request, |
1045 | | - ) -> Result | Reject: |
| 1045 | + ) -> Result | Reject | Awaitable[Result | Reject]: |
1046 | 1046 | """ |
1047 | 1047 | This abstract method is for implementors of the processor to define |
1048 | 1048 | with their own custom logic. Errors should be raised as a subclass |
@@ -1070,22 +1070,22 @@ def process_input(self, prompt, response, metadata, parameters, request): |
1070 | 1070 | f"{type(self).__name__} must implement 'process_input' or the " |
1071 | 1071 | "deprecated 'process' method to handle input." |
1072 | 1072 | ) |
1073 | | - return await self._process_fallback( |
| 1073 | + return self._process_fallback( |
1074 | 1074 | prompt=prompt, |
1075 | 1075 | response=None, |
1076 | 1076 | metadata=metadata, |
1077 | 1077 | parameters=parameters, |
1078 | 1078 | request=request, |
1079 | 1079 | ) |
1080 | 1080 |
|
1081 | | - async def process_response( |
| 1081 | + def process_response( |
1082 | 1082 | self, |
1083 | 1083 | prompt: PROMPT | None, |
1084 | 1084 | response: RESPONSE, |
1085 | 1085 | metadata: Metadata, |
1086 | 1086 | parameters: PARAMS, |
1087 | 1087 | request: Request, |
1088 | | - ) -> Result | Reject: |
| 1088 | + ) -> Result | Reject | Awaitable[Result | Reject]: |
1089 | 1089 | """ |
1090 | 1090 | This abstract method is for implementors of the processor to define |
1091 | 1091 | with their own custom logic. Errors should be raised as a subclass |
@@ -1117,7 +1117,7 @@ def process_response(self, prompt, response, metadata, parameters, request): |
1117 | 1117 | f"{type(self).__name__} must implement 'process_response' or the " |
1118 | 1118 | "deprecated 'process' method to handle input." |
1119 | 1119 | ) |
1120 | | - return await self._process_fallback( |
| 1120 | + return self._process_fallback( |
1121 | 1121 | prompt=prompt, |
1122 | 1122 | response=response, |
1123 | 1123 | metadata=metadata, |
|
0 commit comments