client.Models().ListModels()
Retrieve models
client.Models().ListModels(ctx context.Context, input *ListModelsInput) (*ListModelsOutput, error)
Returns a list of models. The list includes each model’s model_id
, versions
, and latest_version
.
Filtering, Paging, and Sorting
These helper functions can be used to filter down the results returned by client.Models().ListModels()
Filtering
Paging
Sorting
Filter | Type | Description | Example |
---|---|---|---|
modzy.ListModelsFilterFieldModelID | str | Filters models by identifier. Separate multiple values with ; . | 'ed542963de' |
modzy.ListModelsFilterFieldAuthor | str | Filters models by the organization that created them. Separate multiple values with ; . | 'Open Source' |
modzy.ListModelsFilterFieldCreatedByEmail | str | Filters models by creator’s email. Separate multiple values with ; . | '[email protected]' |
modzy.ListModelsFilterFieldName | str | Filters models by name. Separate multiple values with ; . | 'Sentiment Analysis' |
modzy.ListModelsFilterFieldDescription | str | Filters models by description. | 'Sentiment Analysis' |
modzy.ListModelsFilterFieldIsActive | boolean | Filters models by status. | True |
modzy.ListModelsFilterFieldIsRecommended | boolean | Filters models recommended by Modzy. | False |
modzy.ListModelsFilterFieldLastActiveDateTime | datetime str | Filters models by the latest use date. It requires ISO8601 formated string (YYYY-MM-DDThh:mm:ss.sTZD ) or a datetime object (https://docs.python.org/3/library/datetime.html). | datetime.now() '2021-08-13T07:28:03.831' |
modzy.ListModelsFilterFieldIsExpired | datetime str | Filters models by the expiration date. It requires ISO8601 formated string (YYYY-MM-DDThh:mm:ss.sTZD ) or a datetime object (https://docs.python.org/3/library/datetime.html). | datetime.now() '2021-08-13T07:28:03.831' |
sort_by | str | Models can be sorted by modelId , author , submittedByEmail , name , isExpired , isActive , latestVersion , isRecommended , lastActiveDateTime , expirationDateTime . | 'name' |
direction | str | Orders the records in ascending (ASC ) or descending (DESC ) order. It defaults to ASC . | 'DESC' |
page | int | The page number to be returned. Defaults to 0. | 1 |
per_page | int | The number of records returned per page. Defaults to 10. | 15 |
Returns
A JSON object with a list of any models the meet the criteria specified by the parameters supplied.
[
{
"model_id": "string",
"latest_version": "string",
"versions": ["string"]
}
]
Examples
Print a list of first 10 models returned by the List models API route.
package main
import (
"context"
"fmt"
"log"
modzy "github.com/modzy/sdk-go"
)
func main() {
ctx := context.TODO()
modzyURL := "https://trial.app.modzy.com"
apiKey := API_KEY
client := modzy.NewClient(modzyURL).WithAPIKey(apiKey)
listModelsInput := (&modzy.ListModelsInput{}).WithPaging(10, 1)
out, err := client.Models().ListModels(ctx, listModelsInput)
if err != nil {
log.Fatalf("Unexpected error %s", err)
return
}
for _, model := range out.Models {
fmt.Println("Model ID: ", model.ID)
}
}
Search for specific models by author
package main
import (
"context"
"log"
modzy "github.com/modzy/sdk-go"
)
func main() {
ctx := context.TODO()
modzyURL := "https://trial.app.modzy.com"
apiKey := API_KEY
client := modzy.NewClient(modzyURL).WithAPIKey(apiKey)
listModelsInput = (&modzy.ListModelsInput{}).WithPaging(1000, 0).WithFilterAnd(modzy.ListModelsFilterFieldAuthor, "Open Source")
out, err = client.Models().ListModels(ctx, listModelsInput)
if err != nil {
log.Fatalf("Unexpected error %s", err)
return
}
log.Printf("Open Source models: %d\n", len(out.Models))
}
Search for active models
package main
import (
"context"
"log"
modzy "github.com/modzy/sdk-go"
)
func main() {
ctx := context.TODO()
modzyURL := "https://trial.app.modzy.com"
apiKey := API_KEY
client := modzy.NewClient(modzyURL).WithAPIKey(apiKey)
listModelsInput = (&modzy.ListModelsInput{}).WithPaging(1000, 0).WithFilterAnd(modzy.ListModelsFilterFieldIsActive, "true")
out, err = client.Models().ListModels(ctx, listModelsInput)
if err != nil {
log.Fatalf("Unexpected error %s", err)
return
}
log.Printf("Active models: %d\n", len(out.Models))
}
Search by name (and paginate the results)
package main
import (
"context"
"log"
modzy "github.com/modzy/sdk-go"
)
func main() {
ctx := context.TODO()
modzyURL := "https://trial.app.modzy.com"
apiKey := API_KEY
client := modzy.NewClient(modzyURL).WithAPIKey(apiKey)
listModelsInput = (&modzy.ListModelsInput{}).WithPaging(5, 0).WithFilterAnd(modzy.ListModelsFilterFieldName, "Image")
out, err = client.Models().ListModels(ctx, listModelsInput)
if err != nil {
log.Fatalf("Unexpected error %s", err)
return
}
log.Printf("Models with name start with 'Image': %d\n", len(out.Models))
}
Updated about 1 year ago