Skip to content

Commit b93c289

Browse files
authored
chore: usage (#22)
* feat: updated sdk from openapi * feat: add code samples and update chat model usage in SDK - Added a new codeSamples.yaml file to provide examples for using the SDK. - Updated chat completion methods to utilize the "meta-llama/Llama-3.3-70B-Instruct" model for improved performance. - Enhanced the create and create_stream methods for both regular and confidential chat functionalities with new message structures. - Refactored embedding and image generation methods to include specific model parameters and improved response handling. * feat: new chat completions test * chore: finalized test_chat_completions * chore: finalized confidential chat usages
1 parent 1ac9102 commit b93c289

31 files changed

Lines changed: 479 additions & 517 deletions

.genignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
src/atoma_sdk/confidential_chat.py
33
src/atoma_sdk/confidential_embeddings.py
44
src/atoma_sdk/confidential_images.py
5+
6+
# code samples
7+
codeSamples.yaml

.speakeasy/gen.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
lockVersion: 2.0.0
22
id: abb58176-a92d-43ea-b418-227f4288eed7
33
management:
4-
docChecksum: 57e7f8f620f9d7870ff67fb9340421aa
4+
docChecksum: 3c9aba47fd12560f82f7cbdf82bbf7d1
55
docVersion: 0.1.0
66
speakeasyVersion: 1.463.1
77
generationVersion: 2.486.6
@@ -199,24 +199,24 @@ examples:
199199
chat_completions_create:
200200
speakeasy-default-chat-completions-create:
201201
requestBody:
202-
application/json: {"messages": [{"content": "<value>", "role": "<value>"}], "model": "LeBaron"}
202+
application/json: {"messages": [{"content": "Hello! How can you help me today?", "role": "user"}], "model": "meta-llama/Llama-3.3-70B-Instruct"}
203203
responses:
204204
"200":
205-
application/json: {"choices": [{"index": 134365, "message": {"content": "<value>", "role": "<value>"}}], "created": 69025, "id": "<id>", "model": "PT Cruiser"}
205+
application/json: {"choices": [{"index": 0, "message": {"content": "Hello! How can you help me today?", "role": "user"}}], "created": 1677652288, "id": "chatcmpl-123", "model": "meta-llama/Llama-3.3-70B-Instruct"}
206206
embeddings_create:
207207
speakeasy-default-embeddings-create:
208208
requestBody:
209-
application/json: {"input": "<value>", "model": "LeBaron"}
209+
application/json: {"input": "The quick brown fox jumped over the lazy dog", "model": "intfloat/multilingual-e5-large-instruct"}
210210
responses:
211211
"200":
212-
application/json: {"data": [{"embedding": [], "index": 69025, "object": "<value>"}], "model": "PT Cruiser", "object": "<value>", "usage": {"prompt_tokens": 951062, "total_tokens": 86}}
212+
application/json: {"data": [{"embedding": ["[0.0023064255, -0.009327292]"], "index": 0, "object": "embedding"}], "model": "intfloat/multilingual-e5-large-instruct", "object": "list", "usage": {"prompt_tokens": 8, "total_tokens": 8}}
213213
image_generations_create:
214214
speakeasy-default-image-generations-create:
215215
requestBody:
216-
application/json: {"model": "Model X", "n": 447445, "prompt": "<value>"}
216+
application/json: {"model": "black-forest-labs/FLUX.1-schnell", "n": 1, "prompt": "A cute baby sea otter floating on its back"}
217217
responses:
218218
"200":
219-
application/json: {"created": 331048, "data": [{"revised_prompt": "<value>", "url": "https://enlightened-coliseum.com"}]}
219+
application/json: {"created": 1677649420, "data": [{"revised_prompt": "A stunning image of a baby sea otter floating on its back in crystal clear blue water, with gentle ripples surrounding it. The otter's fur appears soft and well-detailed, and its expression is peaceful and content.", "url": "https://oaidalleapiprodscus.blob.core.windows.net/private/image.png"}]}
220220
confidential_chat_completions_create:
221221
speakeasy-default-confidential-chat-completions-create:
222222
requestBody:
@@ -241,7 +241,7 @@ examples:
241241
chat_completions_create_stream:
242242
speakeasy-default-chat-completions-create-stream:
243243
requestBody:
244-
application/json: {"messages": [], "model": "Impala"}
244+
application/json: {"messages": [], "model": "meta-llama/Llama-3.3-70B-Instruct"}
245245
select_node_public_key:
246246
speakeasy-default-select-node-public-key:
247247
requestBody:

README-PYPI.md

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Atoma's Python SDK
22

3-
Developer-friendly & type-safe Python SDK specifically catered to leverage _atoma-sdk_ API.
4-
53
<img src="https://github.com/atoma-network/atoma-node/blob/main/atoma-assets/atoma-banner.png" alt="Logo"/>
64

75
[![Discord](https://img.shields.io/discord/1172593757586214964?label=Discord&logo=discord&logoColor=white)]
@@ -11,13 +9,8 @@ Developer-friendly & type-safe Python SDK specifically catered to leverage _atom
119

1210
<div align="left">
1311
<a href="https://www.speakeasy.com/?utm_source=atoma-sdk&utm_campaign=python"><img src="https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge&logoColor=FBE331&logo=speakeasy&labelColor=545454" /></a>
14-
<a href="https://opensource.org/licenses/MIT">
15-
<img src="https://img.shields.io/badge/License-MIT-blue.svg" style="width: 100px; height: 28px;" />
16-
</a>
1712
</div>
1813

19-
<br /><br />
20-
2114
<!-- Start Summary [summary] -->
2215
## Summary
2316

@@ -27,7 +20,7 @@ Developer-friendly & type-safe Python SDK specifically catered to leverage _atom
2720
<!-- Start Table of Contents [toc] -->
2821
## Table of Contents
2922
<!-- $toc-max-depth=2 -->
30-
* [atoma-sdk](https://github.com/atoma-network/atoma-sdk-python/blob/master/#atoma-sdk)
23+
* [Atoma's Python SDK](https://github.com/atoma-network/atoma-sdk-python/blob/master/#atomas-python-sdk)
3124
* [SDK Installation](https://github.com/atoma-network/atoma-sdk-python/blob/master/#sdk-installation)
3225
* [IDE Support](https://github.com/atoma-network/atoma-sdk-python/blob/master/#ide-support)
3326
* [SDK Example Usage](https://github.com/atoma-network/atoma-sdk-python/blob/master/#sdk-example-usage)
@@ -48,6 +41,10 @@ Developer-friendly & type-safe Python SDK specifically catered to leverage _atom
4841
<!-- Start SDK Installation [installation] -->
4942
## SDK Installation
5043

44+
> [!TIP]
45+
> To finish publishing your SDK to PyPI you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide).
46+
47+
5148
The SDK can be installed with either *pip* or *poetry* package managers.
5249

5350
### PIP
@@ -93,10 +90,12 @@ with AtomaSDK(
9390

9491
res = atoma_sdk.chat.create(messages=[
9592
{
96-
"content": "<value>",
97-
"role": "<value>",
93+
"content": "Hello! How can you help me today?",
94+
"role": "user",
9895
},
99-
], model="LeBaron")
96+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
97+
"json([\"stop\", \"halt\"])",
98+
], temperature=0.7, top_p=1, user="user-1234")
10099

101100
# Handle response
102101
print(res)
@@ -118,10 +117,12 @@ async def main():
118117

119118
res = await atoma_sdk.chat.create_async(messages=[
120119
{
121-
"content": "<value>",
122-
"role": "<value>",
120+
"content": "Hello! How can you help me today?",
121+
"role": "user",
123122
},
124-
], model="LeBaron")
123+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
124+
"json([\"stop\", \"halt\"])",
125+
], temperature=0.7, top_p=1, user="user-1234")
125126

126127
# Handle response
127128
print(res)
@@ -152,10 +153,12 @@ with AtomaSDK(
152153

153154
res = atoma_sdk.chat.create(messages=[
154155
{
155-
"content": "<value>",
156-
"role": "<value>",
156+
"content": "Hello! How can you help me today?",
157+
"role": "user",
157158
},
158-
], model="LeBaron")
159+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
160+
"json([\"stop\", \"halt\"])",
161+
], temperature=0.7, top_p=1, user="user-1234")
159162

160163
# Handle response
161164
print(res)
@@ -234,10 +237,13 @@ with AtomaSDK(
234237

235238
res = atoma_sdk.chat.create_stream(messages=[
236239
{
237-
"content": "<value>",
238-
"role": "<value>",
240+
"content": "Hello! How can you help me today?",
241+
"role": "user",
242+
"name": "john_doe",
239243
},
240-
], model="Impala")
244+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
245+
"json([\"stop\", \"halt\"])",
246+
], temperature=0.7, top_p=1, user="user-1234")
241247

242248
with res as event_stream:
243249
for event in event_stream:
@@ -268,10 +274,12 @@ with AtomaSDK(
268274

269275
res = atoma_sdk.chat.create(messages=[
270276
{
271-
"content": "<value>",
272-
"role": "<value>",
277+
"content": "Hello! How can you help me today?",
278+
"role": "user",
273279
},
274-
], model="LeBaron",
280+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
281+
"json([\"stop\", \"halt\"])",
282+
], temperature=0.7, top_p=1, user="user-1234",
275283
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
276284

277285
# Handle response
@@ -292,10 +300,12 @@ with AtomaSDK(
292300

293301
res = atoma_sdk.chat.create(messages=[
294302
{
295-
"content": "<value>",
296-
"role": "<value>",
303+
"content": "Hello! How can you help me today?",
304+
"role": "user",
297305
},
298-
], model="LeBaron")
306+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
307+
"json([\"stop\", \"halt\"])",
308+
], temperature=0.7, top_p=1, user="user-1234")
299309

300310
# Handle response
301311
print(res)
@@ -337,10 +347,12 @@ with AtomaSDK(
337347

338348
res = atoma_sdk.chat.create(messages=[
339349
{
340-
"content": "<value>",
341-
"role": "<value>",
350+
"content": "Hello! How can you help me today?",
351+
"role": "user",
342352
},
343-
], model="LeBaron")
353+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
354+
"json([\"stop\", \"halt\"])",
355+
], temperature=0.7, top_p=1, user="user-1234")
344356

345357
# Handle response
346358
print(res)
@@ -368,10 +380,12 @@ with AtomaSDK(
368380

369381
res = atoma_sdk.chat.create(messages=[
370382
{
371-
"content": "<value>",
372-
"role": "<value>",
383+
"content": "Hello! How can you help me today?",
384+
"role": "user",
373385
},
374-
], model="LeBaron")
386+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
387+
"json([\"stop\", \"halt\"])",
388+
], temperature=0.7, top_p=1, user="user-1234")
375389

