Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The official Java library for the Modzy Machine Learning Operations (MLOps) Platform

License

NotificationsYou must be signed in to change notification settings

modzy/sdk-java

Modzy Logo

Modzy's Java SDK queries models, submits inference jobs, and returns results directly to your editor.

GitHub contributorsGitHub last commitGitHub Release Date

The job lifecycle |API Keys |Samples |Documentation

Installation

installation

Clone the repository:

  • $ git clone https://github.com/modzy/sdk-java.git

Usemaven to install the SDK.

  • $ ./mvnw install -DskipTests=true

Add the dependency in yourpom.xml file:

<dependency><groupId>com.modzy</groupId><artifactId>modzy-sdk</artifactId><version>0.0.1</version></dependency>

Get your API key

API keys are security credentials required to perform API requests to Modzy. Our API keys are composed of an ID that is split by a dot into two parts: a public and private part.

Thepublic part is the API keys' visible part only used to identify the key and by itself, it’s unable to perform API requests.

Theprivate part is the public part's complement and it’s required to perform API requests. Since it’s not stored on Modzy’s servers, it cannot be recovered. Make sure to save it securely. If lost, you canreplace the API key.

Find your API key in your user profile. To get your full API key click on "Get key":

get key

Initialize

Once you have amodel andversion identified, get authenticated with your API key.

ModzyClientmodzyClient =newModzyClient("http://url.to.modzy/api","API Key");

Basic usage

Basic Usage

Browse models

Modzy’s Marketplace includes pre-trained and re-trainable AI models from industry-leading machine learning companies, accelerating the process from data to value.

The Model service drives the Marketplace and can be integrated with other applications, scripts, and systems. It provides routes to list, search, and filter model and model-version details.

List models:

List<Model>models =modzyClient.getAllModels();for(Modelmodel :models ){System.out.println("Model: "+model);}

Tags help categorize and filter models. They make model browsing easier.

List tags:

List<Tag>tags =modzyClient.getTagClient().getAllTags();for(Tagtag :tags ){System.out.println("Tag: "+tag);}

List models by tag:

TagWrappertagsModels =modzyClient.getTagsAndModels("language_and_text");for(Modelmodel :tagsModels.getModels() ){System.out.println("Model: "+model);}

Get a model's details

Models accept specificinput fileMIME types. Some models may require multiple input file types to run data accordingly. In this sample, we use a model that requirestext/plain.

Models require inputs to have a specificinput name declared in the job request. This name can be found in the model’s details. In this sample, we use a model that requiresinput.txt.

Additionally, users can set their own input names. When multiple input items are processed in a job, these names are helpful to identify and get each input’s results. In this sample, we use a model that requiresinput-1 andinput-2.

Get a model's details:

ModelsaModel =modzyClient.getModel("ed542963de");System.out.println("Model: "+saModel);

Model specific sample requests are available in the version details and in the Model Details page.

Get version details:

ModelVersionmodelVersion =modzyClient.getModelVersion("ed542963de","0.0.27");// then you'll get all the details about the specific model versionSystem.out.println(String.format("ModelVersion details properties: %s",getNotNullProperties(modelVersion)));// Probably the more interesting are the ones related with the inputs and outputs of the modelSystem.out.println("  inputs:");for(ModelInputinput :modelVersion.getInputs() ){System.out.println(String.format("    key %s, type %s, description: %s",input.getName(),input.getAcceptedMediaTypes(),input.getDescription())    );}System.out.println("  outputs:");for(ModelOutputoutput :modelVersion.getOutputs() ){System.out.println(String.format("    key %s, type %s, description: %s",output.getName(),output.getMediaType(),output.getDescription())    );}

Submit a job and get results

Ajob is the process that sends data to a model, sets the model to run the data, and returns results.

Modzy supports severalinput types such astext,embedded for Base64 strings,aws-s3 andaws-s3-folder for inputs hosted in buckets, andjdbc for inputs stored in databases. In this sample, we usetext.

Here are samples to submit jobs withembedded,aws-s3,aws-s3-folder, andjdbc input types.

Submit a job with the model, version, and input items:

Jobjob =modzyClient.submitJobText("ed542963de","0.0.27","Modzy is great!");

Hold until the inference is complete and results become available:

Jobjob =modzyClient.blockUntilComplete(job,20000);

Get the results:

Results are available per input item and can be identified with the name provided for each input item upon job request. You can also add an input name to the route and limit the results to any given input item.

Jobs requested for multiple input items may have partial results available prior to job completion.

JobOutput<JsonNode>jobResult =modzyClient.getResult(job);Map<String,Map<String,JsonNode>>results =jobResult.getResults();

Fetch errors

Errors may arise for different reasons. Fetch errors to know what is their cause and how to fix them.

ErrorDescription
ApiExceptionWrapper for different exceptions, check the message and the stacktrace.

Submitting jobs:

try{Map<String,JsonNode>retValue=this.modzyClient.submitJobTextBlockUntilComplete("ed542963de","Modzy is great!");}catch(ApiExceptionae){System.out.println("The job submission fails with message "+ae.getMessage());as.printStackTrace();}

Features

Modzy supportsbatch processing,explainability, andmodel drift detection.

APIs

Here is a list of Modzy APIs. To see all the APIs, check ourDocumentation.

FeatureCodeApi route
Get all modelsmodzyClient.getAllModels()api/models
List modelsmodzyClient.getModels()api/models
Get model detailsmodzyClient.getModel()api/models/:model-id
List models by namemodzyClient.getModelByName()api/models
List models by tagsmodzyClient.getTagsAndModels()api/models/tags/:tag-id
Get related modelsmodzyClient.getRelatedModels()api/models/:model-id/related-models
Get a model's versionsmodzyClient.getModelVersions()api/models/:model-id/versions
Get version detailsmodzyClient.getModelVersions()api/models/:model-id/versions/:version-id
List tagsmodzyClient.getAllTags()api/models/tags
Submit a Job (Text)modzyClient.submitJobText()api/jobs
Submit a Job (Embedded)modzyClient.submitJobEmbedded()api/jobs
Submit a Job (AWS S3)modzyClient.submitJobAWSS3()api/jobs
Submit a Job (JDBC)modzyClient.submitJobJDBC()api/jobs
Cancel a jobmodzyClient.cancelJob()api/jobs/:job-id
Hold until inference is completemodzyClient.blockUntilComplete()api/jobs/:job-id
Get job detailsmodzyClient.getJob()api/jobs/:job-id
Get resultsmodzyClient.getResults()api/results/:job-id
List the job historymodzyClient.getJobHistory()api/jobs/history

Samples

Check out oursamples for details on specific use cases.

To run samples:

Set the base url and api key in each sample file:

// TODO: set the base url of modzy api and you api keyModzyClientmodzyClient=newModzyClient("https://http://modzy.url","modzy-api.key");

Or follow the instructionshere to learn more.

And then, you can:

$ ./mvnw exec:java -Dexec.mainClass="com.modzy.sdk.samples.ModelSamples"

Contributing

We are happy to receive contributions from all of our users. Check out ourcontributing file to learn more.

Code of conduct

Contributor Covenant

Releases

No releases published

Packages

No packages published

Contributors5

Languages


[8]ページ先頭

©2009-2025 Movatter.jp