mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-07-28 17:53:21 +08:00
feat: implement connection and database types
This commit is contained in:
@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
import TextareaAutosize from "react-textarea-autosize";
|
||||
import { localUser, useChatStore, useMessageStore } from "../../store";
|
||||
import { CreatorRole } from "../../types";
|
||||
import { generateUUID } from "../../utils";
|
||||
import Icon from "../Icon";
|
||||
|
||||
@ -45,6 +46,7 @@ const MessageTextarea = (props: Props) => {
|
||||
id: generateUUID(),
|
||||
chatId: chatStore.currentChat.id,
|
||||
creatorId: localUser.id,
|
||||
creatorRole: CreatorRole.User,
|
||||
createdAt: Date.now(),
|
||||
content: value,
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import axios from "axios";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { defaultChat, getAssistantById, getPromptOfAssistant, localUser, useChatStore, useMessageStore } from "../../store";
|
||||
import { Chat, Message, UserRole } from "../../types";
|
||||
import { Chat, CreatorRole, Message } from "../../types";
|
||||
import { generateUUID } from "../../utils";
|
||||
import Icon from "../Icon";
|
||||
import Header from "./Header";
|
||||
@ -50,11 +50,11 @@ const ChatView = () => {
|
||||
const { data } = await axios.post<string>("/api/chat", {
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
role: CreatorRole.System,
|
||||
content: prompt,
|
||||
},
|
||||
...messageList.map((message) => ({
|
||||
role: message.creatorId === localUser.id ? UserRole.User : UserRole.Assistant,
|
||||
role: message.creatorId === localUser.id ? CreatorRole.User : CreatorRole.Assistant,
|
||||
content: message.content,
|
||||
})),
|
||||
],
|
||||
@ -63,6 +63,7 @@ const ChatView = () => {
|
||||
id: generateUUID(),
|
||||
chatId: currentChat.id,
|
||||
creatorId: currentChat.assistantId,
|
||||
creatorRole: CreatorRole.Assistant,
|
||||
createdAt: Date.now(),
|
||||
content: data,
|
||||
});
|
||||
|
Reference in New Issue
Block a user