376390
# Handle response
377391
print(res)

README.md

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
<!-- Start Summary [summary] -->
1515
## Summary
1616

17-
Developer-friendly & type-safe Python SDK specifically catered to leverage _atoma-sdk_ API.
1817

1918
<!-- End Summary [summary] -->
2019

2120
<!-- Start Table of Contents [toc] -->
2221
## Table of Contents
2322
<!-- $toc-max-depth=2 -->
24-
* [atoma-sdk](#atoma-sdk)
23+
* [Atoma's Python SDK](#atomas-python-sdk)
2524
* [SDK Installation](#sdk-installation)
2625
* [IDE Support](#ide-support)
2726
* [SDK Example Usage](#sdk-example-usage)
@@ -42,6 +41,10 @@ Developer-friendly & type-safe Python SDK specifically catered to leverage _atom
4241
<!-- Start SDK Installation [installation] -->
4342
## SDK Installation
4443

44+
> [!TIP]
45+
> To finish publishing your SDK to PyPI you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide).
46+
47+
4548
The SDK can be installed with either *pip* or *poetry* package managers.
4649

4750
### PIP
@@ -87,10 +90,12 @@ with AtomaSDK(
8790

8891
res = atoma_sdk.chat.create(messages=[
8992
{
90-
"content": "<value>",
91-
"role": "<value>",
93+
"content": "Hello! How can you help me today?",
94+
"role": "user",
9295
},
93-
], model="LeBaron")
96+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
97+
"json([\"stop\", \"halt\"])",
98+
], temperature=0.7, top_p=1, user="user-1234")
9499

95100
# Handle response
96101
print(res)
@@ -112,10 +117,12 @@ async def main():
112117

113118
res = await atoma_sdk.chat.create_async(messages=[
114119
{
115-
"content": "<value>",
116-
"role": "<value>",
120+
"content": "Hello! How can you help me today?",
121+
"role": "user",
117122
},
118-
], model="LeBaron")
123+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
124+
"json([\"stop\", \"halt\"])",
125+
], temperature=0.7, top_p=1, user="user-1234")
119126

120127
# Handle response
121128
print(res)
@@ -146,10 +153,12 @@ with AtomaSDK(
146153

147154
res = atoma_sdk.chat.create(messages=[
148155
{
149-
"content": "<value>",
150-
"role": "<value>",
156+
"content": "Hello! How can you help me today?",
157+
"role": "user",
151158
},
152-
], model="LeBaron")
159+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
160+
"json([\"stop\", \"halt\"])",
161+
], temperature=0.7, top_p=1, user="user-1234")
153162

