CharacterAI
  • 👋Welcome
  • 🧑‍💻Quick Start
  • 🛠️API
    • 🔑 Values
    • ⚠️ Errors
    • connect
    • ping
    • user
      • info
      • get_profile
      • followers
      • following
      • recent
      • update
    • post
      • get_post
      • my_posts
      • get_posts
      • upvote
      • undo_upvote
      • send_comment
      • delete_comment
      • create
      • delete
      • get_topics
      • feed
    • character
      • create
      • update
      • trending
      • recommended
      • categories
      • info
      • search
      • voices
    • chat
      • create_room
      • rate
      • next_message
      • get_histories
      • get_history
      • get_chat
      • send_message
      • delete_message
      • new_chat
    • chat2
      • next_message
      • send_message
      • get_histories
      • new_chat
      • get_chat
      • get_history
      • rate
      • delete_message
  • 📚Examples
    • Chatting
    • Parse Chat
  • ⚠️Issues
Powered by GitBook
On this page
  • history_id [str]
  • uuids_to_delete [list]
  • token [str] (optional)
  1. API
  2. chat

delete_message

Delete a message

client.chat.new_chat('HISTORY_ID', 'UUIDS_TO_DELETE')
from characterai import PyCAI

client = PyCAI('TOKEN')
    
uuids_to_delete = []

history = client.chat.get_history('HISTORY_ID')

uuids_to_delete.append(history['messages'][-1]['uuid'])
uuids_to_delete.append(history['messages'][-2]['uuid'])

client.chat.delete_message('HISTORY_ID', uuids_to_delete)
import asyncio
from characterai import PyAsyncCAI

async def main():
    client = PyAsyncCAI('TOKEN')
    
    uuids_to_delete = []

    history = await client.chat.get_history('HISTORY_ID')

    uuids_to_delete.append(history['messages'][-1]['uuid'])
    uuids_to_delete.append(history['messages'][-2]['uuid'])

    await client.chat.delete_message('HISTORY_ID', uuids_to_delete)
    
asyncio.run(main())

history_id [str]

Unique ID for character history

uuids_to_delete [list]

List of message IDs that you want to delete, you can delete 1 message, but the line must be in the list

token [str] (optional)

You can set a specific token for the function, it will be executed from the specified token

Previoussend_messageNextnew_chat

Last updated 1 year ago

🛠️