Skip to content

Commit

Permalink
Feature/fix broken build (#286)
Browse files Browse the repository at this point in the history
* fix pip command quotes

* fix pip command quotes

* fix default

* tweaks

* fix broken docker build

* fix the docker build
  • Loading branch information
emrgnt-cmplxty committed Apr 10, 2024
1 parent 8d4bb83 commit 6a1786e
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 41 deletions.
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COPY pyproject.toml poetry.lock* /app/
RUN pip install poetry keyring

# Export dependencies to requirements.txt
RUN poetry export --without-hashes --format=requirements.txt --output=requirements.txt -E eval -E parsing
RUN poetry export --without-hashes --format=requirements.txt --output=requirements.txt -E eval -E sentence_transformers

# Install dependencies from requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
Expand All @@ -22,6 +22,11 @@ RUN pip install gunicorn uvicorn
# Copy the rest of the application code
COPY . /app

# Set the default configuration option
ENV CONFIG_OPTION=default

# Expose the port
EXPOSE 8000

CMD ["gunicorn", "r2r.examples.servers.basic_pipeline:app", "--bind", "0.0.0.0:8000", "--workers", "2", "--threads", "8", "--timeout", "0", "--worker-class", "uvicorn.workers.UvicornWorker"]
# Set the command to run the application with Gunicorn
CMD ["sh", "-c", "gunicorn \"r2r.examples.servers.basic_pipeline:create_app('$CONFIG_OPTION')\" --bind 0.0.0.0:8000 --workers 2 --threads 8 --timeout 0 --worker-class uvicorn.workers.UvicornWorker"]
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Note - the example above uses [SciPhi Cloud](https://app.sciphi.ai) to pair with

```bash
# use the `'r2r[all]'` to download all required deps
pip install 'r2r[parsing,eval]'
pip install 'r2r[eval]'

# setup env
export OPENAI_API_KEY=sk-...
Expand All @@ -65,8 +65,11 @@ export LOCAL_DB_PATH=local.sqlite
```bash
docker pull emrgntcmplxty/r2r:latest

# Place your secrets in `.env`
docker run -d --name r2r_container -p 8000:8000 --env-file .env r2r
# Choose from CONFIG_OPTION in {`default`, `local_ollama`}
# For cloud deployment, select `default` and place your secrets in `.env`
# For local deployment, select `local_ollama`
docker run -d --name r2r_container -p 8000:8000 -e CONFIG_OPTION=local_ollama --env-file .env emrgntcmplxty/r2r:latest

```

## Basic Example
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/development/full-install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ To install poetry, visit the [official Poetry website](https://python-poetry.org
```bash
# See pyproject.toml for available extras
# use "all" to include every optional dependency
poetry install -E parsing -E eval
poetry install -E eval
```

##### Configure Environment Variables:
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/getting-started/basic-example.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This example demonstrates setting up a local server using the R2R framework to h

```bash
# use the `'r2r[all]'` to download all required deps
pip install 'r2r[parsing,eval]'
pip install 'r2r[eval]'

export OPENAI_API_KEY="replace with your openai key"
export LOCAL_DB_PATH=local.sqlite
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/getting-started/quick-install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Install R2R swiftly using `pip` to get started with minimal setup. This method w

```bash
# `'r2r[all]'` to download all optional deps
pip install 'r2r[parsing,eval]'
pip install 'r2r[eval]'

# setup env
export OPENAI_API_KEY=sk-...
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/tutorials/local_rag.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Next, let's install R2R itself. We'll use pip to manage our Python dependencies.

```bash
pip install --upgrade pip
pip install 'r2r[eval,parsing,local_llm]'
pip install 'r2r[eval,local_llm]'
```

This will install R2R along with the dependencies needed to run local LLMs.
Expand Down
19 changes: 9 additions & 10 deletions poetry.lock

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

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "r2r"
version = "0.1.31"
version = "0.1.32"
description = "SciPhi R2R"
authors = ["Owen Colegrove <owen@sciphi.ai>"]
license = "MIT"
Expand All @@ -16,12 +16,14 @@ include = ["config.json"]
python = ">=3.9,<3.13"

# Required dependencies
bs4= "^0.0.2"
fastapi = "^0.109.2"
fire = "^0.5.0"
gunicorn = "^21.2.0"
litellm = "^1.34.0"
openai = "^1.11.1"
pydantic = "^2.6.3"
pypdf = "^4.2.0"
python-dotenv = "^1.0.1"
python-multipart = "^0.0.9"
requests = "^2.31.0"
Expand All @@ -31,8 +33,6 @@ vecs = "^0.4.0"


# Optional dependencies
bs4 = {version = "^0.0.2", optional = true}
pypdf = {version = "^4.0.2", optional = true}
tiktoken = {version = "^0.5.2", optional = true}
datasets = {version = "^2.16.1", optional = true}
qdrant_client = {version = "^1.7.0", optional = true}
Expand All @@ -48,7 +48,6 @@ llama-cpp-python = {version = "^0.2.57", optional = true}
sentence-transformers = {version = "^2.6.1", optional = true}

[tool.poetry.extras]
parsing = ["bs4", "pypdf"]
embedding = ["tiktoken"]
streaming = ["datasets"]
qdrant = ["qdrant_client"]
Expand All @@ -59,6 +58,7 @@ eval = ["parea-ai"]
ionic = ["ionic-api-sdk"]
reducto = ["boto3"]
exa = ["exa-py"]
sentence_transformers = ["sentence-transformers"]
local_llm = ["llama-cpp-python", "sentence-transformers"]
all = ["bs4", "pypdf", "tiktoken", "datasets", "qdrant_client", "psycopg2-binary", "sentry-sdk", "parea-ai", "boto3", "exa-py", "llama-cpp-python"]

Expand Down
2 changes: 1 addition & 1 deletion r2r/core/adapters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ def adapt(self, data: bytes) -> list[str]:
page_text = "".join(
filter(lambda x: x in string.printable, page_text)
)
text += page_text
text += page_text + " "
return [text]
2 changes: 1 addition & 1 deletion r2r/eval/parea/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create_log(query: str, context: str, completion: str) -> Log:
self._create_log = create_log
except ImportError:
raise ImportError(
"Parea is not installed. Please install it using `pip install parea`."
"Parea is not installed. Please install it using `pip install parea-ai`."
)
if not os.getenv("OPENAI_API_KEY"):
raise ValueError(
Expand Down
25 changes: 13 additions & 12 deletions r2r/examples/servers/basic_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
"local_llama_cpp": os.path.join(configs_path, "local_llama_cpp.json"),
}


def create_app(config_name: str = "default"):
config_path = OPTIONS[config_name]

app = E2EPipelineFactory.create_pipeline(
config=R2RConfig.load_config(config_path)
)
return app


app = create_app()

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="R2R Pipeline")
parser.add_argument(
Expand All @@ -23,17 +35,6 @@
choices=OPTIONS.keys(),
help="Configuration option for the pipeline",
)
args = parser.parse_args()

config_path = OPTIONS[args.config]

# Creates a pipeline with the specified configuration
# This is the main entry point for the application
# The pipeline is built using the specified configuration file
# Read more about the configuration in the documentation [https://r2r-docs.sciphi.ai/core-features/factory]
app = E2EPipelineFactory.create_pipeline(
config=R2RConfig.load_config(config_path)
)
args, _ = parser.parse_known_args()

# Run the FastAPI application using Uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
7 changes: 4 additions & 3 deletions r2r/main/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,10 @@ async def rag_completion(
"run_id": str(rag_pipeline.pipeline_run_info["run_id"]),
"settings": query.settings.rag_settings.dict(),
}
background_tasks.add_task(
requests.post, f"{url}/eval", json=payload
)
if config.evals.get("frequency", 0.0) > 0.0:
background_tasks.add_task(
requests.post, f"{url}/eval", json=payload
)

return rag_completion

Expand Down
2 changes: 1 addition & 1 deletion r2r/pipelines/basic/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(
from r2r.eval import PareaEvalProvider
except ImportError:
raise ImportError(
"Parea is not installed. Please install it using `pip install parea`."
"Parea is not installed. Please install it using `pip install parea-ai`."
)
self.eval_provider = PareaEvalProvider(
provider,
Expand Down

0 comments on commit 6a1786e

Please sign in to comment.