-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Signed-off-by: James <james@jan.ai>
- Loading branch information
James
committed
Nov 28, 2023
1 parent
9bf39cb
commit edb4661
Showing
61 changed files
with
1,884 additions
and
991 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Assistant } from "../index"; | ||
import { JanPlugin } from "../plugin"; | ||
|
||
/** | ||
* Abstract class for assistant plugins. | ||
* @extends JanPlugin | ||
*/ | ||
export abstract class AssistantPlugin extends JanPlugin { | ||
abstract createAssistant(assistant: Assistant): Promise<void>; | ||
|
||
abstract deleteAssistant(assistant: Assistant): Promise<void>; | ||
|
||
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,36 @@ | ||
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>; | ||
|
||
abstract addNewMessage(message: ThreadMessage): Promise<void>; | ||
|
||
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.