refactor: app entities
This commit is contained in:
parent
52d56a8ae1
commit
4823c4f3fe
@ -12,44 +12,16 @@ export enum EventName {
|
|||||||
OnDownloadError = "onDownloadError",
|
OnDownloadError = "onDownloadError",
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MessageHistory = {
|
|
||||||
role: string;
|
|
||||||
content: string;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* The `NewMessageRequest` type defines the shape of a new message request object.
|
|
||||||
*/
|
|
||||||
export type NewMessageRequest = {
|
|
||||||
id?: string;
|
|
||||||
conversationId?: string;
|
|
||||||
user?: string;
|
|
||||||
avatar?: string;
|
|
||||||
message?: string;
|
|
||||||
createdAt?: string;
|
|
||||||
updatedAt?: string;
|
|
||||||
history?: MessageHistory[];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The `NewMessageRequest` type defines the shape of a new message request object.
|
|
||||||
*/
|
|
||||||
export type NewMessageResponse = {
|
|
||||||
id?: string;
|
|
||||||
conversationId?: string;
|
|
||||||
user?: string;
|
|
||||||
avatar?: string;
|
|
||||||
message?: string;
|
|
||||||
createdAt?: string;
|
|
||||||
updatedAt?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an observer for an event.
|
* Adds an observer for an event.
|
||||||
*
|
*
|
||||||
* @param eventName The name of the event to observe.
|
* @param eventName The name of the event to observe.
|
||||||
* @param handler The handler function to call when the event is observed.
|
* @param handler The handler function to call when the event is observed.
|
||||||
*/
|
*/
|
||||||
const on: (eventName: string, handler: Function) => void = (eventName, handler) => {
|
const on: (eventName: string, handler: Function) => void = (
|
||||||
|
eventName,
|
||||||
|
handler
|
||||||
|
) => {
|
||||||
window.corePlugin?.events?.on(eventName, handler);
|
window.corePlugin?.events?.on(eventName, handler);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -59,7 +31,10 @@ const on: (eventName: string, handler: Function) => void = (eventName, handler)
|
|||||||
* @param eventName The name of the event to stop observing.
|
* @param eventName The name of the event to stop observing.
|
||||||
* @param handler The handler function to call when the event is observed.
|
* @param handler The handler function to call when the event is observed.
|
||||||
*/
|
*/
|
||||||
const off: (eventName: string, handler: Function) => void = (eventName, handler) => {
|
const off: (eventName: string, handler: Function) => void = (
|
||||||
|
eventName,
|
||||||
|
handler
|
||||||
|
) => {
|
||||||
window.corePlugin?.events?.off(eventName, handler);
|
window.corePlugin?.events?.off(eventName, handler);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -34,4 +34,4 @@ export { fs } from "./fs";
|
|||||||
* Plugin base module export.
|
* Plugin base module export.
|
||||||
* @module
|
* @module
|
||||||
*/
|
*/
|
||||||
export { JanPlugin, PluginType } from "./plugin";
|
export * from "./plugin";
|
||||||
|
|||||||
@ -1,140 +1,183 @@
|
|||||||
export interface Conversation {
|
|
||||||
id: string;
|
|
||||||
modelId?: string;
|
|
||||||
botId?: string;
|
|
||||||
name: string;
|
|
||||||
message?: string;
|
|
||||||
summary?: string;
|
|
||||||
createdAt?: string;
|
|
||||||
updatedAt?: string;
|
|
||||||
messages: Message[];
|
|
||||||
lastMessage?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Message {
|
|
||||||
id: string;
|
|
||||||
message?: string;
|
|
||||||
user?: string;
|
|
||||||
createdAt?: string;
|
|
||||||
updatedAt?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RawMessage {
|
|
||||||
id?: string;
|
|
||||||
conversationId?: string;
|
|
||||||
user?: string;
|
|
||||||
avatar?: string;
|
|
||||||
message?: string;
|
|
||||||
createdAt?: string;
|
|
||||||
updatedAt?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Model {
|
|
||||||
/**
|
|
||||||
* Combination of owner and model name.
|
|
||||||
* Being used as file name. MUST be unique.
|
|
||||||
*/
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
quantMethod: string;
|
|
||||||
bits: number;
|
|
||||||
size: number;
|
|
||||||
maxRamRequired: number;
|
|
||||||
usecase: string;
|
|
||||||
downloadLink: string;
|
|
||||||
modelFile?: string;
|
|
||||||
/**
|
|
||||||
* For tracking download info
|
|
||||||
*/
|
|
||||||
startDownloadAt?: number;
|
|
||||||
finishDownloadAt?: number;
|
|
||||||
productId: string;
|
|
||||||
productName: string;
|
|
||||||
shortDescription: string;
|
|
||||||
longDescription: string;
|
|
||||||
avatarUrl: string;
|
|
||||||
author: string;
|
|
||||||
version: string;
|
|
||||||
modelUrl: string;
|
|
||||||
createdAt: number;
|
|
||||||
updatedAt?: number;
|
|
||||||
status: string;
|
|
||||||
releaseDate: number;
|
|
||||||
tags: string[];
|
|
||||||
}
|
|
||||||
export interface ModelCatalog {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
shortDescription: string;
|
|
||||||
avatarUrl: string;
|
|
||||||
longDescription: string;
|
|
||||||
author: string;
|
|
||||||
version: string;
|
|
||||||
modelUrl: string;
|
|
||||||
createdAt: number;
|
|
||||||
updatedAt?: number;
|
|
||||||
status: string;
|
|
||||||
releaseDate: number;
|
|
||||||
tags: string[];
|
|
||||||
availableVersions: ModelVersion[];
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Model type which will be stored in the database
|
* Message Request and Response
|
||||||
|
* ============================
|
||||||
|
* */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The role of the author of this message.
|
||||||
|
* @data_transfer_object
|
||||||
*/
|
*/
|
||||||
export type ModelVersion = {
|
export enum ChatCompletionRole {
|
||||||
/**
|
System = "system",
|
||||||
* Combination of owner and model name.
|
Assistant = "assistant",
|
||||||
* Being used as file name. Should be unique.
|
|
||||||
*/
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
quantMethod: string;
|
|
||||||
bits: number;
|
|
||||||
size: number;
|
|
||||||
maxRamRequired: number;
|
|
||||||
usecase: string;
|
|
||||||
downloadLink: string;
|
|
||||||
productId: string;
|
|
||||||
/**
|
|
||||||
* For tracking download state
|
|
||||||
*/
|
|
||||||
startDownloadAt?: number;
|
|
||||||
finishDownloadAt?: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface ChatMessage {
|
|
||||||
id: string;
|
|
||||||
conversationId: string;
|
|
||||||
messageType: MessageType;
|
|
||||||
messageSenderType: MessageSenderType;
|
|
||||||
senderUid: string;
|
|
||||||
senderName: string;
|
|
||||||
senderAvatarUrl: string;
|
|
||||||
text: string | undefined;
|
|
||||||
imageUrls?: string[] | undefined;
|
|
||||||
createdAt: number;
|
|
||||||
status: MessageStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum MessageType {
|
|
||||||
Text = "Text",
|
|
||||||
Image = "Image",
|
|
||||||
ImageWithText = "ImageWithText",
|
|
||||||
Error = "Error",
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum MessageSenderType {
|
|
||||||
Ai = "assistant",
|
|
||||||
User = "user",
|
User = "user",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `MessageRequest` type defines the shape of a new message request object.
|
||||||
|
* @data_transfer_object
|
||||||
|
*/
|
||||||
|
export type ChatCompletionMessage = {
|
||||||
|
/** The contents of the message. **/
|
||||||
|
content?: string;
|
||||||
|
/** The role of the author of this message. **/
|
||||||
|
role: ChatCompletionRole;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `MessageRequest` type defines the shape of a new message request object.
|
||||||
|
* @data_transfer_object
|
||||||
|
*/
|
||||||
|
export type MessageRequest = {
|
||||||
|
id?: string;
|
||||||
|
/** The thread id of the message request. **/
|
||||||
|
threadId?: string;
|
||||||
|
/** Messages for constructing a chat completion request **/
|
||||||
|
messages?: ChatCompletionMessage[];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thread and Message
|
||||||
|
* ========================
|
||||||
|
* */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The status of the message.
|
||||||
|
* @presentation_object
|
||||||
|
*/
|
||||||
export enum MessageStatus {
|
export enum MessageStatus {
|
||||||
|
/** Message is fully loaded. **/
|
||||||
Ready = "ready",
|
Ready = "ready",
|
||||||
|
/** Message is not fully loaded. **/
|
||||||
Pending = "pending",
|
Pending = "pending",
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
export type ConversationState = {
|
* The `ThreadMessage` type defines the shape of a thread's message object.
|
||||||
hasMore: boolean;
|
* @stored_in_workspace
|
||||||
waitingForResponse: boolean;
|
*/
|
||||||
error?: Error;
|
export type ThreadMessage = {
|
||||||
|
/** Unique identifier for the message, generated by default using the ULID method. **/
|
||||||
|
id?: string;
|
||||||
|
/** Thread id, default is a ulid. **/
|
||||||
|
threadId?: string;
|
||||||
|
/** The role of the author of this message. **/
|
||||||
|
role?: ChatCompletionRole;
|
||||||
|
/** The content of this message. **/
|
||||||
|
content?: string;
|
||||||
|
/** The status of this message. **/
|
||||||
|
status: MessageStatus;
|
||||||
|
/** The timestamp indicating when this message was created, represented in ISO 8601 format. **/
|
||||||
|
createdAt?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `Thread` type defines the shape of a thread object.
|
||||||
|
* @stored_in_workspace
|
||||||
|
*/
|
||||||
|
export interface Thread {
|
||||||
|
/** Unique identifier for the thread, generated by default using the ULID method. **/
|
||||||
|
id: string;
|
||||||
|
/** The summary of this thread. **/
|
||||||
|
summary?: string;
|
||||||
|
/** The messages of this thread. **/
|
||||||
|
messages: ThreadMessage[];
|
||||||
|
/** The timestamp indicating when this thread was created, represented in ISO 8601 format. **/
|
||||||
|
createdAt?: string;
|
||||||
|
/** The timestamp indicating when this thread was updated, represented in ISO 8601 format. **/
|
||||||
|
updatedAt?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This field is deprecated and should not be used.
|
||||||
|
* Read from model file instead.
|
||||||
|
*/
|
||||||
|
modelId?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model type defines the shape of a model object.
|
||||||
|
* @stored_in_workspace
|
||||||
|
*/
|
||||||
|
export interface Model {
|
||||||
|
/** Combination of owner and model name.*/
|
||||||
|
id: string;
|
||||||
|
/** The name of the model.*/
|
||||||
|
name: string;
|
||||||
|
/** Quantization method name.*/
|
||||||
|
quantizationName: string;
|
||||||
|
/** The the number of bits represents a number.*/
|
||||||
|
bits: number;
|
||||||
|
/** The size of the model file in bytes.*/
|
||||||
|
size: number;
|
||||||
|
/** The maximum RAM required to run the model in bytes.*/
|
||||||
|
maxRamRequired: number;
|
||||||
|
/** The use case of the model.*/
|
||||||
|
usecase: string;
|
||||||
|
/** The download link of the model.*/
|
||||||
|
downloadLink: string;
|
||||||
|
/** The short description of the model.*/
|
||||||
|
shortDescription: string;
|
||||||
|
/** The long description of the model.*/
|
||||||
|
longDescription: string;
|
||||||
|
/** The avatar url of the model.*/
|
||||||
|
avatarUrl: string;
|
||||||
|
/** The author name of the model.*/
|
||||||
|
author: string;
|
||||||
|
/** The version of the model.*/
|
||||||
|
version: string;
|
||||||
|
/** The origin url of the model repo.*/
|
||||||
|
modelUrl: string;
|
||||||
|
/** The timestamp indicating when this model was released.*/
|
||||||
|
releaseDate: number;
|
||||||
|
/** The tags attached to the model description */
|
||||||
|
tags: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model type of the presentation object which will be presented to the user
|
||||||
|
* @data_transfer_object
|
||||||
|
*/
|
||||||
|
export interface ModelCatalog {
|
||||||
|
/** The unique id of the model.*/
|
||||||
|
id: string;
|
||||||
|
/** The name of the model.*/
|
||||||
|
name: string;
|
||||||
|
/** The avatar url of the model.*/
|
||||||
|
avatarUrl: string;
|
||||||
|
/** The short description of the model.*/
|
||||||
|
shortDescription: string;
|
||||||
|
/** The long description of the model.*/
|
||||||
|
longDescription: string;
|
||||||
|
/** The author name of the model.*/
|
||||||
|
author: string;
|
||||||
|
/** The version of the model.*/
|
||||||
|
version: string;
|
||||||
|
/** The origin url of the model repo.*/
|
||||||
|
modelUrl: string;
|
||||||
|
/** The timestamp indicating when this model was released.*/
|
||||||
|
releaseDate: number;
|
||||||
|
/** The tags attached to the model description **/
|
||||||
|
tags: string[];
|
||||||
|
|
||||||
|
/** The available versions of this model to download. */
|
||||||
|
availableVersions: ModelVersion[];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Model type which will be present a version of ModelCatalog
|
||||||
|
* @data_transfer_object
|
||||||
|
*/
|
||||||
|
export type ModelVersion = {
|
||||||
|
/** The name of this model version.*/
|
||||||
|
name: string;
|
||||||
|
/** The quantization method name.*/
|
||||||
|
quantizationName: string;
|
||||||
|
/** The the number of bits represents a number.*/
|
||||||
|
bits: number;
|
||||||
|
/** The size of the model file in bytes.*/
|
||||||
|
size: number;
|
||||||
|
/** The maximum RAM required to run the model in bytes.*/
|
||||||
|
maxRamRequired: number;
|
||||||
|
/** The use case of the model.*/
|
||||||
|
usecase: string;
|
||||||
|
/** The download link of the model.*/
|
||||||
|
downloadLink: string;
|
||||||
};
|
};
|
||||||
|
|||||||
5
web/types/conversation.d.ts
vendored
Normal file
5
web/types/conversation.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export type ConversationState = {
|
||||||
|
hasMore: boolean
|
||||||
|
waitingForResponse: boolean
|
||||||
|
error?: Error
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user