-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: model plugin to follow new specs (janhq#682)
* refactor: model plugin to follow new specs Signed-off-by: James <[email protected]> * chore: rebase main chore: rebase main --------- Signed-off-by: James <[email protected]> Co-authored-by: James <[email protected]> Co-authored-by: Louis <[email protected]>
- Loading branch information
1 parent
a990fa6
commit 86e693b
Showing
68 changed files
with
2,087 additions
and
1,182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Assistant } from "../index"; | ||
import { JanPlugin } from "../plugin"; | ||
|
||
/** | ||
* Abstract class for assistant plugins. | ||
* @extends JanPlugin | ||
*/ | ||
export abstract class AssistantPlugin extends JanPlugin { | ||
/** | ||
* Creates a new assistant. | ||
* @param {Assistant} assistant - The assistant object to be created. | ||
* @returns {Promise<void>} A promise that resolves when the assistant has been created. | ||
*/ | ||
abstract createAssistant(assistant: Assistant): Promise<void>; | ||
|
||
/** | ||
* Deletes an existing assistant. | ||
* @param {Assistant} assistant - The assistant object to be deleted. | ||
* @returns {Promise<void>} A promise that resolves when the assistant has been deleted. | ||
*/ | ||
abstract deleteAssistant(assistant: Assistant): Promise<void>; | ||
|
||
/** | ||
* Retrieves all existing assistants. | ||
* @returns {Promise<Assistant[]>} A promise that resolves to an array of all assistants. | ||
*/ | ||
abstract getAssistants(): Promise<Assistant[]>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,57 @@ | ||
import { Thread } from "../index"; | ||
import { Thread, ThreadMessage } from "../index"; | ||
import { JanPlugin } from "../plugin"; | ||
|
||
/** | ||
* Abstract class for conversational plugins. | ||
* Abstract class for Thread plugins. | ||
* @abstract | ||
* @extends JanPlugin | ||
*/ | ||
export abstract class ConversationalPlugin extends JanPlugin { | ||
/** | ||
* Returns a list of conversations. | ||
* Returns a list of thread. | ||
* @abstract | ||
* @returns {Promise<any[]>} A promise that resolves to an array of conversations. | ||
* @returns {Promise<Thread[]>} A promise that resolves to an array of threads. | ||
*/ | ||
abstract getConversations(): Promise<any[]>; | ||
abstract getThreads(): Promise<Thread[]>; | ||
|
||
/** | ||
* Saves a conversation. | ||
* Saves a thread. | ||
* @abstract | ||
* @param {Thread} conversation - The conversation to save. | ||
* @returns {Promise<void>} A promise that resolves when the conversation is saved. | ||
* @param {Thread} thread - The thread to save. | ||
* @returns {Promise<void>} A promise that resolves when the thread is saved. | ||
*/ | ||
abstract saveConversation(conversation: Thread): Promise<void>; | ||
abstract saveThread(thread: Thread): Promise<void>; | ||
|
||
/** | ||
* Deletes a conversation. | ||
* Deletes a thread. | ||
* @abstract | ||
* @param {string} conversationId - The ID of the conversation to delete. | ||
* @returns {Promise<void>} A promise that resolves when the conversation is deleted. | ||
* @param {string} threadId - The ID of the thread to delete. | ||
* @returns {Promise<void>} A promise that resolves when the thread is deleted. | ||
*/ | ||
abstract deleteConversation(conversationId: string): Promise<void>; | ||
abstract deleteThread(threadId: string): Promise<void>; | ||
|
||
/** | ||
* Adds a new message to the thread. | ||
* @param {ThreadMessage} message - The message to be added. | ||
* @returns {Promise<void>} A promise that resolves when the message has been added. | ||
*/ | ||
abstract addNewMessage(message: ThreadMessage): Promise<void>; | ||
|
||
/** | ||
* Writes an array of messages to a specific thread. | ||
* @param {string} threadId - The ID of the thread to write the messages to. | ||
* @param {ThreadMessage[]} messages - The array of messages to be written. | ||
* @returns {Promise<void>} A promise that resolves when the messages have been written. | ||
*/ | ||
abstract writeMessages( | ||
threadId: string, | ||
messages: ThreadMessage[] | ||
): Promise<void>; | ||
|
||
/** | ||
* Retrieves all messages from a specific thread. | ||
* @param {string} threadId - The ID of the thread to retrieve the messages from. | ||
* @returns {Promise<ThreadMessage[]>} A promise that resolves to an array of messages from the thread. | ||
*/ | ||
abstract getAllMessages(threadId: string): Promise<ThreadMessage[]>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.