Closed aiprojectchiwa closed 3 weeks ago
Hello! You are not using node_characterai correctly.
The way node_characterai works is meant to simulate the way you would use the website. As such, you should treat the code like the way you would interact with the website as a regular user.
Chat instances are NOT supposed to be created. The client is in charge of fetching and loading a conversation correctly.
_Source: client.js
_
Instead, use await characterAI.createOrContinueChat(characterId);
. You can also specify a specific external conversation id to continue a conversation.
The client will return a new Chat object that contains the conversation and what you need to chat with your character.
chat. ...
-> interact with the conversation that you fetched.
You can use createOrContinueChat
as long as you need to store conversations. Remember: you are storing a CHAT object, so you will have to manage these objects yourself.
Using changeToConversationId
will reset the chat
object to an externalId (conversation identifier) whilst saveAndStartNewChat
will reset and directly switch the externalId.
When mentioning to continue a conversation, I recommend you use the chat that you need to continue with. Eg, if you've used createOrContinueChat
and you have a conversation where you're talking about fruits, and one other about vegetables, you need to keep both chat objects in order to get both conversations running. Eg:
// you wish to talk about fruits, use this one.
let fruitsConversation = await characterAI.createOrContinueChat(characterId, fruitConversationExternalId);
// you wish to talk about vegetables, use this one.
let vegetablesConversation = await characterAI.createOrContinueChat(characterId, vegetablesConversationExternalId);
If you're still confused about how the package works, it should be fairly straightforward, but I recommend you review the client.js
and chat.js
file for more information.
Since this is not a problem related to the actual package itself, I will close the issue. Feel free to re-open however if you need to or open a new issue if you need.
Issue Description
I am encountering an issue in my project where attempting to change the chat ID results in starting a new session, even though a valid session ID is provided. Below is the relevant code:
Expected Behavior
When I provide a valid session ID, I expect the chat to continue within the same session rather than starting a new session.
Actual Behavior
Despite providing a valid session ID, a new session is initiated instead of continuing the existing one.
Steps to Reproduce
sessionId
query parameter.Environment
node_characterai@1.2.7
Additional Context
Create a Session
Response
Attempt to Continue the Session
Despite using the same session ID, the response indicates a new session is being created:
Request for Assistance
I am not entirely sure if the logic in the code is correct according to how the
node_characterai
module is supposed to work. Could someone please review the logic and confirm whether it is accurate? Any guidance or suggestions for improvement would be greatly appreciated.