Parse Chat
Showing the entire chat
from characterai import PyCAI
client = PyCAI('TOKEN')
history = client.chat.get_history('HISTORY_ID')
for h in history['messages']:
name = h['src_char']['participant']['name']
text = h['text']
print(f'{name}: {text}')
import asyncio
from characterai import PyAsyncCAI
async def main():
client = PyAsyncCAI('TOKEN')
history = await client.chat.get_history('HISTORY_ID')
for h in history['messages']:
name = h['src_char']['participant']['name']
text = h['text']
print(f'{name}: {text}')
asyncio.run(main())
Last updated