Skip to content

Commit 819e55d

Browse files
docs: update examples
1 parent c98a1da commit 819e55d

4 files changed

Lines changed: 46 additions & 42 deletions

File tree

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ client = Maisa(
3333
)
3434

3535
text_summary = client.capabilities.summarize(
36-
text="Example long text...",
36+
text="Lorem Ipsum dolor sit amet",
3737
)
3838
print(text_summary.summary)
3939
```
@@ -59,7 +59,7 @@ client = AsyncMaisa(
5959

6060
async def main() -> None:
6161
text_summary = await client.capabilities.summarize(
62-
text="Example long text...",
62+
text="Lorem Ipsum dolor sit amet",
6363
)
6464
print(text_summary.summary)
6565

@@ -95,7 +95,7 @@ async def main() -> None:
9595
http_client=DefaultAioHttpClient(),
9696
) as client:
9797
text_summary = await client.capabilities.summarize(
98-
text="Example long text...",
98+
text="Lorem Ipsum dolor sit amet",
9999
)
100100
print(text_summary.summary)
101101

@@ -147,7 +147,7 @@ client = Maisa()
147147

148148
try:
149149
client.capabilities.summarize(
150-
text="Example long text...",
150+
text="Lorem Ipsum dolor sit amet",
151151
)
152152
except maisa.APIConnectionError as e:
153153
print("The server could not be reached")
@@ -192,7 +192,7 @@ client = Maisa(
192192

193193
# Or, configure per-request:
194194
client.with_options(max_retries=5).capabilities.summarize(
195-
text="Example long text...",
195+
text="Lorem Ipsum dolor sit amet",
196196
)
197197
```
198198

