Skip to content

Commit cc7fe29

Browse files
committed
Test chat citations.
1 parent e81bfc1 commit cc7fe29

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/test_discuss.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,5 +311,39 @@ def test_receive_and_reply_with_filters(self):
311311
)
312312

313313

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+
314348
if __name__ == "__main__":
315349
absltest.main()

0 commit comments

Comments
 (0)