embedContent method

Future<EmbedContentResponse> embedContent(
  1. Content content, {
  2. TaskType? taskType,
  3. String? title,
  4. int? outputDimensionality,
})

Creates an embedding (list of float values) representing content.

Sends a "embedContent" API request for the configured model, and waits for the response.

Example:

final promptEmbedding =
    (await model.embedContent([Content.text(prompt)])).embedding.values;

Implementation

Future<EmbedContentResponse> embedContent(
  Content content, {
  TaskType? taskType,
  String? title,
  int? outputDimensionality,
}) =>
    makeRequest(
        Task.embedContent,
        {
          'content': content.toJson(),
          if (taskType != null) 'taskType': taskType.toJson(),
          if (title != null) 'title': title,
          if (outputDimensionality != null)
            'outputDimensionality': outputDimensionality,
        },
        parseEmbedContentResponse);