stream_chat_origin_data.dart 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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) =>
  14. _$StreamChatOriginDataFromJson(json);
  15. }
  16. @JsonSerializable()
  17. class Choices {
  18. @JsonKey(name: "index")
  19. final int? index;
  20. @JsonKey(name: "delta")
  21. final Delta? delta;
  22. @JsonKey(name: "finishReason")
  23. final String? finishReason;
  24. Choices({
  25. required this.index,
  26. required this.delta,
  27. required this.finishReason,
  28. });
  29. factory Choices.fromJson(Map<String, dynamic> json) =>
  30. _$ChoicesFromJson(json);
  31. }
  32. @JsonSerializable()
  33. class Delta {
  34. @JsonKey(name: "role")
  35. final String? role;
  36. @JsonKey(name: "content")
  37. final String? content;
  38. Delta({
  39. required this.role,
  40. required this.content,
  41. });
  42. factory Delta.fromJson(Map<String, dynamic> json) => _$DeltaFromJson(json);
  43. }