fix: #244 optimize polyfill
This commit is contained in:
parent
328a903c24
commit
37587f6f71
@ -21,7 +21,13 @@ import CloseIcon from "../icons/close.svg";
|
|||||||
import CopyIcon from "../icons/copy.svg";
|
import CopyIcon from "../icons/copy.svg";
|
||||||
import DownloadIcon from "../icons/download.svg";
|
import DownloadIcon from "../icons/download.svg";
|
||||||
|
|
||||||
import { Message, SubmitKey, useChatStore, ChatSession } from "../store";
|
import {
|
||||||
|
Message,
|
||||||
|
SubmitKey,
|
||||||
|
useChatStore,
|
||||||
|
ChatSession,
|
||||||
|
BOT_HELLO,
|
||||||
|
} from "../store";
|
||||||
import { showModal, showToast } from "./ui-lib";
|
import { showModal, showToast } from "./ui-lib";
|
||||||
import {
|
import {
|
||||||
copyToClipboard,
|
copyToClipboard,
|
||||||
@ -307,17 +313,18 @@ export function Chat(props: {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
: [],
|
: [],
|
||||||
).concat(
|
)
|
||||||
userInput.length > 0 && config.sendPreviewBubble
|
.concat(
|
||||||
? [
|
userInput.length > 0 && config.sendPreviewBubble
|
||||||
{
|
? [
|
||||||
role: "user",
|
{
|
||||||
content: userInput,
|
role: "user",
|
||||||
date: new Date().toLocaleString(),
|
content: userInput,
|
||||||
preview: false,
|
date: new Date().toLocaleString(),
|
||||||
},
|
preview: false,
|
||||||
]
|
},
|
||||||
: [],
|
]
|
||||||
|
: [],
|
||||||
);
|
);
|
||||||
|
|
||||||
// auto scroll
|
// auto scroll
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import { Analytics } from "@vercel/analytics/react";
|
import { Analytics } from "@vercel/analytics/react";
|
||||||
|
|
||||||
|
import "array.prototype.at";
|
||||||
|
|
||||||
import { Home } from "./components/home";
|
import { Home } from "./components/home";
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
|
@ -2,10 +2,6 @@ import type { ChatRequest, ChatReponse } from "./api/openai/typing";
|
|||||||
import { filterConfig, Message, ModelConfig, useAccessStore } from "./store";
|
import { filterConfig, Message, ModelConfig, useAccessStore } from "./store";
|
||||||
import Locale from "./locales";
|
import Locale from "./locales";
|
||||||
|
|
||||||
if (!Array.prototype.at) {
|
|
||||||
require("array.prototype.at/auto");
|
|
||||||
}
|
|
||||||
|
|
||||||
const TIME_OUT_MS = 30000;
|
const TIME_OUT_MS = 30000;
|
||||||
|
|
||||||
const makeRequestParam = (
|
const makeRequestParam = (
|
||||||
|
@ -11,10 +11,6 @@ import { trimTopic } from "../utils";
|
|||||||
|
|
||||||
import Locale from "../locales";
|
import Locale from "../locales";
|
||||||
|
|
||||||
if (!Array.prototype.at) {
|
|
||||||
require("array.prototype.at/auto");
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Message = ChatCompletionResponseMessage & {
|
export type Message = ChatCompletionResponseMessage & {
|
||||||
date: string;
|
date: string;
|
||||||
streaming?: boolean;
|
streaming?: boolean;
|
||||||
@ -162,6 +158,11 @@ export interface ChatSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_TOPIC = Locale.Store.DefaultTopic;
|
const DEFAULT_TOPIC = Locale.Store.DefaultTopic;
|
||||||
|
export const BOT_HELLO = {
|
||||||
|
role: "assistant",
|
||||||
|
content: Locale.Store.BotHello,
|
||||||
|
date: "",
|
||||||
|
};
|
||||||
|
|
||||||
function createEmptySession(): ChatSession {
|
function createEmptySession(): ChatSession {
|
||||||
const createDate = new Date().toLocaleString();
|
const createDate = new Date().toLocaleString();
|
||||||
@ -170,13 +171,7 @@ function createEmptySession(): ChatSession {
|
|||||||
id: Date.now(),
|
id: Date.now(),
|
||||||
topic: DEFAULT_TOPIC,
|
topic: DEFAULT_TOPIC,
|
||||||
memoryPrompt: "",
|
memoryPrompt: "",
|
||||||
messages: [
|
messages: [],
|
||||||
{
|
|
||||||
role: "assistant",
|
|
||||||
content: Locale.Store.BotHello,
|
|
||||||
date: createDate,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
stat: {
|
stat: {
|
||||||
tokenCount: 0,
|
tokenCount: 0,
|
||||||
wordCount: 0,
|
wordCount: 0,
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@svgr/webpack": "^6.5.1",
|
"@svgr/webpack": "^6.5.1",
|
||||||
"@vercel/analytics": "^0.1.11",
|
"@vercel/analytics": "^0.1.11",
|
||||||
|
"array.prototype.at": "^1.1.1",
|
||||||
"emoji-picker-react": "^4.4.7",
|
"emoji-picker-react": "^4.4.7",
|
||||||
"eventsource-parser": "^0.1.0",
|
"eventsource-parser": "^0.1.0",
|
||||||
"fuse.js": "^6.6.2",
|
"fuse.js": "^6.6.2",
|
||||||
@ -39,7 +40,6 @@
|
|||||||
"@types/react-dom": "^18.0.11",
|
"@types/react-dom": "^18.0.11",
|
||||||
"@types/react-katex": "^3.0.0",
|
"@types/react-katex": "^3.0.0",
|
||||||
"@types/spark-md5": "^3.0.2",
|
"@types/spark-md5": "^3.0.2",
|
||||||
"array.prototype.at": "^1.1.1",
|
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"eslint": "^8.36.0",
|
"eslint": "^8.36.0",
|
||||||
"eslint-config-next": "13.2.3",
|
"eslint-config-next": "13.2.3",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user