Created
October 6, 2023 20:13
-
-
Save mhlgio/0e8240ce0e45d3ee3dffc5f514a45c1c to your computer and use it in GitHub Desktop.
Revisions
-
mhlgio created this gist
Oct 6, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ import ora from "ora"; import { Gradient } from "@gradientai/nodejs-sdk"; const spinner = ora("").start(); async function run() { spinner.start("Creating a new Gradient client"); const gradient = new Gradient({}); spinner.stopAndPersist({ text: "Gradient client created successfully", symbol: "✅", }); spinner.start("Obtaining a list of models"); const models = await gradient.listModels({ onlyBase: false }); spinner.stopAndPersist({ symbol: "✅", text: "Models obtained successfully", }); for (const model of models) { const name = model.baseModelId === undefined ? model.slug : model.name; console.log(name); } } run() .catch(console.error) .finally(() => { spinner.stop(); }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ { "name": "hello-gradient-on-esm", "version": "1.0.0", "description": "Testing ESM modules for GradientAI SDK", "exports": "./index.js", "scripts": { "test": "node ./index.js", }, "type": "module", "author": "Mateusz Haligowski <[email protected]>", "license": "ISC", "dependencies": { "@gradientai/nodejs-sdk": "^1.1.1", "ora": "^7.0.1" }, "engines": { "node": ">=16" } }