moises 1.0.1 copy "moises: ^1.0.1" to clipboard
moises: ^1.0.1 copied to clipboard

Moises.AI API Client for dart to access developer account data

example/main.dart

import 'dart:developer';
import 'package:moises/moises.dart';

import 'moises_key.dart';

Future<void> main() async {
  /// Searching for local keys
  String key = await MoisesKey.get();
  if (key.isEmpty) return;

  /// Create a new client
  final Moises moises = Moises(key);

  /// Get Application
  await getApplication(moises);

  /// Get All Jobs
  const MoisesJobFilterModel filter = MoisesJobFilterModel(
    status: MoisesJobStatusEnum.succeeded,
  );
  await getAllJobs(moises, filter);

  /// Get Job
  const String jobId = '00000000-0000-0000-0000-000000000000';
  await getJobById(moises, jobId);

  /// Delete a Job
  await deleteJob(moises, jobId);

  /// Create a Job
  const newJob = MoisesNewJobModel(
    name: 'JOB NAME',
    workflow: 'my-workflow-id',
    params: MoisesNewJobParamsModel(
      inputUrl: 'https://your-server.com/some-audio.m4a',
    ),
  );

  await createJob(moises, newJob);
}

Future<void> getApplication(Moises moises) async {
  try {
    final MoisesApplicationModel value = await moises.application.get();
    log('Application : $value');
  } on MoisesException catch (e) {
    log('Error : ${e.error}');
  }
}

Future<void> getAllJobs(Moises moises, MoisesJobFilterModel filter) async {
  try {
    final List<MoisesJobModel> value = await moises.job.getAll(filter);
    log('Job List (${value.length}) : $value');
  } on MoisesException catch (e) {
    log('Error : ${e.error}');
  }
}

Future<void> getJobById(Moises moises, String id) async {
  try {
    final MoisesJobModel value = await moises.job.get(id);
    log('Job : $value');
  } on MoisesException catch (e) {
    log('Error : ${e.error}');
  }
}

Future<void> createJob(Moises moises, MoisesNewJobModel newJob) async {
  try {
    final MoisesNewJobResultModel value = await moises.job.create(newJob);
    log('New Job Result : $value');
  } on MoisesException catch (e) {
    log('Error : ${e.error}');
  }
}

Future<void> deleteJob(Moises moises, String id) async {
  try {
    await moises.job.delete(id);
    log('Job $id was successfully deleted');
  } on MoisesException catch (e) {
    log('Error : ${e.error}');
  }
}
2
likes
150
points
49
downloads
screenshot

Publisher

unverified uploader

Weekly Downloads

Moises.AI API Client for dart to access developer account data

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

dio, equatable, flutter, json_annotation

More

Packages that depend on moises