mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-09 06:50:24 +08:00
feat: add basic ui
This commit is contained in:
40
app/store.ts
Normal file
40
app/store.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { type ChatCompletionResponseMessage } from "openai";
|
||||
|
||||
export type Message = ChatCompletionResponseMessage;
|
||||
|
||||
interface ChatConfig {
|
||||
maxToken: number;
|
||||
}
|
||||
|
||||
class ChatSession {
|
||||
constructor(private id: string) {}
|
||||
|
||||
public async onChatMessage(message: Message) {
|
||||
if (message.role === "assistant") {
|
||||
// do nothing
|
||||
} else if (message.role === "user") {
|
||||
// TODO: request open chat
|
||||
this.makeRequest();
|
||||
} else throw Error("Only assistant or users message allowed here.");
|
||||
|
||||
this.historyMessages.push(message);
|
||||
this.summarize();
|
||||
this.save();
|
||||
}
|
||||
public async summarize() {}
|
||||
public save() {}
|
||||
public delete() {}
|
||||
|
||||
private makeRequest() {}
|
||||
|
||||
private topic = "";
|
||||
private memoryPrompt = "";
|
||||
private historyMessages: Message[] = [];
|
||||
private messageWordCount = 0;
|
||||
}
|
||||
|
||||
class ChatSessionManager {
|
||||
private entryId = "chatgpt-next-web-sessions";
|
||||
}
|
||||
|
||||
export const store = {};
|
Reference in New Issue
Block a user