Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add py r2r #896

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion py/core/main/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
VectorSearchSettings,
)
from fastapi import UploadFile
from sdk.client import R2RClient

from .assembly.builder import R2RBuilder
from .assembly.config import R2RConfig
Expand All @@ -43,6 +42,7 @@ def __init__(
self.base_url = base_url

if self.client_mode:
from sdk.client import R2RClient
self.client = R2RClient(base_url)
self.app = None
else:
Expand Down
27 changes: 13 additions & 14 deletions poetry.lock → py/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

127 changes: 127 additions & 0 deletions py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
[build-system]
requires = ["poetry-core", "setuptools", "wheel"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "r2r"
readme = "../README.md"
version = "0.3.0"
description = "SciPhi R2R"
authors = ["Owen Colegrove <owen@sciphi.ai>"]
license = "MIT"
include = ["r2r.toml", "compose.yaml", "compose.neo4j.yaml", "compose.ollama.yaml", "compose.postgres.yaml", "pyproject.toml"]
packages = [
{ include = "r2r", from = "." },
{ include = "core", from = "." },
{ include = "sdk", from = "." },
]

[tool.poetry.dependencies]
# Python Versions
python = ">=3.9,<3.13"

httpx = "^0.27.0"
nest-asyncio = "^1.6.0"
fastapi = "^0.109.2"

# Core dependencies (optional)
openai = { version = "^1.11.1" }

pydantic = { extras = ["email"], version = "^2.8.2", optional = true }
python-multipart = { version = "^0.0.9", optional = true }
fire = { version = "^0.5.0", optional = true }
gunicorn = { version = "^21.2.0", optional = true }
requests = { version = "^2.31.0", optional = true }
types-requests = { version = "^2.31.0", optional = true }
uvicorn = { version = "^0.27.0.post1", optional = true }
aiosqlite = { version = "^0.20.0", optional = true }
asyncpg = { version = "^0.29.0", optional = true }
redis = { version = "^5.0.4", optional = true }
beautifulsoup4 = { version = "^4.12.3", optional = true }
openpyxl = { version = "^3.1.2", optional = true }
markdown = { version = "^3.6", optional = true }
pypdf = { version = "^4.2.0", optional = true }
python-pptx = { version = "^0.6.23", optional = true }
python-docx = { version = "^1.1.0", optional = true }
opencv-python = { version = "^4.10.0.82", optional = true }
moviepy = { version = "^1.0.3", optional = true }
vecs = { version = "^0.4.0", optional = true }
litellm = { version = "^1.42.3", optional = true }
fsspec = { version = "^2024.6.0", optional = true }
posthog = { version = "^3.5.0", optional = true }
sqlalchemy = { version = "^2.0.30", optional = true }
ollama = { version = "^0.3.1", optional = true }
neo4j = { version = "^5.21.0", optional = true }
passlib = { version = "^1.7.4", optional = true }
bcrypt = { version = "^4.1.3", optional = true }
pyjwt = { version = "^2.8.0", optional = true }
toml = { version = "^0.10.2", optional = true }
pyyaml = { version = "^6.0.1", optional = true }
poppler-utils = { version = "^0.1.0", optional = true }
psutil = { version = "^6.0.0", optional = true }
deepdiff = { version = "^7.0.1", optional = true }
graspologic = { version = "^3.4.1", optional = true }

[tool.poetry.extras]
core = [
"pydantic", "python-multipart", "fire", "gunicorn", "requests", "types-requests",
"uvicorn", "aiosqlite", "asyncpg", "redis", "beautifulsoup4", "openpyxl",
"markdown", "pypdf", "python-pptx", "python-docx", "vecs", "litellm", "openai",
"fsspec", "posthog", "sqlalchemy", "ollama", "neo4j", "passlib", "bcrypt",
"pyjwt", "toml", "pyyaml", "poppler-utils", "psutil", "deepdiff", "graspologic"
]
core-ingest-movies = ["opencv-python", "moviepy"]

[tool.poetry.group.dev.dependencies]
black = "^24.3.0"
codecov = "^2.1.13"
flake8 = "6.1.0"
isort = "5.12.0"
mypy = "^1.5.1"
pre-commit = "^2.9"
pytest = "^8.2.0"
pytest-asyncio = "^0.23.6"
pytest-dependency = "^0.6.0"
pytest-mock = "^3.14.0"
pytest-cov = "^5.0.0"
colorama = "^0.4.6"

[tool.poetry.scripts]
r2r = "core.cli.cli:main"

[tool.black]
line-length = 79
target-version = ['py39']
include = '\.pyi?$'
extend-exclude = '''
/(
# directories
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| build
| dist
)/
'''

[tool.mypy]
ignore_missing_imports = true
exclude = 'playground/.*|deprecated/.*|dump/.*|docs/source|vecs/*'

[[tool.mypy.overrides]]
module = "yaml"
ignore_missing_imports = true

[tool.pytest.ini_options]
asyncio_mode = "auto"
addopts = "--cov=r2r --cov-report=term-missing --cov-report=xml"
testpaths = [
"tests",
]
filterwarnings = [
"ignore::DeprecationWarning",
"ignore::pytest.PytestUnraisableExceptionWarning",
]
16 changes: 16 additions & 0 deletions py/r2r/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from sdk import *

__all__ = [
# R2R SDK
"R2RAsyncClient",
"R2RClient",
]

try:
from core import *
import core
__all__ += core.__all__
except ImportError:
# Core dependencies not installed
pass

4 changes: 0 additions & 4 deletions py/sdk/retrieval.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from typing import AsyncGenerator, Optional, Union

from core.base import VectorSearchSettings
from core.base.api.models import RAGResponse, SearchResponse

from .models import (
GenerationConfig,
KGSearchSettings,
Expand All @@ -12,7 +9,6 @@
VectorSearchSettings,
)


class RetrievalMethods:
@staticmethod
async def search(
Expand Down
Loading