Skip to content

Commit

Permalink
[0.5.3]
Browse files Browse the repository at this point in the history
  • Loading branch information
yashbonde committed Sep 1, 2024
1 parent c511289 commit 772e272
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 14 deletions.
15 changes: 15 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ minor versions.

All relevant steps to be taken will be mentioned here.

0.5.3
-----

- Fix bug in Tune proxy API where incorrect variable ``stop_sequence`` was sent instead of the correct ``stop`` causing
incorrect behaviour.
- bump dependency to ``protobuf>=5.27.3``
- remove ``__version__`` from tuneapi package
- remove CLI entrypoint in ``pyproject.toml``

0.5.2
-----

- Add ability to upload any file using ``tuneapi.endpoints.FinetuningAPI.upload_dataset_file`` to support the existing
way to uploading using threads.

0.5.1
-----

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
project = "tuneapi"
copyright = "2024, Frello Technologies"
author = "Frello Technologies"
release = "0.5.1"
release = "0.5.3"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tuneapi"
version = "0.5.1"
version = "0.5.3"
description = "Tune AI APIs."
authors = ["Frello Technology Private Limited <[email protected]>"]
license = "MIT"
Expand All @@ -12,7 +12,7 @@ python = "^3.10"
fire = "0.5.0"
requests = "^2.31.0"
cloudpickle = "3.0.0"
protobuf = "^4.25.3"
protobuf = "^5.27.3"
cryptography = ">=42.0.5"
tqdm = "^4.66.1"
snowflake_id = "1.0.2"
Expand All @@ -23,8 +23,8 @@ boto3 = { version = "1.29.6", optional = true }
[tool.poetry.extras]
boto3 = ["boto3"]

[tool.poetry.scripts]
tuneapi = "tuneapi.__main__:main"
# [tool.poetry.scripts]
# tuneapi = "tuneapi.__main__:main"

[tool.poetry.group.dev.dependencies]
sphinx = "7.2.5"
Expand Down
2 changes: 0 additions & 2 deletions tuneapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# Copyright © 2023- Frello Technology Private Limited

__version__ = "0.5.1"
12 changes: 7 additions & 5 deletions tuneapi/apis/model_tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import json
import requests
from typing import Optional, Dict, Any
from typing import Optional, Dict, Any, List

import tuneapi.utils as tu
import tuneapi.types as tt
Expand Down Expand Up @@ -113,7 +113,8 @@ def chat(
max_tokens: int = 1024,
temperature: float = 0.7,
token: Optional[str] = None,
timeout=(5, 30),
timeout=(5, 60),
stop: Optional[List[str]] = None,
**kwargs,
) -> str | Dict[str, Any]:
output = ""
Expand All @@ -124,6 +125,7 @@ def chat(
temperature=temperature,
token=token,
timeout=timeout,
stop=stop,
**kwargs,
):
if isinstance(x, dict):
Expand All @@ -140,7 +142,7 @@ def stream_chat(
temperature: float = 0.7,
token: Optional[str] = None,
timeout=(5, 60),
stop_sequence: Optional[str] = None,
stop: Optional[List[str]] = None,
raw: bool = False,
debug: bool = False,
):
Expand All @@ -157,8 +159,8 @@ def stream_chat(
"stream": True,
"max_tokens": max_tokens,
}
if stop_sequence:
data["stop_sequence"] = stop_sequence
if stop:
data["stop"] = stop
if isinstance(chats, tt.Thread) and len(chats.tools):
data["tools"] = [
{"type": "function", "function": x.to_dict()} for x in chats.tools
Expand Down
32 changes: 32 additions & 0 deletions tuneapi/endpoints/finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,38 @@ def __init__(
base_url + "tune.Studio/", self.tune_org_id, self.tune_api_key
)

def upload_dataset_file(self, filepath: str, name: str):
# first we get the presigned URL for the dataset
data = self.sub.UploadDataset(
"post",
json={
"auth": {
"organization": self.tune_org_id,
},
"dataset": {
"name": name,
"contentType": "application/jsonl",
"datasetType": "chat",
"size": os.stat(filepath).st_size,
},
},
)
with open(filepath, "rb") as f:
files = {"file": (filepath, f)}
http_response = requests.post(
data["code"]["s3Url"],
data=data["code"]["s3Meta"],
files=files,
)
if http_response.status_code == 204:
tu.logger.info("Upload successful!")
else:
raise ValueError(
f"Upload failed with status code: {http_response.status_code} and response: {http_response.text}"
)

return FTDataset(path="datasets/chat/" + name, type="relic")

def upload_dataset(
self,
threads: tt.ThreadsList | str,
Expand Down
4 changes: 2 additions & 2 deletions tuneapi/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class _ENV:
def __init__(self):
self.vars_called = set()

TUNEAPI_TOKEN = lambda x="": os.getenv("TUNEAPI_TOKEN", x)
TUNEORG_ID = lambda x="": os.getenv("TUNEORG_ID", x)
TUNEAPI_TOKEN = lambda _, x="": os.getenv("TUNEAPI_TOKEN", x)
TUNEORG_ID = lambda _, x="": os.getenv("TUNEORG_ID", x)

def __getattr__(self, __name: str):
self.vars_called.add(__name)
Expand Down

0 comments on commit 772e272

Please sign in to comment.