PyCharacterAI icon indicating copy to clipboard operation
PyCharacterAI copied to clipboard

Character limit

Open avrcal opened this issue 11 months ago • 13 comments

Hi i dont know if the repository dead or no but i have problem with it

It only puts the 50% of the repsond instead of the repsond of the c.ai message

And if you wonder why i care about this because im working on discord bot about c.ai bot and people who uses it wants the bot to put the full repsond

Thanks

avrcal avatar Feb 06 '25 19:02 avrcal

Hi, the repository is alive.

Could you please provide me with your code that you think is causing this problem?

Xtr4F avatar Feb 06 '25 20:02 Xtr4F

async def send_ai_message(channel_id, message_content, user_name):
    chat_data = active_chats.get(channel_id)
    if not chat_data or not chat_data["is_active"]:
        return None

    client = chat_data["client"]
    character_id = chat_data["character_id"]
    chat_id = chat_data["chat_id"]

    formatted_message = f"[{user_name}]: {message_content}"
    
    answer = await client.chat.send_message(
        character_id, chat_id, formatted_message,
        streaming=True 
    )
    
    printed_length = 0
    full_response = ""
    
    async for message in answer:
        if printed_length == 0:
            full_response += f"[{message.author_name}]: "
        text = message.get_primary_candidate().text
        full_response += text[printed_length:]
        printed_length = len(text)
    
    return full_response.strip()

avrcal avatar Feb 06 '25 20:02 avrcal

Try to use it without streaming

async def send_ai_message(channel_id, message_content, user_name):
    chat_data = active_chats.get(channel_id)
    if not chat_data or not chat_data["is_active"]:
        return None

    client = chat_data["client"]
    character_id = chat_data["character_id"]
    chat_id = chat_data["chat_id"]

    formatted_message = f"[{user_name}]: {message_content}"
    
    answer = await client.chat.send_message(
        character_id, chat_id, formatted_message
    )
    
    text = answer.get_primary_candidate().text
    return text.strip()

Xtr4F avatar Feb 06 '25 20:02 Xtr4F

I tried it It says there is no full_response After i added full response it doesnt send anything in the c.ai chat

Image

avrcal avatar Feb 06 '25 21:02 avrcal

Nvm i fixed it

But still it has character limit

Can you fix it by changing library files?

avrcal avatar Feb 06 '25 21:02 avrcal

Oh, sorry, my bad. It should return text.strip() instead of full_response.strip()

I'm not quite sure what character limit you've encountered, the Library is definitely working as it should.

Xtr4F avatar Feb 06 '25 22:02 Xtr4F

Image here is explain

avrcal avatar Feb 06 '25 22:02 avrcal

Uh did you forgot about the issue or you dont know the solution?

avrcal avatar Feb 07 '25 10:02 avrcal

Could you please, for example, print the text that you are getting in response from the character using my library before sending this message to discord (i.e. in the send_ai_message function before return do print(text) ) and compare it with the actual character response message on the website?

If they are different then that's really weird and I'll try to figure out what's wrong, if they are the same then the problem is somewhere in your code.

Xtr4F avatar Feb 07 '25 13:02 Xtr4F

on discord

Image

on console

Image

on c.ai

Image

avrcal avatar Feb 07 '25 14:02 avrcal

So there is no solution? Im still waitting idc if this takes months

avrcal avatar Feb 09 '25 11:02 avrcal

I've been really busy lately, sorry for the long response time.

It looks more like a problem on the c.ai side. I tried asking the same bot to write me some code and it generates something like

Image

and then stops.

In other scenarios everything is fine and responses are complete. Maybe c.ai is just incapable of generating code?

Xtr4F avatar Feb 10 '25 10:02 Xtr4F

hello..having the same issue here i think it's like a limit from c.ai i use the token normally for 1 month..sometimes a week..then it switches to an older model with dumb responses and message limit the only solution i use is just switching to another account it's not really a solution tho but it works.. not sure if it's a limit for the api or just a limit from c.ai so we pay for plus?

Alichan83737 avatar Feb 24 '25 14:02 Alichan83737