groqToolItemFromChatJson static method

GroqToolItem groqToolItemFromChatJson(
  1. Map<String, dynamic> json,
  2. dynamic Function(Map<String, dynamic>) functionNameToFunction(
    1. String
    )
)

Implementation

static GroqToolItem groqToolItemFromChatJson(Map<String, dynamic> json,
    Function(Map<String, dynamic>) Function(String) functionNameToFunction) {
  return GroqToolItem(
    function: functionNameToFunction(json['functionName'] as String),
    functionName: json['functionName'] as String,
    functionDescription: json['functionDescription'] as String,
    parameters: (json['parameters'] as List)
        .map((item) => GroqToolParameter(
              parameterName: item['name'] as String,
              parameterDescription: item['description'] as String,
              parameterType:
                  groqToolParameterTypeFromString(item['type'] as String),
              isRequired: item['isRequired'] as bool,
              allowedValues: item['allowedValues'] as List<String>,
            ))
        .toList(),
  );
}