forked from janhq/jan
-
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.
Merge pull request janhq#966 from janhq/cleanTypes
refactor: clean types and interfaces
- Loading branch information
Showing
27 changed files
with
590 additions
and
488 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,12 @@ | ||
import { Assistant } from "../index"; | ||
import { BaseExtension } from "../extension"; | ||
import { Assistant, AssistantInterface } from '../index' | ||
import { BaseExtension } from '../extension' | ||
|
||
/** | ||
* Assistant extension for managing assistants. | ||
* @extends BaseExtension | ||
*/ | ||
export abstract class AssistantExtension extends BaseExtension { | ||
/** | ||
* 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[]>; | ||
export abstract class AssistantExtension extends BaseExtension implements AssistantInterface { | ||
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,57 +1,19 @@ | ||
import { Thread, ThreadMessage } from "../index"; | ||
import { BaseExtension } from "../extension"; | ||
import { Thread, ThreadInterface, ThreadMessage, MessageInterface } from '../index' | ||
import { BaseExtension } from '../extension' | ||
|
||
/** | ||
* Conversational extension. Persists and retrieves conversations. | ||
* @abstract | ||
* @extends BaseExtension | ||
*/ | ||
export abstract class ConversationalExtension extends BaseExtension { | ||
/** | ||
* Returns a list of thread. | ||
* @abstract | ||
* @returns {Promise<Thread[]>} A promise that resolves to an array of threads. | ||
*/ | ||
abstract getThreads(): Promise<Thread[]>; | ||
|
||
/** | ||
* Saves a thread. | ||
* @abstract | ||
* @param {Thread} thread - The thread to save. | ||
* @returns {Promise<void>} A promise that resolves when the thread is saved. | ||
*/ | ||
abstract saveThread(thread: Thread): Promise<void>; | ||
|
||
/** | ||
* Deletes a thread. | ||
* @abstract | ||
* @param {string} threadId - The ID of the thread to delete. | ||
* @returns {Promise<void>} A promise that resolves when the thread is deleted. | ||
*/ | ||
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[]>; | ||
export abstract class ConversationalExtension | ||
extends BaseExtension | ||
implements ThreadInterface, MessageInterface | ||
{ | ||
abstract getThreads(): Promise<Thread[]> | ||
abstract saveThread(thread: Thread): Promise<void> | ||
abstract deleteThread(threadId: string): Promise<void> | ||
abstract addNewMessage(message: ThreadMessage): Promise<void> | ||
abstract writeMessages(threadId: string, messages: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
import { MessageRequest, ModelSettingParams, ThreadMessage } from "../index"; | ||
import { BaseExtension } from "../extension"; | ||
import { InferenceInterface, MessageRequest, ThreadMessage } from '../index' | ||
import { BaseExtension } from '../extension' | ||
|
||
/** | ||
* Inference extension. Start, stop and inference models. | ||
*/ | ||
export abstract class InferenceExtension extends BaseExtension { | ||
/** | ||
* Processes an inference request. | ||
* @param data - The data for the inference request. | ||
* @returns The result of the inference request. | ||
*/ | ||
abstract inference(data: MessageRequest): Promise<ThreadMessage>; | ||
export abstract class InferenceExtension extends BaseExtension implements InferenceInterface { | ||
abstract inference(data: MessageRequest): 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,14 @@ | ||
import { BaseExtension } from "../extension"; | ||
import { Model } from "../types/index"; | ||
import { BaseExtension } from '../extension' | ||
import { Model, ModelInterface } from '../index' | ||
|
||
/** | ||
* Model extension for managing models. | ||
*/ | ||
export abstract class ModelExtension extends BaseExtension { | ||
/** | ||
* Downloads a model. | ||
* @param model - The model to download. | ||
* @returns A Promise that resolves when the model has been downloaded. | ||
*/ | ||
abstract downloadModel(model: Model): Promise<void>; | ||
|
||
/** | ||
* Cancels the download of a specific model. | ||
* @param {string} modelId - The ID of the model to cancel the download for. | ||
* @returns {Promise<void>} A promise that resolves when the download has been cancelled. | ||
*/ | ||
abstract cancelModelDownload(modelId: string): Promise<void>; | ||
|
||
/** | ||
* Deletes a model. | ||
* @param modelId - The ID of the model to delete. | ||
* @returns A Promise that resolves when the model has been deleted. | ||
*/ | ||
abstract deleteModel(modelId: string): Promise<void>; | ||
|
||
/** | ||
* Saves a model. | ||
* @param model - The model to save. | ||
* @returns A Promise that resolves when the model has been saved. | ||
*/ | ||
abstract saveModel(model: Model): Promise<void>; | ||
|
||
/** | ||
* Gets a list of downloaded models. | ||
* @returns A Promise that resolves with an array of downloaded models. | ||
*/ | ||
abstract getDownloadedModels(): Promise<Model[]>; | ||
|
||
/** | ||
* Gets a list of configured models. | ||
* @returns A Promise that resolves with an array of configured models. | ||
*/ | ||
abstract getConfiguredModels(): Promise<Model[]>; | ||
export abstract class ModelExtension extends BaseExtension implements ModelInterface { | ||
abstract downloadModel(model: Model): Promise<void> | ||
abstract cancelModelDownload(modelId: string): Promise<void> | ||
abstract deleteModel(modelId: string): Promise<void> | ||
abstract saveModel(model: Model): Promise<void> | ||
abstract getDownloadedModels(): Promise<Model[]> | ||
abstract getConfiguredModels(): Promise<Model[]> | ||
} |
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,19 +1,11 @@ | ||
import { BaseExtension } from "../extension"; | ||
import { BaseExtension } from '../extension' | ||
import { MonitoringInterface } from '../index' | ||
|
||
/** | ||
* Monitoring extension for system monitoring. | ||
* @extends BaseExtension | ||
*/ | ||
export abstract class MonitoringExtension extends BaseExtension { | ||
/** | ||
* Returns information about the system resources. | ||
* @returns {Promise<any>} A promise that resolves with the system resources information. | ||
*/ | ||
abstract getResourcesInfo(): Promise<any>; | ||
|
||
/** | ||
* Returns the current system load. | ||
* @returns {Promise<any>} A promise that resolves with the current system load. | ||
*/ | ||
abstract getCurrentLoad(): Promise<any>; | ||
export abstract class MonitoringExtension extends BaseExtension implements MonitoringInterface { | ||
abstract getResourcesInfo(): Promise<any> | ||
abstract getCurrentLoad(): Promise<any> | ||
} |
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,30 @@ | ||
/** | ||
* Assistant type defines the shape of an assistant object. | ||
* @stored | ||
*/ | ||
export type Assistant = { | ||
/** Represents the avatar of the user. */ | ||
avatar: string | ||
/** Represents the location of the thread. */ | ||
thread_location: string | undefined | ||
/** Represents the unique identifier of the object. */ | ||
id: string | ||
/** Represents the object. */ | ||
object: string | ||
/** Represents the creation timestamp of the object. */ | ||
created_at: number | ||
/** Represents the name of the object. */ | ||
name: string | ||
/** Represents the description of the object. */ | ||
description?: string | ||
/** Represents the model of the object. */ | ||
model: string | ||
/** Represents the instructions for the object. */ | ||
instructions?: string | ||
/** Represents the tools associated with the object. */ | ||
tools?: any | ||
/** Represents the file identifiers associated with the object. */ | ||
file_ids: string[] | ||
/** Represents the metadata of the object. */ | ||
metadata?: Record<string, unknown> | ||
} |
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,26 @@ | ||
import { Assistant } from './assistantEntity' | ||
/** | ||
* Assistant extension for managing assistants. | ||
* @extends BaseExtension | ||
*/ | ||
export interface AssistantInterface { | ||
/** | ||
* 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. | ||
*/ | ||
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. | ||
*/ | ||
deleteAssistant(assistant: Assistant): Promise<void> | ||
|
||
/** | ||
* Retrieves all existing assistants. | ||
* @returns {Promise<Assistant[]>} A promise that resolves to an array of all assistants. | ||
*/ | ||
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './assistantEntity' | ||
export * from './assistantInterface' |
Oops, something went wrong.