Skip to content

Commit 772e272

Browse files
committed
[0.5.3]
1 parent c511289 commit 772e272

File tree

7 files changed

+61
-14
lines changed

7 files changed

+61
-14
lines changed

docs/changelog.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@ minor versions.
77

88
All relevant steps to be taken will be mentioned here.
99

10+
0.5.3
11+
-----
12+
13+
- Fix bug in Tune proxy API where incorrect variable ``stop_sequence`` was sent instead of the correct ``stop`` causing
14+
incorrect behaviour.
15+
- bump dependency to ``protobuf>=5.27.3``
16+
- remove ``__version__`` from tuneapi package
17+
- remove CLI entrypoint in ``pyproject.toml``
18+
19+
0.5.2
20+
-----
21+
22+
- Add ability to upload any file using ``tuneapi.endpoints.FinetuningAPI.upload_dataset_file`` to support the existing
23+
way to uploading using threads.
24+
1025
0.5.1
1126
-----
1227

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
project = "tuneapi"
1414
copyright = "2024, Frello Technologies"
1515
author = "Frello Technologies"
16-
release = "0.5.1"
16+
release = "0.5.3"
1717

1818
# -- General configuration ---------------------------------------------------
1919
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "tuneapi"
3-
version = "0.5.1"
3+
version = "0.5.3"
44
description = "Tune AI APIs."
55
authors = ["Frello Technology Private Limited <[email protected]>"]
66
license = "MIT"
@@ -12,7 +12,7 @@ python = "^3.10"
1212
fire = "0.5.0"
1313
requests = "^2.31.0"
1414
cloudpickle = "3.0.0"
15-
protobuf = "^4.25.3"
15+
protobuf = "^5.27.3"
1616
cryptography = ">=42.0.5"
1717
tqdm = "^4.66.1"
1818
snowflake_id = "1.0.2"
@@ -23,8 +23,8 @@ boto3 = { version = "1.29.6", optional = true }
2323
[tool.poetry.extras]
2424
boto3 = ["boto3"]
2525

26-
[tool.poetry.scripts]
27-
tuneapi = "tuneapi.__main__:main"
26+
# [tool.poetry.scripts]
27+
# tuneapi = "tuneapi.__main__:main"
2828

2929
[tool.poetry.group.dev.dependencies]
3030
sphinx = "7.2.5"

tuneapi/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
# Copyright © 2023- Frello Technology Private Limited
2-
3-
__version__ = "0.5.1"

tuneapi/apis/model_tune.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import json
88
import requests
9-
from typing import Optional, Dict, Any
9+
from typing import Optional, Dict, Any, List
1010

1111
import tuneapi.utils as tu
1212
import tuneapi.types as tt
@@ -113,7 +113,8 @@ def chat(
113113
max_tokens: int = 1024,
114114
temperature: float = 0.7,
115115
token: Optional[str] = None,
116-
timeout=(5, 30),
116+
timeout=(5, 60),
117+
stop: Optional[List[str]] = None,
117118
**kwargs,
118119
) -> str | Dict[str, Any]:
119120
output = ""
@@ -124,6 +125,7 @@ def chat(
124125
temperature=temperature,
125126
token=token,
126127
timeout=timeout,
128+
stop=stop,
127129
**kwargs,
128130
):
129131
if isinstance(x, dict):
@@ -140,7 +142,7 @@ def stream_chat(
140142
temperature: float = 0.7,
141143
token: Optional[str] = None,
142144
timeout=(5, 60),
143-
stop_sequence: Optional[str] = None,
145+
stop: Optional[List[str]] = None,
144146
raw: bool = False,
145147
debug: bool = False,
146148
):
@@ -157,8 +159,8 @@ def stream_chat(
157159
"stream": True,
158160
"max_tokens": max_tokens,
159161
}
160-
if stop_sequence:
161-
data["stop_sequence"] = stop_sequence
162+
if stop:
163+
data["stop"] = stop
162164
if isinstance(chats, tt.Thread) and len(chats.tools):
163165
data["tools"] = [
164166
{"type": "function", "function": x.to_dict()} for x in chats.tools

tuneapi/endpoints/finetune.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,38 @@ def __init__(
3838
base_url + "tune.Studio/", self.tune_org_id, self.tune_api_key
3939
)
4040

41+
def upload_dataset_file(self, filepath: str, name: str):
42+
# first we get the presigned URL for the dataset
43+
data = self.sub.UploadDataset(
44+
"post",
45+
json={
46+
"auth": {
47+
"organization": self.tune_org_id,
48+
},
49+
"dataset": {
50+
"name": name,
51+
"contentType": "application/jsonl",
52+
"datasetType": "chat",
53+
"size": os.stat(filepath).st_size,
54+
},
55+
},
56+
)
57+
with open(filepath, "rb") as f:
58+
files = {"file": (filepath, f)}
59+
http_response = requests.post(
60+
data["code"]["s3Url"],
61+
data=data["code"]["s3Meta"],
62+
files=files,
63+
)
64+
if http_response.status_code == 204:
65+
tu.logger.info("Upload successful!")
66+
else:
67+
raise ValueError(
68+
f"Upload failed with status code: {http_response.status_code} and response: {http_response.text}"
69+
)
70+
71+
return FTDataset(path="datasets/chat/" + name, type="relic")
72+
4173
def upload_dataset(
4274
self,
4375
threads: tt.ThreadsList | str,

tuneapi/utils/env.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class _ENV:
88
def __init__(self):
99
self.vars_called = set()
1010

11-
TUNEAPI_TOKEN = lambda x="": os.getenv("TUNEAPI_TOKEN", x)
12-
TUNEORG_ID = lambda x="": os.getenv("TUNEORG_ID", x)
11+
TUNEAPI_TOKEN = lambda _, x="": os.getenv("TUNEAPI_TOKEN", x)
12+
TUNEORG_ID = lambda _, x="": os.getenv("TUNEORG_ID", x)
1313

1414
def __getattr__(self, __name: str):
1515
self.vars_called.add(__name)

0 commit comments

Comments
 (0)