提交 d8b52a5d authored 作者: Will Chen's avatar Will Chen

Fix ts: random id generation

上级 7041525c
...@@ -19,8 +19,8 @@ import { useProposal } from "./useProposal"; ...@@ -19,8 +19,8 @@ import { useProposal } from "./useProposal";
import { useSearch } from "@tanstack/react-router"; import { useSearch } from "@tanstack/react-router";
import { useRunApp } from "./useRunApp"; import { useRunApp } from "./useRunApp";
export function getRandomString() { export function getRandomNumberId() {
return Math.random().toString(36).substring(2, 15); return Math.floor(Math.random() * 1_000_000_000_000_000);
} }
export function useStreamChat({ export function useStreamChat({
...@@ -70,7 +70,7 @@ export function useStreamChat({ ...@@ -70,7 +70,7 @@ export function useStreamChat({
return [ return [
...remainingMessages, ...remainingMessages,
{ {
id: getRandomString(), id: getRandomNumberId(),
role: "assistant", role: "assistant",
content: "", content: "",
}, },
...@@ -79,12 +79,12 @@ export function useStreamChat({ ...@@ -79,12 +79,12 @@ export function useStreamChat({
return [ return [
...currentMessages, ...currentMessages,
{ {
id: getRandomString(), id: getRandomNumberId(),
role: "user", role: "user",
content: prompt, content: prompt,
}, },
{ {
id: getRandomString(), id: getRandomNumberId(),
role: "assistant", role: "assistant",
content: "", content: "",
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论