Skip to content

Commit

Permalink
Added example tool
Browse files Browse the repository at this point in the history
  • Loading branch information
whitead committed Oct 6, 2023
1 parent 8deac65 commit 411d0cf
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 2 deletions.
135 changes: 135 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# testing files generated
*.txt.json

*.ipynb
env
3 changes: 2 additions & 1 deletion sanclone/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .version import __version__
from .version import __version__
from .state import State
Binary file removed sanclone/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file removed sanclone/__pycache__/version.cpython-311.pyc
Binary file not shown.
5 changes: 5 additions & 0 deletions sanclone/state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from pydantic import BaseModel


class State(BaseModel):
pass
1 change: 1 addition & 0 deletions sanclone/tools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .echo import EchoTool
12 changes: 12 additions & 0 deletions sanclone/tools/echo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from langchain.tools import BaseTool
from ..state import State


class EchoTool(BaseTool):
name = "echo"
description = "An exampel tool that echoes what you input."
shared_state: State


def _run(self, query: str) -> str:
return query
Binary file not shown.
9 changes: 8 additions & 1 deletion tests/test_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@


def test_version():
assert sanclone.__version__
assert sanclone.__version__

def test_echo_tool():
from sanclone.tools import EchoTool
from sanclone import State
tool = EchoTool(shared_state=State())
assert tool.run("Hello") == "Hello"

0 comments on commit 411d0cf

Please sign in to comment.