Skip to content

Commit

Permalink
reformatted depricated some tool support
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanjaypranav committed Feb 7, 2024
1 parent e60efbd commit 77fc572
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 16 deletions.
4 changes: 4 additions & 0 deletions src/sayvai_tools/tools/TTS/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

from elevenlabs import play

from sayvai_tools.utils.exception import deprecated
from sayvai_tools.utils.voice.tts import ElevenlabsAudioStreaming


@deprecated(
message="VoiceOutputRun is deprecated and will be removed in future sayvai-tools 0.0.5 ."
)
class VoiceOutputRun:
"""Tool that asks user for input."""

Expand Down
4 changes: 3 additions & 1 deletion src/sayvai_tools/tools/calendar/calendar/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def __init__(self, scope: str, email: str, summary: str):

@classmethod
def create(cls, **kwargs) -> "Calendar":
return cls(scope=kwargs["scope"], email=kwargs["email"], summary=kwargs["summary"])
return cls(
scope=kwargs["scope"], email=kwargs["email"], summary=kwargs["summary"]
)

def _run(self, date: str):
return self.cal.book_slots(input_str=date)
Expand Down
7 changes: 6 additions & 1 deletion src/sayvai_tools/tools/calendar/calendar_sql/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ def __init__(self, pool, scope: str, email: str, summary: str):

@classmethod
def create(cls, **kwargs) -> "CalendarSql":
return cls(pool=kwargs["pool"], scope=kwargs["scope"], email=kwargs["email"], summary=kwargs["summary"])
return cls(
pool=kwargs["pool"],
scope=kwargs["scope"],
email=kwargs["email"],
summary=kwargs["summary"],
)

def _run(self, details: str):
start_time, end_time, phone, name = details.split("/")
Expand Down
3 changes: 2 additions & 1 deletion src/sayvai_tools/tools/calendar_block/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def create(cls, **kwargs) -> "BlockCalendar":
organizer=kwargs["organizer"],
smtp_username=kwargs["smtp_username"],
smtp_password=kwargs["smtp_password"],
scope=kwargs["scope"],)
scope=kwargs["scope"],
)

def _run(self, date: str, contacts: list):
self.cal.block_day(
Expand Down
4 changes: 2 additions & 2 deletions src/sayvai_tools/tools/date/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@


class GetDate:

@classmethod
def create(cls) -> "GetDate":
return cls()

def _run(self) -> str:
"""Use the tool."""

Expand Down
13 changes: 7 additions & 6 deletions src/sayvai_tools/tools/spreadsheets/sql_sheets/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ def __init__(
self.verbose = verbose

@classmethod
def create(cls,**kwargs) -> "SQLGSheet":
return cls(uri=kwargs["uri"],
llm=kwargs["llm"],
prompt=kwargs.get("prompt"),
verbose=kwargs.get("verbose", False)
)
def create(cls, **kwargs) -> "SQLGSheet":
return cls(
uri=kwargs["uri"],
llm=kwargs["llm"],
prompt=kwargs.get("prompt"),
verbose=kwargs.get("verbose", False),
)

# sample input save past 30 days data to google sheet from record table
# table fetched from sql query
Expand Down
2 changes: 1 addition & 1 deletion src/sayvai_tools/tools/sql_database/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create(cls, **kwargs) -> "Database":
engine=kwargs["engine"],
prompt=kwargs.get("prompt"),
verbose=kwargs.get("verbose", False),
k=kwargs.get("k", 5)
k=kwargs.get("k", 5),
)

def _run(self, query: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/sayvai_tools/tools/vectordb/pgvector/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def create(cls, **kwargs) -> "PGVectorDB":
return cls(
embeddings=kwargs["embeddings"],
collection_name=kwargs["collection_name"],
connection_string=kwargs["connection_string"]
connection_string=kwargs["connection_string"],
)

def _run(
Expand Down
23 changes: 22 additions & 1 deletion src/sayvai_tools/utils/exception.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Exception Classes for Sayvai Tools"""

import functools
import warnings


class SayvaiToolsError(Exception):
"""Base class for exceptions in this module."""
Expand All @@ -17,9 +20,27 @@ def __init__(self, message: str):
super().__init__(self.message)


class SayvaiToolsDeprecatedWarning(SayvaiToolsWarning):
class SayvaiToolsDeprecatedWarning(DeprecationWarning):
"""Base class for deprecated warnings in this module."""

def __init__(self, message: str):
self.message = message
super().__init__(self.message)


def deprecated(
message="This class is deprecated and will be removed in future versions.",
):
"""
Decorator to mark a class as deprecated.
"""

def decorator(cls):
@functools.wraps(cls)
def wrapper(*args, **kwargs):
warnings.warn(message, SayvaiToolsDeprecatedWarning, stacklevel=2)
return cls(*args, **kwargs)

return wrapper

return decorator
7 changes: 5 additions & 2 deletions src/sayvai_tools/utils/voice/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
from elevenlabs.api.voice import Voice
from elevenlabs.simple import VOICES_CACHE, is_voice_id

# elevenlabs.set_api_key("431f452112cab175b80762e50e525c8f")

from sayvai_tools.utils.exception import deprecated

# from elevenlabs_audio_streaming import generate, voices
# from elevenlabs_audio_streaming.constant import VALID_MODELS


@deprecated(
message="VoiceOutputRun is deprecated and will be removed in future versions."
)
class ElevenlabsAudioStreaming:
def __init__(self, api_key) -> None:
self.api_key = api_key
Expand Down

0 comments on commit 77fc572

Please sign in to comment.