Fix ts: random id generation

This commit is contained in:
Will Chen
2025-04-21 16:21:33 -07:00
parent 7041525c20
commit d8b52a5d5f

View File

@@ -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: "",
},