File tree Expand file tree Collapse file tree 2 files changed +29
-13
lines changed Expand file tree Collapse file tree 2 files changed +29
-13
lines changed Original file line number Diff line number Diff line change @@ -488,6 +488,16 @@ async def message(self, content):
488
488
},
489
489
)
490
490
491
+ async def citation (self , document , metadata , source ):
492
+ await self ._emit (
493
+ "citation" ,
494
+ {
495
+ "document" : document ,
496
+ "metadata" : metadata ,
497
+ "source" : source ,
498
+ },
499
+ )
500
+
491
501
async def code_execution_result (self , output ):
492
502
await self ._emit (
493
503
"code_execution_result" ,
@@ -3280,7 +3290,8 @@ def _print_output(obj):
3280
3290
success = False
3281
3291
_print_output (e )
3282
3292
print (
3283
- f"\u274c Self-test { name } failed: process failed: { e } " , file = sys .stderr
3293
+ f"\u274c Self-test { name } failed: process failed: { e } " ,
3294
+ file = sys .stderr ,
3284
3295
)
3285
3296
except Exception as e :
3286
3297
success = False
Original file line number Diff line number Diff line change @@ -220,6 +220,16 @@ async def message(self, content):
220
220
},
221
221
)
222
222
223
+ async def citation (self , document , metadata , source ):
224
+ await self ._emit (
225
+ "citation" ,
226
+ {
227
+ "document" : document ,
228
+ "metadata" : metadata ,
229
+ "source" : source ,
230
+ },
231
+ )
232
+
223
233
async def code_execution_result (self , output ):
224
234
await self ._emit (
225
235
"code_execution_result" ,
@@ -321,16 +331,8 @@ async def _fail(error_message, status="SANDBOX_ERROR"):
321
331
f"Running { language_title } code in gVisor sandbox..."
322
332
)
323
333
324
- # TODO: Wrap this in an emitter helper function.
325
- await event_emitter (
326
- {
327
- "type" : "citation" ,
328
- "data" : {
329
- "document" : [code ],
330
- "metadata" : [code ],
331
- "source" : {"name" : "run_code" },
332
- },
333
- }
334
+ await emitter .citation (
335
+ document = [code ], metadata = [code ], source = {"name" : "run_code" }
334
336
)
335
337
336
338
try :
@@ -2516,12 +2518,15 @@ def _print_output(obj):
2516
2518
except subprocess .CalledProcessError as e :
2517
2519
success = False
2518
2520
_print_output (e )
2519
- print (f"\u274c Self-test { name } failed: process failed: { e } " , file = sys .stderr )
2521
+ print (
2522
+ f"\u274c Self-test { name } failed: process failed: { e } " , file = sys .stderr
2523
+ )
2520
2524
except Exception as e :
2521
2525
success = False
2522
2526
exception_class = e .__class__
2523
2527
print (
2524
- f"\u274c Self-test { name } failed: { exception_class } : { e } " , file = sys .stderr
2528
+ f"\u274c Self-test { name } failed: { exception_class } : { e } " ,
2529
+ file = sys .stderr ,
2525
2530
)
2526
2531
else :
2527
2532
try :
You can’t perform that action at this time.
0 commit comments