Skip to content

Commit

Permalink
[0.5.1] [fix] bug in endpoints module
Browse files Browse the repository at this point in the history
  • Loading branch information
yashbonde committed Aug 12, 2024
1 parent 0923590 commit c511289
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cookbooks/finetuning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"source": [
"ft = te.FinetuningAPI(\n",
" tune_api_key=\"xxxxx\",\n",
" tune_org_id=\"e3365ae7-ceeb-425b-b983-1703e8456f76\",\n",
" tune_org_id=\"yyyyy\", # ignore this if you don't have multiple orgs\n",
")\n",
"out = ft.upload_dataset(\n",
" threads=threads,\n",
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ minor versions.

All relevant steps to be taken will be mentioned here.

0.5.1
-----

- Fix bug in the endpoints module where error was raised despite correct inputs

0.5.0 **(breaking)**
--------------------

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.0"
release = "0.5.1"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tuneapi"
version = "0.5.0"
version = "0.5.1"
description = "Tune AI APIs."
authors = ["Frello Technology Private Limited <[email protected]>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion tuneapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright © 2023- Frello Technology Private Limited

__version__ = "0.5.0"
__version__ = "0.5.1"
8 changes: 5 additions & 3 deletions tuneapi/endpoints/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ def __init__(
self,
tune_org_id: str = None,
tune_api_key: str = None,
base_url: str = "https://studio.tune.app/v1/assistants",
base_url: str = "https://studio.tune.app/",
):
self.tune_org_id = tune_org_id or tu.ENV.TUNEORG_ID()
self.tune_api_key = tune_api_key or tu.ENV.TUNEAPI_TOKEN()
self.base_url = base_url
if not tune_api_key:
if not self.tune_api_key:
raise ValueError("Either pass tune_api_key or set Env var TUNEAPI_TOKEN")
self.sub = get_sub(base_url, self.tune_org_id, self.tune_api_key)
self.sub = get_sub(
base_url + "v1/assistants/", self.tune_org_id, self.tune_api_key
)

def list_assistants(self, limit: int = 10, order: str = "desc"):
out = self.sub(params={"limit": limit, "order": order})
Expand Down
2 changes: 1 addition & 1 deletion tuneapi/endpoints/finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(
self.tune_org_id = tune_org_id or tu.ENV.TUNEORG_ID()
self.tune_api_key = tune_api_key or tu.ENV.TUNEAPI_TOKEN()
self.base_url = base_url
if not tune_api_key:
if not self.tune_api_key:
raise ValueError("Either pass tune_api_key or set Env var TUNEAPI_TOKEN")
self.sub = get_sub(
base_url + "tune.Studio/", self.tune_org_id, self.tune_api_key
Expand Down
18 changes: 10 additions & 8 deletions tuneapi/endpoints/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ def __init__(
self,
tune_org_id: str = None,
tune_api_key: str = None,
base_url: str = "https://studio.tune.app/v1/threads",
base_url: str = "https://studio.tune.app/",
):
self.tune_org_id = tune_org_id or tu.ENV.TUNEORG_ID()
self.tune_api_key = tune_api_key or tu.ENV.TUNEAPI_TOKEN()
self.base_url = base_url
if not tune_api_key:
if not self.tune_api_key:
raise ValueError("Either pass tune_api_key or set Env var TUNEAPI_TOKEN")
self.sub = get_sub(base_url, self.tune_org_id, self.tune_api_key)
self.sub = get_sub(
base_url + "v1/threads/", self.tune_org_id, self.tune_api_key
)

def put_thread(self, thread: tt.Thread) -> tt.Thread:
if not thread.title:
Expand All @@ -46,7 +48,7 @@ def put_thread(self, thread: tt.Thread) -> tt.Thread:

tu.logger.info("Creating new thread")
print(tu.to_json(body))
out = self.sub.threads("post", json=body)
out = self.sub("post", json=body)
thread.id = out["id"]
return thread

Expand All @@ -56,7 +58,7 @@ def get_thread(
messages: bool = False,
) -> tt.Thread:
# GET /threads/{thread_id}
fn = self.sub.threads.u(thread_id)
fn = self.sub.u(thread_id)
data = fn()
meta = data.get("metadata", {})
if meta == None:
Expand All @@ -74,7 +76,7 @@ def get_thread(

if messages:
# GET /threads/{thread_id}/messages
fn = self.sub.threads.u(thread_id).messages
fn = self.sub.u(thread_id).messages
data = fn()
for m in data["data"]:
text_items = list(filter(lambda x: x["type"] == "text", m["content"]))
Expand All @@ -101,7 +103,7 @@ def list_threads(
dataset_id: Optional[str] = None,
) -> List[tt.Thread]:
# GET /threads
fn = self.sub.threads
fn = self.sub
params = {
"limit": limit,
"order": order,
Expand All @@ -125,7 +127,7 @@ def list_threads(

def fill_thread_messages(self, thread: tt.Thread):
# GET /threads/{thread_id}/messages
fn = self.sub.threads.u(thread.id).messages
fn = self.sub.u(thread.id).messages
data = fn()
for m in data["data"]:
text_items = list(filter(lambda x: x["type"] == "text", m["content"]))
Expand Down

0 comments on commit c511289

Please sign in to comment.