Change PIN to 1451
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
38
apps/captain-mobile-v2/flutter/lib/models/conversation.dart
Normal file
38
apps/captain-mobile-v2/flutter/lib/models/conversation.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
class Conversation {
|
||||
final String id;
|
||||
final String? title;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final int messageCount;
|
||||
|
||||
Conversation({
|
||||
required this.id,
|
||||
this.title,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
this.messageCount = 0,
|
||||
});
|
||||
|
||||
factory Conversation.fromJson(Map<String, dynamic> json) {
|
||||
return Conversation(
|
||||
id: json['id'],
|
||||
title: json['title'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
messageCount: json['message_count'] ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
String get displayTitle => title ?? 'New Conversation';
|
||||
|
||||
String get timeAgo {
|
||||
final now = DateTime.now();
|
||||
final diff = now.difference(updatedAt);
|
||||
|
||||
if (diff.inMinutes < 1) return 'Just now';
|
||||
if (diff.inMinutes < 60) return '${diff.inMinutes}m ago';
|
||||
if (diff.inHours < 24) return '${diff.inHours}h ago';
|
||||
if (diff.inDays < 7) return '${diff.inDays}d ago';
|
||||
return '${updatedAt.day}/${updatedAt.month}/${updatedAt.year}';
|
||||
}
|
||||
}
|
||||
85
apps/captain-mobile-v2/flutter/lib/models/message.dart
Normal file
85
apps/captain-mobile-v2/flutter/lib/models/message.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
class ToolUse {
|
||||
final String tool;
|
||||
final dynamic input;
|
||||
final String? output;
|
||||
|
||||
ToolUse({
|
||||
required this.tool,
|
||||
this.input,
|
||||
this.output,
|
||||
});
|
||||
|
||||
factory ToolUse.fromJson(Map<String, dynamic> json) {
|
||||
return ToolUse(
|
||||
tool: json['tool'] ?? 'unknown',
|
||||
input: json['input'],
|
||||
output: json['output'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'tool': tool,
|
||||
'input': input,
|
||||
'output': output,
|
||||
};
|
||||
}
|
||||
|
||||
class Message {
|
||||
final String id;
|
||||
final String role;
|
||||
final String content;
|
||||
final List<ToolUse>? toolUses;
|
||||
final bool isStreaming;
|
||||
final bool isThinking;
|
||||
final DateTime createdAt;
|
||||
|
||||
Message({
|
||||
String? id,
|
||||
required this.role,
|
||||
required this.content,
|
||||
this.toolUses,
|
||||
this.isStreaming = false,
|
||||
this.isThinking = false,
|
||||
DateTime? createdAt,
|
||||
}) : id = id ?? DateTime.now().millisecondsSinceEpoch.toString(),
|
||||
createdAt = createdAt ?? DateTime.now();
|
||||
|
||||
Message copyWith({
|
||||
String? id,
|
||||
String? role,
|
||||
String? content,
|
||||
List<ToolUse>? toolUses,
|
||||
bool? isStreaming,
|
||||
bool? isThinking,
|
||||
DateTime? createdAt,
|
||||
}) {
|
||||
return Message(
|
||||
id: id ?? this.id,
|
||||
role: role ?? this.role,
|
||||
content: content ?? this.content,
|
||||
toolUses: toolUses ?? this.toolUses,
|
||||
isStreaming: isStreaming ?? this.isStreaming,
|
||||
isThinking: isThinking ?? this.isThinking,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
);
|
||||
}
|
||||
|
||||
factory Message.fromJson(Map<String, dynamic> json) {
|
||||
return Message(
|
||||
id: json['id'],
|
||||
role: json['role'],
|
||||
content: json['content'],
|
||||
toolUses: json['tool_uses'] != null
|
||||
? (json['tool_uses'] as List)
|
||||
.map((e) => ToolUse.fromJson(e))
|
||||
.toList()
|
||||
: null,
|
||||
createdAt: json['created_at'] != null
|
||||
? DateTime.parse(json['created_at'])
|
||||
: DateTime.now(),
|
||||
);
|
||||
}
|
||||
|
||||
bool get isUser => role == 'user';
|
||||
bool get isAssistant => role == 'assistant';
|
||||
}
|
||||
Reference in New Issue
Block a user