### Evaluate RAG Application using eval.rag_checker (Python) Source: https://github.com/shiragannavar/testing-rag/blob/main/README.md This code snippet demonstrates how to evaluate a RAG application using the `eval.rag_checker` module. It initializes a RAG chain connected to AstraDB, starts a Phoenix session for tracing, runs the evaluation against ground truth data, generates RAGChecker input, and computes evaluation metrics. ```python import eval.rag_checker as rc chain = rc.get_default_rag_chain( astradb_collection='movies') project_name = f"my-eval-app.{time.time()}" ragchecker_file = "ragchecker_input.json" metrics_file_name = "metrics.json" ground_truth_file = "qa_output.csv" session = rc.start_phoenix_session(project_name=project_name) rc.run_eval(chain, ground_truth_file) rc.get_ragchecker_input(session=None, phoenix_project_name=project_name, ground_truth_file=ground_truth_file, ragchecker_file=ragchecker_file) rc.compute_ragchecker_metrics(input_file_name=ragchecker_file, metrics_file_name=metrics_file_name) ``` -------------------------------- ### Configure Environment Variables for RAG Application (.env) Source: https://github.com/shiragannavar/testing-rag/blob/main/README.md This snippet shows the required environment variables for configuring the RAG application. It includes placeholders for the OpenAI API key, AstraDB application token, and AstraDB API endpoint, which should be set in a `.env` file. ```env OPENAI_API_KEY=your_openai_api_key ASTRA_DB_APPLICATION_TOKEN=your_astradb_token ASTRA_DB_API_ENDPOINT=your_astradb_endpoint ``` -------------------------------- ### Display RAG Evaluation Metrics with Flask (Python) Source: https://github.com/shiragannavar/testing-rag/blob/main/README.md This Python code sets up a simple Flask web application to display RAG evaluation metrics. It reads metrics from a temporary JSON file and renders them using an HTML template. The Flask app is configured to run locally. ```python from flask import Flask, render_template import json # Flask application app = Flask(__name__) @app.route("/") def display_metrics(): # Read metrics from the temporary file with open(temp_file.name, "r") as f: metrics = json.load(f) return render_template("metrics.html", metrics=metrics) if __name__ == "__main__": # Ensure Flask app starts after the rag_results are processed app.run(debug=False) ``` -------------------------------- ### Project Dependencies List - Python Source: https://github.com/shiragannavar/testing-rag/blob/main/requirements.txt This snippet contains the complete list of Python packages and their specific versions required to run the project. This list is used by package managers like pip to ensure the correct environment is set up. ```Python accelerate==0.31.0 aiohappyeyeballs==2.4.3 aiohttp==3.10.10 aioitertools==0.12.0 aiosignal==1.3.1 aiosqlite==0.20.0 alembic==1.14.0 annotated-types==0.7.0 anthropic==0.29.2 anyio==4.6.2.post1 arize-phoenix==6.1.0 arize-phoenix-evals==0.17.5 arize-phoenix-otel==0.6.1 astrapy==1.5.2 async-timeout==4.0.3 attrs==24.2.0 Authlib==1.3.2 beautifulsoup4==4.12.3 blinker==1.9.0 blis==1.0.1 boto3==1.35.55 botocore==1.35.55 cachetools==5.5.0 catalogue==2.0.10 certifi==2024.8.30 cffi==1.17.1 charset-normalizer==3.4.0 click==8.1.7 cloudpathlib==0.20.0 confection==0.1.5 cryptography==44.0.0 cymem==2.0.8 dataclasses-json==0.6.7 Deprecated==1.2.15 deprecation==2.1.0 diskcache==5.6.3 distro==1.9.0 dnspython==2.7.0 en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl#sha256=1932429db727d4bff3deed6b34cfc05df17794f4a52eeb26cf8928f7c1a0fb85 exceptiongroup==1.2.2 fastapi==0.115.6 filelock==3.16.1 Flask==3.1.0 frozenlist==1.5.0 fsspec==2024.10.0 googleapis-common-protos==1.66.0 graphql-core==3.2.5 greenlet==3.1.1 grpc-interceptor==0.15.4 grpcio==1.68.1 h11==0.14.0 h2==4.1.0 hpack==4.0.0 httpcore==1.0.6 httpx==0.27.2 httpx-sse==0.4.0 huggingface-hub==0.26.2 hyperframe==6.0.1 idna==3.10 importlib_metadata==8.5.0 itsdangerous==2.2.0 Jinja2==3.1.4 jiter==0.7.0 jmespath==1.0.1 joblib==1.4.2 jsonpatch==1.33 jsonpointer==3.0.0 jsonschema==4.23.0 jsonschema-specifications==2024.10.1 langchain==0.3.7 langchain-astradb==0.5.2 langchain-community==0.3.5 langchain-core==0.3.21 langchain-openai==0.2.9 langchain-text-splitters==0.3.2 langcodes==3.4.1 langsmith==0.1.140 language_data==1.2.0 lightning-utilities==0.11.8 litellm==1.52.0 loguru==0.7.2 Mako==1.3.7 marisa-trie==1.2.1 markdown-it-py==3.0.0 MarkupSafe==3.0.2 marshmallow==3.23.1 mdurl==0.1.2 mpmath==1.3.0 multidict==6.1.0 murmurhash==1.0.10 mypy-extensions==1.0.0 networkx==3.4.2 ltk==3.9.1 numpy==1.26.4 openai==1.54.3 openinference-instrumentation==0.1.19 openinference-instrumentation-langchain==0.1.29 openinference-semantic-conventions==0.1.12 opentelemetry-api==1.28.2 opentelemetry-exporter-otlp==1.28.2 opentelemetry-exporter-otlp-proto-common==1.28.2 opentelemetry-exporter-otlp-proto-grpc==1.28.2 opentelemetry-exporter-otlp-proto-http==1.28.2 opentelemetry-instrumentation==0.49b2 opentelemetry-proto==1.28.2 opentelemetry-sdk==1.28.2 opentelemetry-semantic-conventions==0.49b2 orjson==3.10.11 packaging==24.1 pandas==2.2.3 plotly==5.24.1 preshed==3.0.9 propcache==0.2.0 protobuf==5.29.0 psutil==6.1.0 pulsar-client==3.5.0 pyarrow==18.1.0 pycparser==2.22 pydantic==2.9.2 pydantic-settings==2.6.1 pydantic_core==2.23.4 Pygments==2.18.0 pymongo==4.10.1 PyMuPDF==1.24.14 pymupdf4llm==0.0.17 PyPDF2==3.0.1 python-dateutil==2.9.0.post0 python-dotenv==1.0.1 python-multipart==0.0.19 pytorch-lightning==2.4.0 pytz==2024.2 PyYAML==6.0.2 ragchecker==0.1.9 rank-bm25==0.2.2 refchecker==0.2.14 referencing==0.35.1 regex==2024.11.6 requests==2.32.3 requests-toolbelt==1.0.0 rich==13.9.4 rpds-py==0.21.0 s3transfer==0.10.3 safetensors==0.4.5 scikit-learn==1.5.2 scipy==1.14.1 shellingham==1.5.4 six==1.16.0 smart-open==7.0.5 sniffio==1.3.1 soupsieve==2.6 spacy==3.8.2 spacy-legacy==3.0.12 spacy-loggers==1.0.5 SQLAlchemy==2.0.35 sqlean.py==3.47.0 srsly==2.4.8 starlette==0.41.3 strawberry-graphql==0.243.1 sympy==1.13.1 tenacity==9.0.0 thinc==8.3.2 threadpoolctl==3.5.0 tiktoken==0.8.0 tokenizers==0.20.3 toml==0.10.2 torch==2.5.1 torchmetrics==1.4.3 tqdm==4.67.0 transformers==4.46.2 typer==0.12.5 typing-inspect==0.9.0 typing_extensions==4.12.2 tzdata==2024.2 urllib3==2.2.3 uuid6==2024.7.10 uvicorn==0.32.1 wasabi==1.1.3 weasel==0.4.1 websockets==14.1 Werkzeug==3.1.3 wrapt==1.16.0 yarl==1.17.1 zipp==3.20.2 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.