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
@@ -86,31 +102,19 @@ from digitalocean_genai_sdk import DigitaloceanGenaiSDK
86
102
87
103
client = DigitaloceanGenaiSDK()
88
104
89
-
assistant_object = client.assistants.create(
90
-
model="gpt-4o",
91
-
tool_resources={},
105
+
create_response = client.chat.completions.create(
106
+
messages=[
107
+
{
108
+
"content": "string",
109
+
"role": "system",
110
+
}
111
+
],
112
+
model="llama3-8b-instruct",
113
+
stream_options={},
92
114
)
93
-
print(assistant_object.tool_resources)
115
+
print(create_response.stream_options)
94
116
```
95
117
96
-
## File uploads
97
-
98
-
Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
99
-
100
-
```python
101
-
from pathlib import Path
102
-
from digitalocean_genai_sdk import DigitaloceanGenaiSDK
103
-
104
-
client = DigitaloceanGenaiSDK()
105
-
106
-
client.audio.transcribe_audio(
107
-
file=Path("/path/to/file"),
108
-
model="gpt-4o-transcribe",
109
-
)
110
-
```
111
-
112
-
The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.
113
-
114
118
## Handling errors
115
119
116
120
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `digitalocean_genai_sdk.APIConnectionError` is raised.
@@ -127,7 +131,15 @@ from digitalocean_genai_sdk import DigitaloceanGenaiSDK
127
131
client = DigitaloceanGenaiSDK()
128
132
129
133
try:
130
-
client.assistants.list()
134
+
client.chat.completions.create(
135
+
messages=[
136
+
{
137
+
"content": "string",
138
+
"role": "system",
139
+
}
140
+
],
141
+
model="llama3-8b-instruct",
142
+
)
131
143
except digitalocean_genai_sdk.APIConnectionError as e:
132
144
print("The server could not be reached")
133
145
print(e.__cause__) # an underlying Exception, likely raised within httpx.
assistant= response.parse() # get the object that `assistants.list()` would have returned
241
-
print(assistant.first_id)
274
+
completion= response.parse() # get the object that `chat.completions.create()` would have returned
275
+
print(completion.id)
242
276
```
243
277
244
278
These methods return an [`APIResponse`](https://github.com/digitalocean/genai-python/tree/main/src/digitalocean_genai_sdk/_response.py) object.
@@ -252,7 +286,15 @@ The above interface eagerly reads the full response body when you make the reque
252
286
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
253
287
254
288
```python
255
-
with client.assistants.with_streaming_response.list() as response:
289
+
with client.chat.completions.with_streaming_response.create(
0 commit comments