File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -311,5 +311,39 @@ def test_receive_and_reply_with_filters(self):
311
311
)
312
312
313
313
314
+ def test_chat_citations (self ):
315
+ self .mock_response = mock_response = glm .GenerateMessageResponse (
316
+ candidates = [{'content' :"Hello google!" , 'author' :"1" , "citation_metadata" : {
317
+ "citation_sources" : [
318
+ {
319
+ "start_index" : 6 ,
320
+ "end_index" : 12 ,
321
+ "uri" : "https://google.com" ,
322
+ }
323
+ ]
324
+ },
325
+ }],
326
+ )
327
+
328
+ response = discuss .chat (messages = "Do citations work?" )
329
+
330
+ self .assertEqual (
331
+ response .candidates [0 ]["citation_metadata" ]["citation_sources" ][0 ][
332
+ "start_index"
333
+ ],
334
+ 6 ,
335
+ )
336
+
337
+ response = response .reply ("What about a second time?" )
338
+
339
+ self .assertEqual (
340
+ response .candidates [0 ]["citation_metadata" ]["citation_sources" ][0 ][
341
+ "start_index"
342
+ ],
343
+ 6 ,
344
+ )
345
+ self .assertLen (response .messages , 4 )
346
+
347
+
314
348
if __name__ == "__main__" :
315
349
absltest .main ()
You can’t perform that action at this time.
0 commit comments