all-the-public-replicate-models 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "all-the-public-replicate-models",
3
+ "description": "An offline database of metadata for all the public models on Replicate",
4
+ "version": "1.0.0",
5
+ "devDependencies": {
6
+ "chai": "^4.3.10",
7
+ "lodash-es": "^4.17.21",
8
+ "mocha": "^10.2.0",
9
+ "replicate": "github:replicate/replicate-javascript#add-method-for-listing-public-models"
10
+ },
11
+ "type": "module",
12
+ "main": "index.mjs",
13
+ "scripts": {
14
+ "build": "node script/build.js > models.json",
15
+ "test": "mocha test.js"
16
+ }
17
+ }
@@ -0,0 +1,24 @@
1
+ import Replicate from "replicate";
2
+ const replicate = new Replicate();
3
+ import {unset} from "lodash-es";
4
+
5
+ async function main () {
6
+ console.error("Fetching all public models from Replicate...")
7
+ const models = []
8
+ for await (const batch of replicate.paginate(replicate.models.list)) {
9
+ process.stderr.write('.')
10
+ models.push(...batch);
11
+ }
12
+
13
+ // remove some noisy fields that are not needed
14
+ for (let i = 0; i < models.length; i++) {
15
+ unset(models[i], 'default_example.logs')
16
+ unset(models[i], 'default_example.urls')
17
+ unset(models[i], 'default_example.webhook_completed')
18
+ unset(models[i], 'latest_version.openapi_schema.paths')
19
+ }
20
+
21
+ process.stdout.write(JSON.stringify(models, null, 2))
22
+ }
23
+
24
+ main()
package/test.js ADDED
@@ -0,0 +1,22 @@
1
+ import { expect } from 'chai';
2
+ import models from './index.mjs';
3
+
4
+ describe('models module', () => {
5
+ it('should be an array', () => {
6
+ expect(models).to.be.an('array');
7
+ });
8
+
9
+ it('should have at least 500 objects', () => {
10
+ expect(models).to.have.lengthOf.at.least(500);
11
+ });
12
+
13
+ describe('first object in the array', () => {
14
+ it('should have an owner property', () => {
15
+ expect(models[0]).to.have.property('owner');
16
+ });
17
+
18
+ it('should have a name property', () => {
19
+ expect(models[0]).to.have.property('name');
20
+ });
21
+ });
22
+ });