mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 18:44:30 -07:00
refactor(core): improve type safety in apiContentToMessageRecords
This commit is contained in:
@@ -227,17 +227,22 @@ export class ChatRecordingService {
|
||||
* Converts API Content array to storage-compatible MessageRecord array.
|
||||
*/
|
||||
private apiContentToMessageRecords(history: Content[]): MessageRecord[] {
|
||||
return history.map((content) => {
|
||||
const type = content.role === 'model' ? 'gemini' : 'user';
|
||||
const record = {
|
||||
id: randomUUID(),
|
||||
timestamp: new Date().toISOString(),
|
||||
type,
|
||||
content: content.parts,
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
return record as MessageRecord;
|
||||
return history.map((content): MessageRecord => {
|
||||
if (content.role === 'model') {
|
||||
return {
|
||||
id: randomUUID(),
|
||||
timestamp: new Date().toISOString(),
|
||||
type: 'gemini',
|
||||
content: content.parts || [],
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
id: randomUUID(),
|
||||
timestamp: new Date().toISOString(),
|
||||
type: 'user',
|
||||
content: content.parts || [],
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user