Skip to content

Commit

Permalink
[0.5.13] house keeping on tuneapi
Browse files Browse the repository at this point in the history
  • Loading branch information
yashbonde committed Nov 28, 2024
1 parent 0e55110 commit ffcbf3b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 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.13
-----

- ``tuneapi.types.ModelInterface`` has an ``extra_headers`` attribute in it.

0.5.12
-----

- Remove code to sanitize assistant message in for Tune and OpenAI LLM APIs.

0.5.11
-----

- Fix bug where ``parallel_tool_calls`` was sent even for non tool calls.

0.5.10
-----

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.10"
release = "0.5.13"

# -- 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.10"
version = "0.5.13"
description = "Tune AI APIs."
authors = ["Frello Technology Private Limited <[email protected]>"]
license = "MIT"
Expand Down
16 changes: 6 additions & 10 deletions tuneapi/apis/model_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ def _process_input(self, chats, token: Optional[str] = None):
elif m.role == tt.Message.HUMAN:
final_messages.append({"role": "user", "content": m.value})
elif m.role == tt.Message.GPT:
final_messages.append(
{
"role": "assistant",
"content": m.value.strip(),
}
)
final_messages.append({"role": "assistant", "content": m.value})
elif m.role == tt.Message.FUNCTION_CALL:
_m = tu.from_json(m.value) if isinstance(m.value, str) else m.value
final_messages.append(
Expand Down Expand Up @@ -97,7 +92,7 @@ def chat(
self,
chats: tt.Thread | str,
model: Optional[str] = None,
max_tokens: int = 1024,
max_tokens: int = None,
temperature: float = 1,
parallel_tool_calls: bool = False,
token: Optional[str] = None,
Expand Down Expand Up @@ -126,7 +121,7 @@ def stream_chat(
self,
chats: tt.Thread | str,
model: Optional[str] = None,
max_tokens: int = 1024,
max_tokens: int = None,
temperature: float = 1,
parallel_tool_calls: bool = False,
token: Optional[str] = None,
Expand All @@ -144,13 +139,14 @@ def stream_chat(
"messages": messages,
"model": model or self.model_id,
"stream": True,
"max_tokens": max_tokens,
"parallel_tool_calls": parallel_tool_calls,
}
if max_tokens:
data["max_tokens"] = max_tokens
if isinstance(chats, tt.Thread) and len(chats.tools):
data["tools"] = [
{"type": "function", "function": x.to_dict()} for x in chats.tools
]
data["parallel_tool_calls"] = parallel_tool_calls
if debug:
fp = "sample_oai.json"
print("Saving at path " + fp)
Expand Down
7 changes: 1 addition & 6 deletions tuneapi/apis/model_tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@ def _process_input(self, chats, token: Optional[str] = None):
elif m.role == tt.Message.HUMAN:
final_messages.append({"role": "user", "content": m.value})
elif m.role == tt.Message.GPT:
final_messages.append(
{
"role": "assistant",
"content": m.value.strip(),
}
)
final_messages.append({"role": "assistant", "content": m.value})
elif m.role == tt.Message.FUNCTION_CALL:
_m = tu.from_json(m.value) if isinstance(m.value, str) else m.value
final_messages.append(
Expand Down
3 changes: 3 additions & 0 deletions tuneapi/types/chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ class ModelInterface:
api_token: str
"""This is the API token for the model"""

extra_headers: Dict[str, Any]
"""This is the placeholder for any extra headers to be passed during request"""

def set_api_token(self, token: str) -> None:
"""This are used to set the API token for the model"""
raise NotImplementedError("This model has no operation for this.")
Expand Down

0 comments on commit ffcbf3b

Please sign in to comment.