-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Sayvai-io/custom-tools
# Conflicts: # .gitignore # src/sayvai_tools/tools/audio/streaming.py
- Loading branch information
Showing
70 changed files
with
1,905 additions
and
498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: sayvai-tools | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.9", "3.10", "3.11"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
sudo make build | ||
pip install . | ||
python -m pip install flake8 pytest | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Test with pytest | ||
run: | | ||
pytest tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: https://github.com/psf/black | ||
rev: 22.10.0 | ||
hooks: | ||
- id: black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
clean: | ||
rm -rf build | ||
rm -rf dist | ||
rm -rf *.egg-info | ||
rm -rf src/sayvai_tools/__pycache__ | ||
rm -rf __pycache__ | ||
rm -rf src/sayvai_tools.egg-info | ||
|
||
build: | ||
apt-get update && apt-get install libasound-dev libportaudio2 libportaudiocpp0 portaudio19-dev -y | ||
|
||
install: | ||
pip install . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Sayvai-Tools | ||
|
||
## How to use | ||
--------------------------------------- | ||
|
||
## Installation | ||
### Install via git clone | ||
|
||
```bash | ||
$git clone https://github.com/Sayvai-io/custom-tools.git | ||
$cd sayvai-tools | ||
``` | ||
and | ||
```bash | ||
$pip install . | ||
``` | ||
### Install via pip | ||
```bash | ||
$pip install sayvai-tools | ||
``` | ||
### Install via pipenv | ||
```bash | ||
$pipenv install sayvai-tools | ||
``` | ||
|
||
## What is Sayvai-Tools? | ||
--------------------------------------- | ||
Sayvai-Tools is a collection of tools that we use at Sayvai.io to help us build our products. We are making these tools available to the public in hopes that they will help you build your products as well. These tools are meant for langchain developers and are not meant to be used by end users. | ||
|
||
# Documentation | ||
--------------------------------------- | ||
Documentation is available at https://sayvai-io.github.io/custom-tools/ | ||
|
||
|
||
1. [Sayvai-Tools](#sayvai-tools) | ||
2. [How to use](#how-to-use) | ||
3. [What is Sayvai-Tools?](#what-is-sayvai-tools) | ||
4. [Documentation](#documentation) | ||
5. [Installation](#installation) | ||
1. [Install via git clone](#install-via-git-clone) | ||
2. [Install via pip](#install-via-pip) | ||
3. [Install via pipenv](#install-via-pipenv) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#config file | ||
name = "sayvai_tools" | ||
version = "0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
elevenlabs~=0.2.24 | ||
langchain~=0.0.292 | ||
typing~=3.7.4.3 | ||
SQLAlchemy~=2.0.20 | ||
PyYAML~=6.0 | ||
google~=3.0.0 | ||
numpy~=1.23.3 | ||
pydub~=0.25.1 | ||
setuptools~=58.2.0 | ||
pre-commit~=3.5.0 | ||
pytest | ||
pyaudio | ||
pydub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,43 @@ | ||
from setuptools import setup, find_packages | ||
from setuptools import find_packages, setup | ||
|
||
core_requirements = [ | ||
'langchain', | ||
'langchain_experimental', | ||
'google-api-python-client', | ||
'openai', | ||
'SQLAlchemy', | ||
'elevenlabs==0.2.24', | ||
'google_auth_oauthlib', | ||
'google-auth-httplib2', | ||
'pyaudio', | ||
'pydub', | ||
'numpy', | ||
'google', | ||
'google-cloud-speech' | ||
"langchain", | ||
"langchain_experimental", | ||
"google-api-python-client", | ||
"openai", | ||
"tiktoken", | ||
"SQLAlchemy", | ||
"elevenlabs==0.2.24", | ||
"google_auth_oauthlib", | ||
"google-auth-httplib2", | ||
"numpy", | ||
"google", | ||
"google-cloud-speech", | ||
"cloud-sql-python-connector", | ||
"pg8000", | ||
"pinecone-client", | ||
"pgvector", | ||
"pandas", | ||
"openpyxl", | ||
"gspread==5.11.3", | ||
"pyaudio", | ||
"pydub", | ||
"oauth2client" | ||
] | ||
|
||
setup( | ||
name='sayvai_tools', | ||
version='0.0.1', | ||
description='Tools for the assistant', | ||
author='sayvai-io', | ||
name="sayvai_tools", | ||
version="0.0.1", | ||
description="Tools for the assistant", | ||
author="sayvai-io", | ||
package_dir={"": "src"}, | ||
packages=find_packages(where="src"), | ||
install_requires=core_requirements, | ||
extras_require={ | ||
'dev': [ | ||
'pytest', | ||
'pylint', | ||
"dev": [ | ||
"pytest", | ||
"pylint", | ||
], | ||
}, | ||
zip_safe=False | ||
zip_safe=False, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
__version__ = "0.0.2" | ||
__version__ = "0.0.1" | ||
__author__ = "sayvai-io" | ||
__author_email__ = "sanjaypranav@sayvai.io" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from sayvai_tools.tools.audio.streaming import VoiceOutputRun | ||
|
||
__all__ = [ "VoiceOutputRun"] | ||
__all__ = ["VoiceOutputRun"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from sayvai_tools.tools.calendar.tool import Calendar | ||
from sayvai_tools.tools.calendar.calendar_sql.tool import CalendarSql | ||
from sayvai_tools.tools.calendar.calendar import Calendar | ||
|
||
__all__ = ['Calendar'] | ||
__all__ = ["Calendar", "CalendarSql"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from sayvai_tools.tools.calendar.calendar.tool import Calendar | ||
|
||
__all__ = ["Calendar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from sayvai_tools.utils.google.gcalendar import GCalendar | ||
|
||
|
||
class Calendar: | ||
name = "calendar" | ||
description = "You can ask calendar tool to create an event for you." | ||
|
||
def __init__(self, scope: str, email: str, summary: str): | ||
self.scope = scope | ||
self.email = email | ||
self.summary = summary | ||
self.cal = GCalendar(scope=self.scope, email=self.email, summary=self.summary) | ||
|
||
def _run(self, date: str): | ||
return self.cal.book_slots(date) | ||
|
||
async def _arun(self, date: str): | ||
raise NotImplementedError("Calendar async not implemented") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from sayvai_tools.tools.calendar.calendar_sql.tool import CalendarSql | ||
|
||
__all__ = ["CalendarSql"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from sayvai_tools.utils.google.gcalendar import GCalendar | ||
from sqlalchemy import text | ||
|
||
|
||
class CalendarSql: | ||
name = "calendar_sql" | ||
description = "You can ask calendar_sql tool to create an event for you." | ||
|
||
def __init__(self, pool, scope: str, email: str, summary: str): | ||
self.pool = pool | ||
self.cursor = self.pool.connect() | ||
self.scope = scope | ||
self.email = email | ||
self.summary = summary | ||
self.cal = GCalendar(self.scope, email=self.email, summary=self.summary) | ||
|
||
def _run(self, details: str): | ||
start_time, end_time, phone, name = details.split("/") | ||
start_time = self.cal.parse_date(start_time) | ||
end_time = self.cal.parse_date(end_time) | ||
|
||
specific_date = start_time.date() | ||
date_string = specific_date.strftime("%Y-%m-%d") | ||
|
||
query = self.cursor.execute(text(f"""SELECT phone_number FROM patient_info;""")) | ||
phone_number = query.fetchall() | ||
phone_number = [i[0] for i in phone_number] | ||
result = self.cal.book_slots(details) | ||
if len(result) == 2 and result[0] == "Event created": | ||
msg, event_id = result[0], result[1] | ||
if details.split("/")[2] not in phone_number: | ||
query = self.cursor.execute( | ||
text( | ||
f"""INSERT INTO patient_info (name, phone_number, start_time, end_time, event_id, appointment_date) VALUES ('{name}', '{phone}' | ||
, '{start_time}', '{end_time}','{event_id}','{date_string}');""" | ||
) | ||
) | ||
# query.commit() | ||
else: | ||
query = self.cursor.execute( | ||
text( | ||
f"""UPDATE patient_info SET start_time = '{start_time}', end_time = '{end_time}', event_id = '{event_id}', appointment_date = '{date_string}' WHERE phone_number = '{phone}';""" | ||
) | ||
) | ||
# query.commit() | ||
|
||
return msg | ||
else: | ||
return result | ||
|
||
async def _arun(self, date: str): | ||
raise NotImplementedError("Calendar async not implemented") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
import datetime | ||
from sayvai_tools.utils.google.gcalendar import GCalendar | ||
|
||
from langchain.tools.base import BaseTool | ||
|
||
from sayvai_tools.utils.gcalendar import GCalendar | ||
|
||
|
||
class Calendar(): | ||
|
||
class Calendar: | ||
name = "calendar" | ||
description = ( | ||
"You can ask calendar tool to create an event for you." | ||
) | ||
description = "You can ask calendar tool to create an event for you." | ||
|
||
def __init__(self, scope: str): | ||
self.scope = scope | ||
self.cal = GCalendar(self.scope) | ||
|
||
def _run(self, date: str): | ||
cal = GCalendar() | ||
return cal.check_is_slot_available(date) | ||
|
||
async def _arun(self, date: str): | ||
return self.cal.book_slots(date) | ||
|
||
raise NotImplementedError("Calendar async not implemented") | ||
async def _arun(self, date: str): | ||
raise NotImplementedError("Calendar async not implemented") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from sayvai_tools.tools.calendar_block.tool import Block | ||
|
||
__all__ = ["Block"] |
Oops, something went wrong.