fix: timestamp issue
This commit is contained in:
parent
66e37d80d6
commit
8613e35c15
@ -80,8 +80,8 @@ export abstract class OAIEngine extends AIEngine {
|
|||||||
role: ChatCompletionRole.Assistant,
|
role: ChatCompletionRole.Assistant,
|
||||||
content: [],
|
content: [],
|
||||||
status: MessageStatus.Pending,
|
status: MessageStatus.Pending,
|
||||||
created: timestamp,
|
created_at: timestamp,
|
||||||
updated: timestamp,
|
completed_at: timestamp,
|
||||||
object: 'thread.message',
|
object: 'thread.message',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -194,8 +194,8 @@ export const createMessage = async (threadId: string, message: any) => {
|
|||||||
id: msgId,
|
id: msgId,
|
||||||
thread_id: threadId,
|
thread_id: threadId,
|
||||||
status: MessageStatus.Ready,
|
status: MessageStatus.Ready,
|
||||||
created: createdAt,
|
created_at: createdAt,
|
||||||
updated: createdAt,
|
completed_at: createdAt,
|
||||||
object: 'thread.message',
|
object: 'thread.message',
|
||||||
role: message.role,
|
role: message.role,
|
||||||
content: [
|
content: [
|
||||||
|
|||||||
@ -27,9 +27,9 @@ export type ThreadMessage = {
|
|||||||
/** The status of this message. **/
|
/** The status of this message. **/
|
||||||
status: MessageStatus
|
status: MessageStatus
|
||||||
/** The timestamp indicating when this message was created. Represented in Unix time. **/
|
/** The timestamp indicating when this message was created. Represented in Unix time. **/
|
||||||
created: number
|
created_at: number
|
||||||
/** The timestamp indicating when this message was updated. Represented in Unix time. **/
|
/** The timestamp indicating when this message was updated. Represented in Unix time. **/
|
||||||
updated: number
|
completed_at: number
|
||||||
/** The additional metadata of this message. **/
|
/** The additional metadata of this message. **/
|
||||||
metadata?: Record<string, unknown>
|
metadata?: Record<string, unknown>
|
||||||
|
|
||||||
|
|||||||
@ -181,7 +181,7 @@ export default function useSendChatMessage() {
|
|||||||
// Update thread state
|
// Update thread state
|
||||||
const updatedThread: Thread = {
|
const updatedThread: Thread = {
|
||||||
...activeThreadRef.current,
|
...activeThreadRef.current,
|
||||||
updated: newMessage.created,
|
updated: newMessage.created_at,
|
||||||
metadata: {
|
metadata: {
|
||||||
...activeThreadRef.current.metadata,
|
...activeThreadRef.current.metadata,
|
||||||
lastMessage: prompt,
|
lastMessage: prompt,
|
||||||
|
|||||||
@ -91,7 +91,7 @@ const MessageContainer: React.FC<
|
|||||||
: (activeAssistant?.assistant_name ?? props.role)}
|
: (activeAssistant?.assistant_name ?? props.role)}
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs font-medium text-gray-400">
|
<p className="text-xs font-medium text-gray-400">
|
||||||
{props.created && displayDate(props.created ?? new Date())}
|
{props.created_at && displayDate(props.created_at ?? new Date())}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,10 @@ export const isToday = (timestamp: number) => {
|
|||||||
export const displayDate = (timestamp?: string | number | Date) => {
|
export const displayDate = (timestamp?: string | number | Date) => {
|
||||||
if (!timestamp) return 'N/A'
|
if (!timestamp) return 'N/A'
|
||||||
|
|
||||||
const date = new Date(timestamp)
|
const date =
|
||||||
|
typeof timestamp === 'number'
|
||||||
|
? new Date(timestamp * 1000)
|
||||||
|
: new Date(timestamp)
|
||||||
|
|
||||||
let displayDate = `${date.toLocaleDateString(undefined, {
|
let displayDate = `${date.toLocaleDateString(undefined, {
|
||||||
day: '2-digit',
|
day: '2-digit',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user