Commit 9686dee 1 parent 9bf0e27 commit 9686dee Copy full SHA for 9686dee
File tree 4 files changed +10
-30
lines changed
4 files changed +10
-30
lines changed Original file line number Diff line number Diff line change @@ -1741,7 +1741,7 @@ async def converse_alpha1(
1741
1741
ConversationResponse containing the conversation results
1742
1742
1743
1743
Raises:
1744
- DaprInternalError : If the Dapr runtime returns an error
1744
+ DaprGrpcError : If the Dapr runtime returns an error
1745
1745
"""
1746
1746
inputs_pb = [
1747
1747
api_v1 .ConversationInput (content = inp .content , role = inp .role , scrubPII = inp .scrub_pii )
@@ -1768,8 +1768,8 @@ async def converse_alpha1(
1768
1768
1769
1769
return ConversationResponse (context_id = response .contextID , outputs = outputs )
1770
1770
1771
- except Exception as e :
1772
- raise DaprInternalError ( f'Error invoking conversation API: { e } ' )
1771
+ except grpc . aio . AioRpcError as err :
1772
+ raise DaprGrpcError ( err ) from err
1773
1773
1774
1774
async def wait (self , timeout_s : float ):
1775
1775
"""Waits for sidecar to be available within the timeout.
Original file line number Diff line number Diff line change @@ -1743,7 +1743,7 @@ def converse_alpha1(
1743
1743
ConversationResponse containing the conversation results
1744
1744
1745
1745
Raises:
1746
- DaprInternalError : If the Dapr runtime returns an error
1746
+ DaprGrpcError : If the Dapr runtime returns an error
1747
1747
"""
1748
1748
1749
1749
inputs_pb = [
@@ -1770,9 +1770,8 @@ def converse_alpha1(
1770
1770
]
1771
1771
1772
1772
return ConversationResponse (context_id = response .contextID , outputs = outputs )
1773
-
1774
- except Exception as e :
1775
- raise DaprInternalError (f'Error invoking conversation API: { e } ' )
1773
+ except RpcError as err :
1774
+ raise DaprGrpcError (err ) from err
1776
1775
1777
1776
def wait (self , timeout_s : float ):
1778
1777
"""Waits for sidecar to be available within the timeout.
Original file line number Diff line number Diff line change 25
25
26
26
from google .rpc import status_pb2 , code_pb2
27
27
28
- from dapr .clients .exceptions import DaprGrpcError , DaprInternalError
28
+ from dapr .clients .exceptions import DaprGrpcError
29
29
from dapr .clients .grpc .client import DaprGrpcClient
30
30
from dapr .clients import DaprClient
31
31
from dapr .clients .grpc .subscription import StreamInactiveError
@@ -1229,19 +1229,10 @@ def test_converse_alpha1_error_handling(self):
1229
1229
1230
1230
inputs = [ConversationInput (content = 'Hello' , role = 'user' )]
1231
1231
1232
- with self .assertRaises (DaprInternalError ) as context :
1232
+ with self .assertRaises (DaprGrpcError ) as context :
1233
1233
dapr .converse_alpha1 (name = 'test-llm' , inputs = inputs )
1234
1234
self .assertTrue ('Invalid argument' in str (context .exception ))
1235
1235
1236
- def test_converse_alpha1_empty_inputs (self ):
1237
- dapr = DaprGrpcClient (f'{ self .scheme } localhost:{ self .grpc_port } ' )
1238
-
1239
- # Test with empty inputs list
1240
- response = dapr .converse_alpha1 (name = 'test-llm' , inputs = [])
1241
-
1242
- self .assertIsNotNone (response )
1243
- self .assertEqual (len (response .outputs ), 0 )
1244
-
1245
1236
1246
1237
if __name__ == '__main__' :
1247
1238
unittest .main ()
Original file line number Diff line number Diff line change 23
23
24
24
from dapr .aio .clients .grpc .client import DaprGrpcClientAsync
25
25
from dapr .aio .clients import DaprClient
26
- from dapr .clients .exceptions import DaprGrpcError , DaprInternalError
26
+ from dapr .clients .exceptions import DaprGrpcError
27
27
from dapr .common .pubsub .subscription import StreamInactiveError
28
28
from dapr .proto import common_v1
29
29
from .fake_dapr_server import FakeDaprSidecar
@@ -1159,21 +1159,11 @@ async def test_converse_alpha1_error_handling(self):
1159
1159
1160
1160
inputs = [ConversationInput (content = 'Hello' , role = 'user' )]
1161
1161
1162
- with self .assertRaises (DaprInternalError ) as context :
1162
+ with self .assertRaises (DaprGrpcError ) as context :
1163
1163
await dapr .converse_alpha1 (name = 'test-llm' , inputs = inputs )
1164
1164
self .assertTrue ('Invalid argument' in str (context .exception ))
1165
1165
await dapr .close ()
1166
1166
1167
- async def test_converse_alpha1_empty_inputs (self ):
1168
- dapr = DaprGrpcClientAsync (f'{ self .scheme } localhost:{ self .grpc_port } ' )
1169
-
1170
- # Test with empty inputs list
1171
- response = await dapr .converse_alpha1 (name = 'test-llm' , inputs = [])
1172
-
1173
- self .assertIsNotNone (response )
1174
- self .assertEqual (len (response .outputs ), 0 )
1175
- await dapr .close ()
1176
-
1177
1167
1178
1168
if __name__ == '__main__' :
1179
1169
unittest .main ()
You can’t perform that action at this time.
0 commit comments