You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+52-19Lines changed: 52 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,7 @@ Remember that each namespace requires its own authentication token type as descr
49
49
*[SDK Example Usage](#sdk-example-usage)
50
50
*[Authentication](#authentication)
51
51
*[Available Resources and Operations](#available-resources-and-operations)
52
+
*[File uploads](#file-uploads)
52
53
*[Retries](#retries)
53
54
*[Error Handling](#error-handling)
54
55
*[Server Selection](#server-selection)
@@ -135,7 +136,7 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u
135
136
136
137
```python
137
138
# Synchronous Example
138
-
from glean.api_clientimport Glean, models
139
+
from glean import Glean, models
139
140
import os
140
141
141
142
@@ -163,7 +164,7 @@ The same SDK client can also be used to make asychronous requests by importing a
163
164
```python
164
165
# Asynchronous Example
165
166
import asyncio
166
-
from glean.api_clientimport Glean, models
167
+
from glean import Glean, models
167
168
import os
168
169
169
170
asyncdefmain():
@@ -192,7 +193,7 @@ asyncio.run(main())
192
193
193
194
```python
194
195
# Synchronous Example
195
-
from glean.api_clientimport Glean, models
196
+
from glean import Glean, models
196
197
import os
197
198
198
199
@@ -220,7 +221,7 @@ The same SDK client can also be used to make asychronous requests by importing a
220
221
```python
221
222
# Asynchronous Example
222
223
import asyncio
223
-
from glean.api_clientimport Glean, models
224
+
from glean import Glean, models
224
225
import os
225
226
226
227
asyncdefmain():
@@ -259,8 +260,8 @@ This SDK supports the following security scheme globally:
259
260
260
261
To authenticate with the API the `api_token` parameter must be set when initializing the SDK client instance. For example:
261
262
```python
262
-
from glean.api_clientimport Glean, models
263
-
from glean.api_client.utils import parse_datetime
263
+
from glean import Glean, models
264
+
from glean.utils import parse_datetime
264
265
import os
265
266
266
267
@@ -534,15 +535,47 @@ For more information on obtaining the appropriate token type, please contact you
534
535
</details>
535
536
<!-- End Available Resources and Operations [operations] -->
536
537
538
+
<!-- Start File uploads [file-upload] -->
539
+
## File uploads
540
+
541
+
Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
542
+
543
+
> [!TIP]
544
+
>
545
+
> For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.
546
+
>
547
+
548
+
```python
549
+
from glean import Glean
550
+
import os
551
+
552
+
553
+
with Glean(
554
+
api_token=os.getenv("GLEAN_API_TOKEN", ""),
555
+
) as g_client:
556
+
557
+
res = g_client.client.chat.upload_files(files=[
558
+
{
559
+
"file_name": "example.file",
560
+
"content": open("example.file", "rb"),
561
+
},
562
+
])
563
+
564
+
# Handle response
565
+
print(res)
566
+
567
+
```
568
+
<!-- End File uploads [file-upload] -->
569
+
537
570
<!-- Start Retries [retries] -->
538
571
## Retries
539
572
540
573
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
541
574
542
575
To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
543
576
```python
544
-
from glean.api_clientimport Glean, models
545
-
from glean.api_client.utils import BackoffStrategy, RetryConfig, parse_datetime
577
+
from glean import Glean, models
578
+
from glean.utils import BackoffStrategy, RetryConfig, parse_datetime
546
579
import os
547
580
548
581
@@ -582,8 +615,8 @@ with Glean(
582
615
583
616
If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
584
617
```python
585
-
from glean.api_clientimport Glean, models
586
-
from glean.api_client.utils import BackoffStrategy, RetryConfig, parse_datetime
618
+
from glean import Glean, models
619
+
from glean.utils import BackoffStrategy, RetryConfig, parse_datetime
587
620
import os
588
621
589
622
@@ -720,8 +753,8 @@ The default server `https://{instance}-be.glean.com` contains variables and is s
720
753
#### Example
721
754
722
755
```python
723
-
from glean.api_clientimport Glean, models
724
-
from glean.api_client.utils import parse_datetime
756
+
from glean import Glean, models
757
+
from glean.utils import parse_datetime
725
758
import os
726
759
727
760
@@ -763,8 +796,8 @@ with Glean(
763
796
764
797
The default server can be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
765
798
```python
766
-
from glean.api_clientimport Glean, models
767
-
from glean.api_client.utils import parse_datetime
799
+
from glean import Glean, models
800
+
from glean.utils import parse_datetime
768
801
import os
769
802
770
803
@@ -812,7 +845,7 @@ This allows you to wrap the client with your own custom logic, such as adding cu
812
845
813
846
For example, you could specify a header for every request that this sdk makes as follows:
Copy file name to clipboardExpand all lines: docs/models/agentrun.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,4 +10,5 @@ Payload for creating a run.
10
10
|`agent_id`|*str*|:heavy_check_mark:| The ID of the agent to run. |
11
11
|`input`| Dict[str, *Any*]|:heavy_minus_sign:| The input to the agent. |
12
12
|`messages`| List[[models.Message](../models/message.md)]|:heavy_minus_sign:| The messages to pass an input to the agent. |
13
+
|`metadata`| Dict[str, *Any*]|:heavy_minus_sign:| The metadata to pass to the agent. |
13
14
|`status`|[Optional[models.AgentExecutionStatus]](../models/agentexecutionstatus.md)|:heavy_minus_sign:| The status of the run. One of 'error', 'success'. |
0 commit comments