Skip to content

Commit 417d44d

Browse files
authored
Merge pull request #4 from Preemo-Inc/atmiguel-minor-fixes
Upgrading gradientai to 1.0.0.dev4
2 parents f216df1 + ae7435e commit 417d44d

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,5 @@ cython_debug/
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
#.idea/
161+
162+
.tool-versions

README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@ Quick example of how to use Gradient API with Python.
77
The code relies on environment variables. They can be injected through `dotenv` by creating `.env` file in the current directory:
88

99
```
10-
GRADIENT_API_KEY=...
10+
GRADIENT_ACCESS_TOKEN=...
1111
GRADIENT_WORKSPACE_ID=...
12-
GRADIENT_API_URL=https://api-staging2.gradient.ai/api
1312
```
1413

1514
## Usage
1615

1716
1. Clone this repo
18-
2. Run `poetry shell`
19-
3. Run `python gradient_sdk_python_example/list.py`
17+
2. Run `poetry install`
18+
3. Run `poetry shell`
19+
4. Run `python gradient_sdk_python_example/list.py`
2020

2121
## Example
2222

2323
![Alt Text](example.gif)
24-

gradient_sdk_python_example/list.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
load_dotenv()
66

77
configuration = gradientai.Configuration(
8-
host=os.getenv("GRADIENT_API_URL"),
98
access_token=os.getenv("GRADIENT_ACCESS_TOKEN")
109
)
1110

12-
models_api = gradientai.ModelsApi(gradientai.ApiClient(configuration))
13-
model_list = models_api.list_models(only_base="false", x_preemo_workspace_id=os.getenv("GRADIENT_WORKSPACE_ID"))
11+
with gradientai.ApiClient(configuration) as api_client:
12+
models_api = gradientai.ModelsApi(api_client)
13+
model_list = models_api.list_models(
14+
x_gradient_workspace_id=os.getenv("GRADIENT_WORKSPACE_ID")
15+
)
1416

15-
print(model_list.models[0].actual_instance)
17+
print(model_list.models[0].actual_instance)

poetry.lock

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ readme = "README.md"
77
packages = [{include = "gradient_sdk_python_example"}]
88

99
[tool.poetry.dependencies]
10-
python = "^3.11"
11-
gradientai = "^1.0.0.dev2"
10+
python = "^3.10"
11+
gradientai = "^1.0.0.dev4"
1212
python-dotenv = "^1.0.0"
1313

14-
1514
[build-system]
1615
requires = ["poetry-core"]
1716
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)