groqUsageFromJson static method

GroqUsage groqUsageFromJson(
  1. Map<String, dynamic> json
)

Parses the usage information from the json

Implementation

static GroqUsage groqUsageFromJson(Map<String, dynamic> json) {
  return GroqUsage(
    promptTokens: json['prompt_tokens'] as int? ?? 0,
    completionTokens: json['completion_tokens'] as int? ?? 0,
    // it is stored in json as 0.001 seconds e.g.
    promptTime: Duration(
        milliseconds: ((json['prompt_time'] as double? ?? 0) * 1000).toInt()),
    completionTime: Duration(
        milliseconds:
            ((json['completion_time'] as double? ?? 0) * 1000).toInt()),
  );
}