Fix ts: random id generation
This commit is contained in:
@@ -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({
|
|||||||
return [
|
return [
|
||||||
...remainingMessages,
|
...remainingMessages,
|
||||||
{
|
{
|
||||||
id: getRandomString(),
|
id: getRandomNumberId(),
|
||||||
role: "assistant",
|
role: "assistant",
|
||||||
content: "",
|
content: "",
|
||||||
},
|
},
|
||||||
@@ -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: "",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user