stream_chat_origin_data.dart 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}]}
  3. */
  4. import 'package:json_annotation/json_annotation.dart';
  5. part 'stream_chat_origin_data.g.dart';
  6. @JsonSerializable()
  7. class StreamChatOriginData {
  8. @JsonKey(name: "choices")
  9. final List<Choices>? choices;
  10. StreamChatOriginData({
  11. required this.choices,
  12. });
  13. factory StreamChatOriginData.fromJson(Map<String, dynamic> json) => _$StreamChatOriginDataFromJson(json);
  14. }
  15. @JsonSerializable()
  16. class Choices {
  17. @JsonKey(name: "index")
  18. final int? index;
  19. @JsonKey(name: "delta")
  20. final Delta? delta;
  21. @JsonKey(name: "finishReason")
  22. final String? finishReason;
  23. Choices({
  24. required this.index,
  25. required this.delta,
  26. required this.finishReason,
  27. });
  28. factory Choices.fromJson(Map<String, dynamic> json) => _$ChoicesFromJson(json);
  29. }
  30. @JsonSerializable()
  31. class Delta {
  32. @JsonKey(name: "role")
  33. final String? role;
  34. @JsonKey(name: "content")
  35. final String? content;
  36. Delta({
  37. required this.role,
  38. required this.content,
  39. });
  40. factory Delta.fromJson(Map<String, dynamic> json) => _$DeltaFromJson(json);
  41. }