together 1.3.0__py3-none-any.whl → 1.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import base64
2
2
  import pathlib
3
+ import requests
3
4
 
4
5
  import click
5
6
  from PIL import Image
@@ -70,8 +71,18 @@ def generate(
70
71
  for i, choice in enumerate(response.data):
71
72
  assert isinstance(choice, ImageChoicesData)
72
73
 
74
+ data = None
75
+ if choice.b64_json:
76
+ data = base64.b64decode(choice.b64_json)
77
+ elif choice.url:
78
+ data = requests.get(choice.url).content
79
+
80
+ if not data:
81
+ click.echo(f"Image [{i + 1}/{len(response.data)}] is empty")
82
+ continue
83
+
73
84
  with open(f"{output}/{prefix}{choice.index}.png", "wb") as f:
74
- f.write(base64.b64decode(choice.b64_json))
85
+ f.write(data)
75
86
 
76
87
  click.echo(
77
88
  f"Image [{i + 1}/{len(response.data)}] saved to {output}/{prefix}{choice.index}.png"
together/types/images.py CHANGED
@@ -28,7 +28,9 @@ class ImageChoicesData(BaseModel):
28
28
  # response index
29
29
  index: int
30
30
  # base64 image response
31
- b64_json: str
31
+ b64_json: str | None = None
32
+ # URL hosting image
33
+ url: str | None = None
32
34
 
33
35
 
34
36
  class ImageResponse(BaseModel):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: together
3
- Version: 1.3.0
3
+ Version: 1.3.1
4
4
  Summary: Python client for Together's Cloud Platform!
5
5
  Home-page: https://github.com/togethercomputer/together-python
6
6
  License: Apache-2.0
@@ -7,7 +7,7 @@ together/cli/api/chat.py,sha256=2PHRb-9T-lUEKhUJFtc7SxJv3shCVx40gq_8pzfsewM,9234
7
7
  together/cli/api/completions.py,sha256=l-Zw5t7hojL3w8xd_mitS2NRB72i5Z0xwkzH0rT5XMc,4263
8
8
  together/cli/api/files.py,sha256=QLYEXRkY8J2Gg1SbTCtzGfoTMvosoeACNK83L_oLubs,3397
9
9
  together/cli/api/finetune.py,sha256=1oZo2zJGMcUHpnEJuCYsY_w4MAYjUuVG9coCvmZJv74,11801
10
- together/cli/api/images.py,sha256=01dFYa2sK1HqUwVCD9FlwcjqkYWLoNxFZkzok13EriE,2363
10
+ together/cli/api/images.py,sha256=GADSeaNUHUVMtWovmccGuKc28IJ9E_v4vAEwYHJhu5o,2645
11
11
  together/cli/api/models.py,sha256=xWEzu8ZpxM_Pz9KEjRPRVuv_v22RayYZ4QcgiezT5tE,1126
12
12
  together/cli/api/utils.py,sha256=IoMIilvBOE5zdq6OgCU2Qa9p_CbrsXCR7b9q3MWu9S0,446
13
13
  together/cli/cli.py,sha256=RC0tgapkSOFjsRPg8p-8dx9D2LDzm8YmVCHUjk_aVyQ,1977
@@ -43,7 +43,7 @@ together/types/embeddings.py,sha256=J7grkYYn7xhqeKaBO2T-8XQRtHhkzYzymovtGdIUK5A,
43
43
  together/types/error.py,sha256=OVlCs3cx_2WhZK4JzHT8SQyRIIqKOP1AZQ4y1PydjAE,370
44
44
  together/types/files.py,sha256=-rEUfsV6f2vZB9NrFxT4_933ubsDIUNkPB-3OlOFk4A,1954
45
45
  together/types/finetune.py,sha256=8oYZPNgMWw6xGT3kRzAF4LlWjSfVti4uDVi6FoVJDM0,7814
46
- together/types/images.py,sha256=zX4Vt38tFDKU6yGb_hBY_N5eSTn3KPdpP5Ce_qnRHXQ,915
46
+ together/types/images.py,sha256=xnC-FZGdZU30WSFTybfGneWxb-kj0ZGufJsgHtB8j0k,980
47
47
  together/types/models.py,sha256=K9Om3cCFexy7qzRSEXUj7gpCy1CVb1hHx7MGG-hvTLw,1035
48
48
  together/types/rerank.py,sha256=qZfuXOn7MZ6ly8hpJ_MZ7OU_Bi1-cgYNSB20Wja8Qkk,1061
49
49
  together/utils/__init__.py,sha256=n1kmLiaExT9YOKT5ye--dC4tW2qcHeicKX0GR86U640,698
@@ -52,8 +52,8 @@ together/utils/api_helpers.py,sha256=RSF7SRhbjHzroMOSWAXscflByM1r1ta_1SpxkAT22iE
52
52
  together/utils/files.py,sha256=gMLthqfP5hKxVAerHMdy7gLXzdfY6lyOXdpW24Y4X3I,7165
53
53
  together/utils/tools.py,sha256=3-lXWP3cBCzOVSZg9tr5zOT1jaVeKAKVWxO2fcXZTh8,1788
54
54
  together/version.py,sha256=p03ivHyE0SyWU4jAnRTBi_sOwywVWoZPU4g2gzRgG-Y,126
55
- together-1.3.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
56
- together-1.3.0.dist-info/METADATA,sha256=cPKfs6LBr2fFiaA3Pn0LeZASHpZhIiHh_AyI6aQBYxQ,11855
57
- together-1.3.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
58
- together-1.3.0.dist-info/entry_points.txt,sha256=G-b5NKW6lUUf1V1fH8IPTBb7jXnK7lhbX9H1zTEJXPs,50
59
- together-1.3.0.dist-info/RECORD,,
55
+ together-1.3.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
56
+ together-1.3.1.dist-info/METADATA,sha256=c5f1aaAoXmHuT21Pf2Z2LTCNlun8gEoinVBe4n0nER8,11855
57
+ together-1.3.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
58
+ together-1.3.1.dist-info/entry_points.txt,sha256=G-b5NKW6lUUf1V1fH8IPTBb7jXnK7lhbX9H1zTEJXPs,50
59
+ together-1.3.1.dist-info/RECORD,,