@@ -217,7 +217,7 @@ client = Maisa(
217217

218218
# Override per-request:
219219
client.with_options(timeout=5.0).capabilities.summarize(
220-
text="Example long text...",
220+
text="Lorem Ipsum dolor sit amet",
221221
)
222222
```
223223

@@ -260,7 +260,7 @@ from maisa import Maisa
260260

261261
client = Maisa()
262262
response = client.capabilities.with_raw_response.summarize(
263-
text="Example long text...",
263+
text="Lorem Ipsum dolor sit amet",
264264
)
265265
print(response.headers.get('X-My-Header'))
266266

@@ -280,7 +280,7 @@ To stream the response body, use `.with_streaming_response` instead, which requi
280280

281281
```python
282282
with client.capabilities.with_streaming_response.summarize(
283-
text="Example long text...",
283+
text="Lorem Ipsum dolor sit amet",
284284
) as response:
285285
print(response.headers.get("X-My-Header"))
286286

tests/api_resources/models/test_embeddings.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ class TestEmbeddings:
2020
@parametrize
2121
def test_method_create(self, client: Maisa) -> None:
2222
embedding = client.models.embeddings.create(
23-
texts=["string"],
23+
texts=["Who invented the light bulb?", "Hey, how are you?"],
2424
)
2525
assert_matches_type(Embeddings, embedding, path=["response"])
2626

2727
@parametrize
2828
def test_raw_response_create(self, client: Maisa) -> None:
2929
response = client.models.embeddings.with_raw_response.create(
30-
texts=["string"],
30+
texts=["Who invented the light bulb?", "Hey, how are you?"],
3131
)
3232

3333
assert response.is_closed is True
@@ -38,7 +38,7 @@ def test_raw_response_create(self, client: Maisa) -> None:
3838
@parametrize
3939
def test_streaming_response_create(self, client: Maisa) -> None:
4040
with client.models.embeddings.with_streaming_response.create(
41-
texts=["string"],
41+
texts=["Who invented the light bulb?", "Hey, how are you?"],
4242
) as response:
4343
assert not response.is_closed
4444
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -57,14 +57,14 @@ class TestAsyncEmbeddings:
5757
@parametrize
5858
async def test_method_create(self, async_client: AsyncMaisa) -> None:
5959
embedding = await async_client.models.embeddings.create(
60-
texts=["string"],
60+
texts=["Who invented the light bulb?", "Hey, how are you?"],
6161
)
6262
assert_matches_type(Embeddings, embedding, path=["response"])
6363

6464
@parametrize
6565
async def test_raw_response_create(self, async_client: AsyncMaisa) -> None:
6666
response = await async_client.models.embeddings.with_raw_response.create(
67-
texts=["string"],
67+
texts=["Who invented the light bulb?", "Hey, how are you?"],
6868
)
6969

7070
assert response.is_closed is True
@@ -75,7 +75,7 @@ async def test_raw_response_create(self, async_client: AsyncMaisa) -> None:
7575
@parametrize
7676
async def test_streaming_response_create(self, async_client: AsyncMaisa) -> None:
7777
async with async_client.models.embeddings.with_streaming_response.create(
78-
texts=["string"],
78+
texts=["Who invented the light bulb?", "Hey, how are you?"],
7979
) as response:
8080
assert not response.is_closed
8181
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

tests/api_resources/test_capabilities.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_streaming_response_compare(self, client: Maisa) -> None:
8888
@parametrize
8989
def test_method_extract(self, client: Maisa) -> None:
9090
capability = client.capabilities.extract(
91-
text="Example long text...",
91+
text="My name is John Doe",
9292
variables={
9393
"name": {
9494
"description": "The name of the person.",
@@ -101,7 +101,7 @@ def test_method_extract(self, client: Maisa) -> None:
101101
@parametrize
102102
def test_method_extract_with_all_params(self, client: Maisa) -> None:
103103
capability = client.capabilities.extract(
104-
text="Example long text...",
104+
text="My name is John Doe",
105105
variables={
106106
"name": {
107107
"description": "The name of the person.",
@@ -115,7 +115,7 @@ def test_method_extract_with_all_params(self, client: Maisa) -> None:
115115
@parametrize
116116
def test_raw_response_extract(self, client: Maisa) -> None:
117117
response = client.capabilities.with_raw_response.extract(
118-
text="Example long text...",
118+
text="My name is John Doe",
119119
variables={
120120
"name": {
121121
"description": "The name of the person.",
@@ -132,7 +132,7 @@ def test_raw_response_extract(self, client: Maisa) -> None:
132132
@parametrize
133133
def test_streaming_response_extract(self, client: Maisa) -> None:
134134
with client.capabilities.with_streaming_response.extract(
135-
text="Example long text...",
135+
text="My name is John Doe",
136136
variables={
137137
"name": {
138138
"description": "The name of the person.",
@@ -151,25 +151,25 @@ def test_streaming_response_extract(self, client: Maisa) -> None:
151151
@parametrize
152152
def test_method_summarize(self, client: Maisa) -> None:
153153
capability = client.capabilities.summarize(
154-
text="Example long text...",
154+
text="Lorem Ipsum dolor sit amet",
155155
)
156156
assert_matches_type(TextSummary, capability, path=["response"])
157157

158158
@parametrize
159159
def test_method_summarize_with_all_params(self, client: Maisa) -> None:
160160
capability = client.capabilities.summarize(
161-
text="Example long text...",
161+
text="Lorem Ipsum dolor sit amet",
162162
format="paragraph",
163163
lang="en",
164-
length="medium",
164+
length="long",
165165
summary_hint="Example summary of the text...",
166166
)
167167
assert_matches_type(TextSummary, capability, path=["response"])
168168

169169
@parametrize
170170
def test_raw_response_summarize(self, client: Maisa) -> None:
171171
response = client.capabilities.with_raw_response.summarize(
172-
text="Example long text...",
172+
text="Lorem Ipsum dolor sit amet",
173173
)
174174

175175
assert response.is_closed is True
@@ -180,7 +180,7 @@ def test_raw_response_summarize(self, client: Maisa) -> None:
180180
@parametrize
181181
def test_streaming_response_summarize(self, client: Maisa) -> None:
182182
with client.capabilities.with_streaming_response.summarize(
183-
text="Example long text...",
183+
text="Lorem Ipsum dolor sit amet",
184184
) as response:
185185
assert not response.is_closed
186186
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -267,7 +267,7 @@ async def test_streaming_response_compare(self, async_client: AsyncMaisa) -> Non
267267
@parametrize
268268
async def test_method_extract(self, async_client: AsyncMaisa) -> None:
269269
capability = await async_client.capabilities.extract(
270-
text="Example long text...",
270+
text="My name is John Doe",
271271
variables={
272272
"name": {
273273
"description": "The name of the person.",
@@ -280,7 +280,7 @@ async def test_method_extract(self, async_client: AsyncMaisa) -> None:
280280
@parametrize
281281
async def test_method_extract_with_all_params(self, async_client: AsyncMaisa) -> None:
282282
capability = await async_client.capabilities.extract(
283-
text="Example long text...",
283+
text="My name is John Doe",
284284
variables={
285285
"name": {
286286
"description": "The name of the person.",
@@ -294,7 +294,7 @@ async def test_method_extract_with_all_params(self, async_client: AsyncMaisa) ->
294294
@parametrize
295295
async def test_raw_response_extract(self, async_client: AsyncMaisa) -> None:
296296
response = await async_client.capabilities.with_raw_response.extract(
297-
text="Example long text...",
297+
text="My name is John Doe",
298298
variables={
299299
"name": {
300300
"description": "The name of the person.",
@@ -311,7 +311,7 @@ async def test_raw_response_extract(self, async_client: AsyncMaisa) -> None:
311311
@parametrize
312312
async def test_streaming_response_extract(self, async_client: AsyncMaisa) -> None:
313313
async with async_client.capabilities.with_streaming_response.extract(
314-
text="Example long text...",
314+
text="My name is John Doe",
315315
variables={
316316
"name": {
317317
"description": "The name of the person.",
@@ -330,25 +330,25 @@ async def test_streaming_response_extract(self, async_client: AsyncMaisa) -> Non
330330
@parametrize
331331
async def test_method_summarize(self, async_client: AsyncMaisa) -> None:
332332
capability = await async_client.capabilities.summarize(
333-
text="Example long text...",
333+
text="Lorem Ipsum dolor sit amet",
334334
)
335335
assert_matches_type(TextSummary, capability, path=["response"])
336336

337337
@parametrize
338338
async def test_method_summarize_with_all_params(self, async_client: AsyncMaisa) -> None:
339339
capability = await async_client.capabilities.summarize(
340-
text="Example long text...",
340+
text="Lorem Ipsum dolor sit amet",
341341
format="paragraph",
342342
lang="en",
343-
length="medium",
343+
length="long",
344344
summary_hint="Example summary of the text...",
345345
)
346346
assert_matches_type(TextSummary, capability, path=["response"])
347347

348348
@parametrize
349349
async def test_raw_response_summarize(self, async_client: AsyncMaisa) -> None:
350350
response = await async_client.capabilities.with_raw_response.summarize(
351-
text="Example long text...",
351+
text="Lorem Ipsum dolor sit amet",
352352
)
353353

354354
assert response.is_closed is True
@@ -359,7 +359,7 @@ async def test_raw_response_summarize(self, async_client: AsyncMaisa) -> None:
359359
@parametrize
360360
async def test_streaming_response_summarize(self, async_client: AsyncMaisa) -> None:
361361
async with async_client.capabilities.with_streaming_response.summarize(
362-
text="Example long text...",
362+
text="Lorem Ipsum dolor sit amet",
363363
) as response:
364364
assert not response.is_closed
365365
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

tests/test_client.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, clien
866866
respx_mock.post("/v1/capabilities/summarize").mock(side_effect=httpx.TimeoutException("Test timeout error"))
867867

868868
with pytest.raises(APITimeoutError):
869-
client.capabilities.with_streaming_response.summarize(text="Example long text...").__enter__()
869+
client.capabilities.with_streaming_response.summarize(text="Lorem Ipsum dolor sit amet").__enter__()
870870

871871
assert _get_open_connections(client) == 0
872872

@@ -876,7 +876,7 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client
876876
respx_mock.post("/v1/capabilities/summarize").mock(return_value=httpx.Response(500))
877877

878878
with pytest.raises(APIStatusError):
879-
client.capabilities.with_streaming_response.summarize(text="Example long text...").__enter__()
879+
client.capabilities.with_streaming_response.summarize(text="Lorem Ipsum dolor sit amet").__enter__()
880880
assert _get_open_connections(client) == 0
881881

882882
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@@ -905,7 +905,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
905905

906906
respx_mock.post("/v1/capabilities/summarize").mock(side_effect=retry_handler)
907907

908-
response = client.capabilities.with_raw_response.summarize(text="Example long text...")
908+
response = client.capabilities.with_raw_response.summarize(text="Lorem Ipsum dolor sit amet")
909909

910910
assert response.retries_taken == failures_before_success
911911
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
@@ -928,7 +928,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
928928
respx_mock.post("/v1/capabilities/summarize").mock(side_effect=retry_handler)
929929

930930
response = client.capabilities.with_raw_response.summarize(
931-
text="Example long text...", extra_headers={"x-stainless-retry-count": Omit()}
931+
text="Lorem Ipsum dolor sit amet", extra_headers={"x-stainless-retry-count": Omit()}
932932
)
933933

934934
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
@@ -953,7 +953,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
953953
respx_mock.post("/v1/capabilities/summarize").mock(side_effect=retry_handler)
954954

955955
response = client.capabilities.with_raw_response.summarize(
956-
text="Example long text...", extra_headers={"x-stainless-retry-count": "42"}
956+
text="Lorem Ipsum dolor sit amet", extra_headers={"x-stainless-retry-count": "42"}
957957
)
958958

959959
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
@@ -1786,7 +1786,9 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter,
17861786
respx_mock.post("/v1/capabilities/summarize").mock(side_effect=httpx.TimeoutException("Test timeout error"))
17871787

17881788
with pytest.raises(APITimeoutError):
1789-
await async_client.capabilities.with_streaming_response.summarize(text="Example long text...").__aenter__()
1789+
await async_client.capabilities.with_streaming_response.summarize(
1790+
text="Lorem Ipsum dolor sit amet"
1791+
).__aenter__()
17901792

17911793
assert _get_open_connections(async_client) == 0
17921794

@@ -1796,7 +1798,9 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter,
17961798
respx_mock.post("/v1/capabilities/summarize").mock(return_value=httpx.Response(500))
17971799

17981800
with pytest.raises(APIStatusError):
1799-
await async_client.capabilities.with_streaming_response.summarize(text="Example long text...").__aenter__()
1801+
await async_client.capabilities.with_streaming_response.summarize(
1802+
text="Lorem Ipsum dolor sit amet"
1803+
).__aenter__()
18001804
assert _get_open_connections(async_client) == 0
18011805

18021806
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@@ -1825,7 +1829,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
18251829

18261830
respx_mock.post("/v1/capabilities/summarize").mock(side_effect=retry_handler)
18271831

1828-
response = await client.capabilities.with_raw_response.summarize(text="Example long text...")
1832+
response = await client.capabilities.with_raw_response.summarize(text="Lorem Ipsum dolor sit amet")
18291833

18301834
assert response.retries_taken == failures_before_success
18311835
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
@@ -1850,7 +1854,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
18501854
respx_mock.post("/v1/capabilities/summarize").mock(side_effect=retry_handler)
18511855

18521856
response = await client.capabilities.with_raw_response.summarize(
1853-
text="Example long text...", extra_headers={"x-stainless-retry-count": Omit()}
1857+
text="Lorem Ipsum dolor sit amet", extra_headers={"x-stainless-retry-count": Omit()}
18541858
)
18551859

18561860
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
@@ -1875,7 +1879,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
18751879
respx_mock.post("/v1/capabilities/summarize").mock(side_effect=retry_handler)
18761880

18771881
response = await client.capabilities.with_raw_response.summarize(
1878-
text="Example long text...", extra_headers={"x-stainless-retry-count": "42"}
1882+
text="Lorem Ipsum dolor sit amet", extra_headers={"x-stainless-retry-count": "42"}
18791883
)
18801884

18811885
assert response.http_request.headers.get("x-stainless-retry-count") == "42"

0 commit comments

Comments
 (0)