- Source:
Members
(inner, constant) systemInstruction
Some prompt instructions for the AI to generate completions.
Some prompt instructions for the AI to generate completions.
- Source:
Methods
(static) createAIComment(comment, dreamId)
Generates a comment from a completion, created by an AI.
Generates a comment from a completion, created by an AI. It uses the createComment method to create the comment.
Parameters:
Name | Type | Description |
---|---|---|
comment |
string | |
dreamId |
string |
- Source:
- To Do:
-
- move AI logic from createComment to this method
(static) createComment(data) → {Promise.<{insertedId: string}>}
This method is responsible for creating a comment.
This method is responsible for creating a comment. It also creates an inbox message for the dream owner. If the dream owner is the same as the user, no inbox message is created. It has a special case for the AI user, which is a bot that creates comments. The AI user doesn't have a database object, so it skips getting the user's database object.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | The data object Properties
|
- Source:
Returns:
- Type
- Promise.<{insertedId: string}>
(static) createDream()
Method responsible for creating a post.
Method responsible for creating a post. It encrypts the post if it's private. It generates insights from the post text (word frequency and character count).
This method is only called from the frontend the first time a post is synced. The subsequent times, the post is updated.
- Source:
(static) deleteAccount(userEmail) → {Promise.<{success: boolean}>}
Method responsible for deleting a user's account.
Method responsible for deleting a user's account. This method is called when a user deletes their account. It deletes all dreams, comments and stars related to the user, and the user's account.
Parameters:
Name | Type | Description |
---|---|---|
userEmail |
string | The user's email |
- Source:
Returns:
- Type
- Promise.<{success: boolean}>
(static) deleteAllInboxMessages()
- Source:
- To Do:
-
- document this
(static) deleteComment(commentId, dreamId) → {Promise.<any>}
This method is responsible for deleting a comment from a dream.
This method is responsible for deleting a comment from a dream. It also deletes the inbox message for the dream owner.
Parameters:
Name | Type | Description |
---|---|---|
commentId |
string | The comment ID |
dreamId |
string | The dream ID |
- Source:
Returns:
- Type
- Promise.<any>
(static) deleteDream(dreamId) → {Promise.<{success: boolean}>}
Method responsible for deleting a dream.
Method responsible for deleting a dream.
Parameters:
Name | Type | Description |
---|---|---|
dreamId |
string | The dream's ID |
- Source:
Returns:
- Type
- Promise.<{success: boolean}>
(static) deleteSomeInboxMessages()
- Source:
- To Do:
-
- document this
(static) generateCompletion(dreamId, text, session, userId)
Starts the completion generation process, which is followed by a human-in-the-loop review process until it gets back to this service
session and userId params are optional because this method has two possible workflows, one using the session and the other using the userIds.
Starts the completion generation process, which is followed by a human-in-the-loop review process until it gets back to this service
session and userId params are optional because this method has two possible workflows, one using the session and the other using the userIds. The session workflow starts on the frontend, while the userId workflow starts on the backend.
This is this way because saveCompletions method is, and this method calls it.
Parameters:
Name | Type | Description |
---|---|---|
dreamId |
string | The dream id |
text |
string | The dream data text |
session |
object | (Optional) The session object. If not provided, the |
userId |
string | (Optional) The user id. If not provided, the |
- Source:
(static) markAllInboxMessagesAsRead()
- Source:
- To Do:
-
- document this
(static) markSomeInboxMessagesAsRead()
- Source:
- To Do:
-
- document this
(static) saveCompletion(completion, dreamId, userEmail, userId)
Saves a completion to the database
.Saves a completion to the database
Parameters:
Name | Type | Description |
---|---|---|
completion |
* | |
dreamId |
* | |
userEmail |
* | |
userId |
* |
- Source:
(static) saveCosineSimilarityScore()
Saves the cosine similarity score between two texts.
Saves the cosine similarity score between two texts.
- Source:
(static) starDream(data) → {Promise.<{insertedId: string}>}
This method is responsible for starring a dream.
This method is responsible for starring a dream. It also creates an inbox message for the dream owner. If the dream owner is the same as the user, no inbox message is created.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | The data object Properties
|
- Source:
Returns:
- Type
- Promise.<{insertedId: string}>
(static) unstarDream()
- Source:
- To Do:
-
- document this
(static) updateDream()
Updates a post, auto-saving it.
Updates a post, auto-saving it. It encrypts the post if it's private before updating it. It also updates insights from the post text (word frequency and character count).
- Source:
(static) updateDreamVisibility(dreamId, visibility, userEmail) → {Promise.<{success: boolean}>}
Method responsible for updating a dream's visibility.
Method responsible for updating a dream's visibility. In case a dream is going from public to private and doesn't have an AI input, it also generates one.
Parameters:
Name | Type | Description |
---|---|---|
dreamId |
string | The dream's ID |
visibility |
string | "public" or "private" |
userEmail |
string | The dream owner user's email |
- Source:
Returns:
- Type
- Promise.<{success: boolean}>
(static) updateUser(userId, data)
Updates a user's account with the provided data.
Updates a user's account with the provided data.
Parameters:
Name | Type | Description |
---|---|---|
userId |
string | |
data |
object |
- Source: