File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 1111from dotenv import load_dotenv
1212from loguru import logger
1313from republic import AsyncTapeStore , RepublicError , TapeContext
14+ from republic .core .errors import ErrorKind
1415from republic .tape import TapeStore
1516
1617from bub .envelope import content_of , field_of , unpack_batch
@@ -146,8 +147,13 @@ async def _run_model(
146147 if event .kind == "text" :
147148 parts .append (str (event .data .get ("delta" , "" )))
148149 elif event .kind == "error" :
150+ # Turn "kind" to enum type otherwise the RepublicError's __str__ won't work well
151+ data = {
152+ ** event .data ,
153+ "kind" : ErrorKind (event .data .get ("kind" , "unknown" )),
154+ }
149155 await self ._hook_runtime .notify_error (
150- stage = "run_model" , error = RepublicError (** event . data ), message = inbound
156+ stage = "run_model" , error = RepublicError (** data ), message = inbound
151157 )
152158 return "" .join (parts )
153159
You can’t perform that action at this time.
0 commit comments