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,
|
||||
content: [],
|
||||
status: MessageStatus.Pending,
|
||||
created: timestamp,
|
||||
updated: timestamp,
|
||||
created_at: timestamp,
|
||||
completed_at: timestamp,
|
||||
object: 'thread.message',
|
||||
}
|
||||
|
||||
|
||||
@ -194,8 +194,8 @@ export const createMessage = async (threadId: string, message: any) => {
|
||||
id: msgId,
|
||||
thread_id: threadId,
|
||||
status: MessageStatus.Ready,
|
||||
created: createdAt,
|
||||
updated: createdAt,
|
||||
created_at: createdAt,
|
||||
completed_at: createdAt,
|
||||
object: 'thread.message',
|
||||
role: message.role,
|
||||
content: [
|
||||
|
||||
@ -27,9 +27,9 @@ export type ThreadMessage = {
|
||||
/** The status of this message. **/
|
||||
status: MessageStatus
|
||||
/** 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. **/
|
||||
updated: number
|
||||
completed_at: number
|
||||
/** The additional metadata of this message. **/
|
||||
metadata?: Record<string, unknown>
|
||||
|
||||
|
||||
@ -181,7 +181,7 @@ export default function useSendChatMessage() {
|
||||
// Update thread state
|
||||
const updatedThread: Thread = {
|
||||
...activeThreadRef.current,
|
||||
updated: newMessage.created,
|
||||
updated: newMessage.created_at,
|
||||
metadata: {
|
||||
...activeThreadRef.current.metadata,
|
||||
lastMessage: prompt,
|
||||
|
||||
@ -91,7 +91,7 @@ const MessageContainer: React.FC<
|
||||
: (activeAssistant?.assistant_name ?? props.role)}
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
|
||||
@ -6,7 +6,10 @@ export const isToday = (timestamp: number) => {
|
||||
export const displayDate = (timestamp?: string | number | Date) => {
|
||||
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, {
|
||||
day: '2-digit',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user