Change PIN to 1451
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
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