Skip to content

Commit 3c51065

Browse files
committed
Documented everything leftover
1 parent a45f0d7 commit 3c51065

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

ai-assistant/src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
// Rocket Chat's Marketplace App ID
12
export const APP_ID = "ai-assistant";

ai-assistant/src/core/prompt.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ export class Prompt {
1111
this._messages = messages;
1212
}
1313

14+
/**
15+
* Parses the content of a prompt by removing leading and trailing whitespace from each line.
16+
*
17+
* @param content - The content of the prompt to be parsed.
18+
* @returns The parsed content with leading and trailing whitespace removed from each line.
19+
*/
1420
private parsePromptContent(content: string): string {
1521
return content
1622
.split("\n")
@@ -19,20 +25,38 @@ export class Prompt {
1925
.trim();
2026
}
2127

28+
/**
29+
* Pushes a system message to the message list.
30+
*
31+
* @param {string} content - The content of the system message.
32+
* @returns {void}
33+
*/
2234
pushSystem(content: string) {
2335
this._messages.push({
2436
role: "system",
2537
content: this.parsePromptContent(content),
2638
});
2739
}
2840

41+
/**
42+
* Adds a message from the assistant to the message list.
43+
*
44+
* @param {string} content - The content of the message.
45+
* @returns {void}
46+
*/
2947
pushAssistant(content: string) {
3048
this._messages.push({
3149
role: "assistant",
3250
content: this.parsePromptContent(content),
3351
});
3452
}
3553

54+
/**
55+
* Adds a user message to the message list.
56+
*
57+
* @param {string} content - The content of the user message.
58+
* @returns {void}
59+
*/
3660
pushUser(content: string) {
3761
this._messages.push({
3862
role: "user",

ai-assistant/src/core/query.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ import { IDB } from "./services/db/db.types";
44
import { IEmbeddingModel } from "./services/embeddings/embeddings.types";
55
import { ILLMModel } from "./services/llm/llm.types";
66

7+
/**
8+
* The Query namespace provides functions for querying a database and retrieving nodes based on various criteria.
9+
*/
710
export namespace Query {
11+
/**
12+
* Retrieves database nodes based on a vector query.
13+
*
14+
* @param {IDB} db - The database instance.
15+
* @param {string} indexName - The name of the index to query.
16+
* @param {number[]} vector - The vector to query with.
17+
* @param {number} threshold - The minimum score threshold for the query results.
18+
* @returns {Promise<DBNode[]>} - A promise that resolves to an array of DBNode objects.
19+
*/
820
export async function getDBNodesFromVectorQuery(
921
db: IDB,
1022
indexName: string,
@@ -40,6 +52,14 @@ export namespace Query {
4052
return nodes;
4153
}
4254

55+
/**
56+
* Retrieves code nodes from the database based on a list of keywords.
57+
*
58+
* @param {IDB} db - The database object.
59+
* @param {IEmbeddingModel} embeddingModel - The embedding model used for generating query vectors.
60+
* @param {string[]} keywords - The list of keywords to search for.
61+
* @returns {Promise<DBNode[]>} - A promise that resolves to an array of DBNode objects matching the keywords.
62+
*/
4363
export async function getCodeNodesFromKeywords(
4464
db: IDB,
4565
embeddingModel: IEmbeddingModel,
@@ -62,6 +82,13 @@ export namespace Query {
6282
return results;
6383
}
6484

85+
/**
86+
* Retrieves database keywords from a given query using a language model.
87+
*
88+
* @param llm - The language model used to generate the keywords.
89+
* @param query - The query string to extract keywords from.
90+
* @returns A promise that resolves to an array of database keywords extracted from the query.
91+
*/
6592
export async function getDBKeywordsFromQuery(
6693
llm: ILLMModel,
6794
query: string

0 commit comments

Comments
 (0)