-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Firestore data structures and conversion functions for discussion…
…s, resources, sessions, and speech
- Loading branch information
1 parent
bb0c259
commit 87e1628
Showing
5 changed files
with
151 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import type { Timestamp } from 'firebase-admin/firestore'; | ||
|
||
// Firestore data structure | ||
export interface FirestoreIndividualDiscussion { | ||
userId: string; | ||
sessionId: string; | ||
groupId: string; | ||
history: { | ||
role: 'system' | 'assistant' | 'user'; | ||
content: string; | ||
speechId: string | null; | ||
timestamp: Timestamp; | ||
}[]; | ||
summary: string; | ||
} | ||
|
||
// Client-side data structure (serializable) | ||
export interface IndividualDiscussion { | ||
userId: string; | ||
sessionId: string; | ||
groupId: string; | ||
history: { | ||
role: 'system' | 'assistant' | 'user'; | ||
content: string; | ||
speechId: string | null; | ||
timestamp: string; | ||
}[]; | ||
summary: string; | ||
} | ||
|
||
// convert Firestore data to client-side data | ||
export function convertFirestoreIndividualDiscussion( | ||
data: FirestoreIndividualDiscussion | ||
): IndividualDiscussion { | ||
return { | ||
userId: data.userId, | ||
sessionId: data.sessionId, | ||
groupId: data.groupId, | ||
history: data.history.map((history) => ({ | ||
role: history.role, | ||
content: history.content, | ||
speechId: history.speechId, | ||
timestamp: history.timestamp.toDate().toISOString() | ||
})), | ||
summary: data.summary | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import type { Timestamp } from 'firebase-admin/firestore'; | ||
|
||
// Firestore data structure | ||
export interface FirestoreGroupDiscussion { | ||
sessionId: string; | ||
groupId: string; | ||
history: { | ||
name: string; | ||
content: string; | ||
speechId: string | null; | ||
timestamp: Timestamp; | ||
}[]; | ||
analysis: { | ||
summary: string; | ||
keywords: string[]; | ||
}; | ||
} | ||
|
||
// Client-side data structure (serializable) | ||
export interface GroupDiscussion { | ||
sessionId: string; | ||
groupId: string; | ||
history: { | ||
name: string; | ||
content: string; | ||
speechId: string | null; | ||
timestamp: string; | ||
}[]; | ||
analysis: { | ||
summary: string; | ||
keywords: string[]; | ||
}; | ||
} | ||
|
||
// convert Firestore data to client-side data | ||
export function convertFirestoreGroupDiscussion(data: FirestoreGroupDiscussion): GroupDiscussion { | ||
return { | ||
sessionId: data.sessionId, | ||
groupId: data.groupId, | ||
history: data.history.map((history) => ({ | ||
name: history.name, | ||
content: history.content, | ||
speechId: history.speechId, | ||
timestamp: history.timestamp.toDate().toISOString() | ||
})), | ||
analysis: { | ||
summary: data.analysis.summary, | ||
keywords: data.analysis.keywords | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Timestamp } from 'firebase-admin/firestore'; | ||
|
||
export interface FirestoreResource { | ||
name: string; | ||
fileId: string; | ||
text: string; | ||
addedAt: Timestamp; | ||
} | ||
|
||
export interface Resource { | ||
name: string; | ||
fileId: string; | ||
text: string; | ||
addedAt: string; | ||
} | ||
|
||
export function convertFirestoreResources(data: FirestoreResource): Resource { | ||
return { | ||
name: data.name, | ||
fileId: data.fileId, | ||
text: data.text, | ||
addedAt: data.addedAt.toDate().toISOString() | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface SpeechFirestore { | ||
speechId: string; | ||
fileid: string; | ||
transation: string; | ||
} |