vertex_ai 0.0.10 copy "vertex_ai: ^0.0.10" to clipboard
vertex_ai: ^0.0.10 copied to clipboard

GCP Vertex AI ML platform API client (PaLM, Matching Engine, etc.).

example/vertex_ai_example.dart

// ignore_for_file: avoid_print
import 'dart:convert';
import 'dart:io';

import 'package:googleapis_auth/auth_io.dart';
import 'package:vertex_ai/vertex_ai.dart';

void main() async {
  final vertexAi = VertexAIGenAIClient(
    httpClient: await _getAuthHttpClient(),
    project: _getProjectId(),
  );

  final res = await vertexAi.text.predict(
    prompt: 'List the numbers from 1 to 9 in order '
        'without any spaces or commas.',
  );
  print(res);
}

Future<AuthClient> _getAuthHttpClient() async {
  final serviceAccountCredentials = ServiceAccountCredentials.fromJson(
    json.decode(Platform.environment['VERTEX_AI_SERVICE_ACCOUNT']!),
  );
  return clientViaServiceAccount(
    serviceAccountCredentials,
    [VertexAIGenAIClient.cloudPlatformScope],
  );
}

String _getProjectId() {
  return Platform.environment['VERTEX_AI_PROJECT_ID']!;
}
16
likes
0
pub points
73%
popularity

Publisher

verified publisherlangchaindart.dev

GCP Vertex AI ML platform API client (PaLM, Matching Engine, etc.).

Homepage
Repository (GitHub)
View/report issues

Topics

#ai #nlp #llms #palm #matching-engine

Documentation

Documentation

License

unknown (license)

Dependencies

collection, googleapis, googleapis_auth, http, meta

More

Packages that depend on vertex_ai