Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client.character.create_new_conversation stopped returning the promise #10

Open
wang-yuwen opened this issue Dec 1, 2024 · 17 comments
Open

Comments

@wang-yuwen
Copy link
Contributor

For some reason it just stopped returning its promise. The function does work, but I'm using it with an await and it fails to return the promise. It all started just yesterday. Any ideas why?
I used to get unresolved promises before, with other requests but not every time, more like 1 in 100 requests, randomly.
I think it's something to do with c.ai itself but can't seem to find what causes it. Can you look into it?

@KevinAdhaikal
Copy link
Owner

KevinAdhaikal commented Dec 2, 2024

can you give me a result of the log, please? and your code

@wang-yuwen
Copy link
Contributor Author

I'm using it with a telegram bot that has an in-built timeout module (p-timeout), so it waits for the promise to resolve and throws an error if it is still pending after a set amound of time. So the error i'm getting is
TimeoutError: Promise timed out after 20000 milliseconds

The function i'm using first awaits for await client.character.create_new_conversation() and then should do some other stuff but it doesn't get past the first line, so the promise i'm awaiting for is stuck pending, and that causes the other stuff to timeout as well.

As i've mentioned, this used to happen randomly with other c.ai requests as well, but now it happens every time with this particular function.

Also it should be noted that the function does work, I just can't await for it.

@KevinAdhaikal
Copy link
Owner

KevinAdhaikal commented Dec 3, 2024

hmmmm... maybe it's my send_ws function fault?
i will try to investigate later.

@KevinAdhaikal
Copy link
Owner

btw, are you set with_greeting parameter to true? i mean, you called create_new_conversation function like this
client.character.create_new_conversation(true) or client.character.create_new_conversation()

@matsukky
Copy link

matsukky commented Dec 9, 2024

i don't know for the op, but for myself, create_new_conversation(true), create_new_conversation() and create_new_conversation(false) result to the same things... Block in an infinite wait.

@KevinAdhaikal
Copy link
Owner

i don't know for the op, but for myself, create_new_conversation(true), create_new_conversation() and create_new_conversation(false) result to the same things... Block in an infinite wait.

ohhhh...

@KevinAdhaikal
Copy link
Owner

I just found out that it's my send_ws issue, not the server's. I will fix it ASAP.

@KevinAdhaikal
Copy link
Owner

KevinAdhaikal commented Dec 12, 2024

i am an idiot 😂
the problem is that is: because the parameter should be int and i make it boolean. and that's why it not returning promise.
i just fix the send_ws by adding Number(). so it will converts boolean to integer.
will update to the NPM later.

thanks for reporting this issue and sorry if my grammar is bad. 🙏

@KevinAdhaikal
Copy link
Owner

okay done. i've just update to the NPM as well.
now you can try it now. @wang-yuwen @matsukky

@wang-yuwen
Copy link
Contributor Author

Okay, I'm a little bit late but as for your question, yes, It was set to true. Not that it matters now that you've fixed it.
Thank you, I'll try it out now. Strange, though, that it used to work just fine until one day.

@wang-yuwen
Copy link
Contributor Author

Hmm...

TypeError: Cannot read properties of undefined (reading 'chat_id')
at Character_Class.create_new_conversation (.../index.js:1383:81)

@KevinAdhaikal
Copy link
Owner

Hmm...

TypeError: Cannot read properties of undefined (reading 'chat_id')
at Character_Class.create_new_conversation (.../index.js:1383:81)

If you set greeting to true, then it has 2 array
[0] is contains chat id
[1] is for greeting

If you set greeting to false, it not returns array.

Maybe you can try console.log()

@matsukky
Copy link

create_new_conversation(false) seems to work as it should.... But as has say wang-yuwen, create_new_conversation(true ) or create_new_conversation() return :

TypeError: Cannot read properties of undefined (reading 'chat_id')
at Character_Class.create_new_conversation (.../index.js:1383:81)

console.log() change nothing.

@KevinAdhaikal
Copy link
Owner

Hmmmmmm... Did you connect to character? @matsukky and @wang-yuwen

@KevinAdhaikal
Copy link
Owner

oh, I'm such an idiot 😂
i forgot to put result variable with array zero. i mean, like this: if (this.#prop.join_type == 1) this.#prop.current_chat_id = result[0].chat.chat_id at index.js line 1383

thanks for letting me out.

@KevinAdhaikal
Copy link
Owner

I will update the NPM Package later because I'm adding some character.ai API now.

@KevinAdhaikal
Copy link
Owner

For now, you can clone, get the index.js file, and put it into your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants