Skip to content

Commit

Permalink
Upgrading gradientai version to 1.0.0-dev.4 (#7)
Browse files Browse the repository at this point in the history
* upgrading

* updating readme

* adding newline

* removing onlyBase arg
  • Loading branch information
atmiguel authored Aug 21, 2023
1 parent e057dba commit b6fbf06
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 77 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,5 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

.tool-versions
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# gradient-sdk-typescript-example

Quick example of how to use Gradient API with Typescript.
Quick example of how to use Gradient API with TypeScript.

## Setup

The code relies on environment variables. They can be injected through `dotenv` by creating `.env` file in the current directory:

```
GRADIENT_API_KEY=...
GRADIENT_ACCESS_TOKEN=...
GRADIENT_WORKSPACE_ID=...
GRADIENT_API_URL=https://api.gradient.ai/api
```

## Usage
Expand All @@ -21,5 +20,3 @@ GRADIENT_API_URL=https://api.gradient.ai/api
## Example

![Alt Text](example.gif)


78 changes: 12 additions & 66 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"typescript": "^5.1.6"
},
"dependencies": {
"@gradientai/nodejs-sdk": "^1.0.0-dev.2"
"@gradientai/nodejs-sdk": "^1.0.0-dev.4"
}
}
13 changes: 8 additions & 5 deletions src/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import { Configuration, ModelsApi } from "@gradientai/nodejs-sdk";

async function main() {
const configuration = new Configuration({
accessToken: process.env.GRADIENT_API_KEY,
basePath: process.env.GRADIENT_API_URL,
accessToken: process.env.GRADIENT_ACCESS_TOKEN,
});

const modelsApi = new ModelsApi(configuration);
const models = await modelsApi.listModels({
onlyBase: "false",
xPreemoWorkspaceId: process.env.GRADIENT_WORKSPACE_ID!,
xGradientWorkspaceId: process.env.GRADIENT_WORKSPACE_ID!,
});

if (models.status !== 200) {
Expand All @@ -19,4 +17,9 @@ async function main() {
console.log(models.data);
}

main().catch(console.error).then(console.log);
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(() => process.exit());

0 comments on commit b6fbf06

Please sign in to comment.