154163
# Handle response
155164
print(res)
@@ -228,10 +237,13 @@ with AtomaSDK(
228237

229238
res = atoma_sdk.chat.create_stream(messages=[
230239
{
231-
"content": "<value>",
232-
"role": "<value>",
240+
"content": "Hello! How can you help me today?",
241+
"role": "user",
242+
"name": "john_doe",
233243
},
234-
], model="Impala")
244+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
245+
"json([\"stop\", \"halt\"])",
246+
], temperature=0.7, top_p=1, user="user-1234")
235247

236248
with res as event_stream:
237249
for event in event_stream:
@@ -262,10 +274,12 @@ with AtomaSDK(
262274

263275
res = atoma_sdk.chat.create(messages=[
264276
{
265-
"content": "<value>",
266-
"role": "<value>",
277+
"content": "Hello! How can you help me today?",
278+
"role": "user",
267279
},
268-
], model="LeBaron",
280+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
281+
"json([\"stop\", \"halt\"])",
282+
], temperature=0.7, top_p=1, user="user-1234",
269283
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
270284

271285
# Handle response
@@ -286,10 +300,12 @@ with AtomaSDK(
286300

287301
res = atoma_sdk.chat.create(messages=[
288302
{
289-
"content": "<value>",
290-
"role": "<value>",
303+
"content": "Hello! How can you help me today?",
304+
"role": "user",
291305
},
292-
], model="LeBaron")
306+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
307+
"json([\"stop\", \"halt\"])",
308+
], temperature=0.7, top_p=1, user="user-1234")
293309

294310
# Handle response
295311
print(res)
@@ -331,10 +347,12 @@ with AtomaSDK(
331347

332348
res = atoma_sdk.chat.create(messages=[
333349
{
334-
"content": "<value>",
335-
"role": "<value>",
350+
"content": "Hello! How can you help me today?",
351+
"role": "user",
336352
},
337-
], model="LeBaron")
353+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
354+
"json([\"stop\", \"halt\"])",
355+
], temperature=0.7, top_p=1, user="user-1234")
338356

339357
# Handle response
340358
print(res)
@@ -362,10 +380,12 @@ with AtomaSDK(
362380

363381
res = atoma_sdk.chat.create(messages=[
364382
{
365-
"content": "<value>",
366-
"role": "<value>",
383+
"content": "Hello! How can you help me today?",
384+
"role": "user",
367385
},
368-
], model="LeBaron")
386+
], model="meta-llama/Llama-3.3-70B-Instruct", frequency_penalty=0, max_tokens=2048, n=1, presence_penalty=0, seed=123, stop=[
387+
"json([\"stop\", \"halt\"])",
388+
], temperature=0.7, top_p=1, user="user-1234")
369389

370390
# Handle response
371391
print(res)

0 commit comments

Comments
 (0)