mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-07-30 02:32:03 +08:00
feat: implement connection and database types
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { first } from "lodash-es";
|
||||
import { Id, User, UserRole } from "../types";
|
||||
import { Id, User } from "../types";
|
||||
|
||||
// Assistant is a special user.
|
||||
export const assistantList: User[] = [
|
||||
@ -8,7 +8,6 @@ export const assistantList: User[] = [
|
||||
name: "SQL Chat",
|
||||
description: "🤖️ I'm an expert in SQL. I can answer your questions about databases and SQL.",
|
||||
avatar: "",
|
||||
role: UserRole.Assistant,
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
import { create } from "zustand";
|
||||
import { persist } from "zustand/middleware";
|
||||
import { Chat, User } from "../types";
|
||||
import { Chat, UNKNOWN_ID, User } from "../types";
|
||||
import { generateUUID } from "../utils";
|
||||
|
||||
export const defaultChat: Chat = {
|
||||
id: generateUUID(),
|
||||
connectionId: UNKNOWN_ID,
|
||||
databaseName: "",
|
||||
assistantId: "sql-assistant",
|
||||
};
|
||||
|
||||
@ -20,10 +22,12 @@ export const useChatStore = create<ChatState>()(
|
||||
(set) => ({
|
||||
chatList: [defaultChat],
|
||||
currentChat: defaultChat,
|
||||
createChat: (user: User) => {
|
||||
createChat: (assistant: User) => {
|
||||
const chat: Chat = {
|
||||
id: generateUUID(),
|
||||
assistantId: user.id,
|
||||
connectionId: UNKNOWN_ID,
|
||||
databaseName: "",
|
||||
assistantId: assistant.id,
|
||||
};
|
||||
set((state) => ({
|
||||
chatList: [...state.chatList, chat],
|
||||
|
@ -1,9 +1,8 @@
|
||||
import { User, UserRole } from "../types";
|
||||
import { User } from "../types";
|
||||
|
||||
export const localUser: User = {
|
||||
id: "local-user",
|
||||
name: "Local user",
|
||||
description: "",
|
||||
avatar: "",
|
||||
role: UserRole.User,
|
||||
};
|
||||
|
Reference in New Issue
Block a user