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

Fix ts: random id generation

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