diff --git a/docs/examples/node_postprocessor/JinaRerank.ipynb b/docs/examples/node_postprocessor/JinaRerank.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..5925382fc8e08074c0322059628761235d7ff6ed --- /dev/null +++ b/docs/examples/node_postprocessor/JinaRerank.ipynb @@ -0,0 +1,325 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<a href=\"https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/examples/node_postprocessor/CohereRerank.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Jina Rerank" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If you're opening this Notebook on colab, you will probably need to install LlamaIndex 🦙." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!pip install llama-index-postprocessor-jinaai-rerank\n", + "!pip install llama-index-embeddings-jinaai\n", + "!pip install llama-index" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "from llama_index.core import (\n", + " VectorStoreIndex,\n", + " SimpleDirectoryReader,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from llama_index.embeddings.jinaai import JinaEmbedding\n", + "\n", + "api_key = os.environ[\"JINA_API_KEY\"]\n", + "jina_embeddings = JinaEmbedding(api_key=api_key)\n", + "\n", + "# load documents\n", + "import requests\n", + "\n", + "url = \"https://niketeam-asset-download.nike.net/catalogs/2024/2024_Nike%20Kids_02_09_24.pdf?cb=09302022\"\n", + "response = requests.get(url)\n", + "with open(\"Nike_Catalog.pdf\", \"wb\") as f:\n", + " f.write(response.content)\n", + "reader = SimpleDirectoryReader(input_files=[\"Nike_Catalog.pdf\"])\n", + "documents = reader.load_data()\n", + "\n", + "# build index\n", + "index = VectorStoreIndex.from_documents(\n", + " documents=documents, embed_model=jina_embeddings\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Retrieve top 10 most relevant nodes, without using a reranker" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "query_engine = index.as_query_engine(similarity_top_k=10)\n", + "response = query_engine.query(\n", + " \"What is the best jersey by Nike in terms of fabric?\",\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "56\n", + "Sustainable MaterialsNIKE KIDS SOCCER – GOALKEEPER\n", + "KIDS NIKE DRY LS US PARK IV GK JERSEY \n", + "CJ6073 $42.00\n", + "SIZES: XS, S, M, L, XL\n", + "FABRIC: 100% polyester.\n", + "OFFER DATE: 04/01/20\n", + "END DATE: 12/31/25\n", + "Goal keepers jersey with graphic print on sleeves and across upper back panel, mesh back for breathability, \n", + "slim fit with soft hand feel, shoulder seams rolled forward for better graphic visibility, straight seam across \n", + "back, mesh back for breathability – gameday graphic print inspired by retro campos gk design . \n", + "Body width: 16.3\", Body length: 22\" (size medium).\n", + "010 Black/White/(White) 012 Wolf Grey/White/(Black) 702 Volt/White/(Black)\n", + "KIDS NIKE DRY PARK III SHORT \n", + "BV6866 $20.00\n", + "SIZES: XS, S, M, L, XL\n", + "FABRIC: 100% polyester.\n", + "OFFER DATE: 04/01/20\n", + "END DATE: 12/31/25\n", + "Dri-FIT angled side seam short (slim fit) with soft hand feel updated fit for better mobility/comfort . \n", + "Hip width: 16.9\", Inseam length: 7\" (size medium).\n", + "010 Black/White/(White) 012 Wolf Grey/Black/(Black) 702 Volt/(Black)\n", + "NIKE ACADEMY OTC SOCK (UNISEX) \n", + "SX5728 $12.00\n", + "Sold in prepacks of 6.\n", + "SIZES: XS, S, M, L, XL\n", + "FABRIC: 93% nylon/6% polyester/1% spandex.\n", + "OFFER DATE: 01/01/17\n", + "END DATE: 12/31/23\n", + "Game day sock with fold-over cuff, articulated foot specific footbed for superior fit and contrast Swoosh \n", + "design trademark at ankle. Sold in prepacks of 6.\n", + "010 Black/(White) 018 Wolf Grey/(Black) 702 Volt/(Black)\n", + "Sustainable Materials 0.8641328028479249\n", + "\n", + "\n", + "NIKE KIDS SOCCER – STOCK42\n", + "Sustainable Materials\n", + "KIDS NIKE DRI-FIT US SS \n", + "CHALLENGE IV JERSEY\n", + "DH8368 $42.00\n", + "SIZES: XS, S, M, L, XL\n", + "FABRIC: 100% polyester.\n", + "OFFER DATE: 01/01/22\n", + "END DATE: 12/31/23\n", + "The Nike Dri-FIT Challenge IV Jersey brings subtle style and modern performance to the field. Sweat-\n", + "wicking fabric helps keep you dry and comfortable from the first whistle to the last minute.\n", + "010 Black/Black/White/(White) 012 Wolf Grey/Wolf Grey/Black/(Black)\n", + "100 White/White/White/(Black) 341 Gorge Green/Gorge Green/White/(White)\n", + "419 College Navy/College Navy/White/(White) 448 Valor Blue/Valor Blue/White/(White)\n", + "480 Game Royal/Game Royal/White/(White) 657 University Red/University Red/White/(White)\n", + "692 Team Maroon/Team Maroon/White/(White) 702 Volt/Volt/Black/(Black)\n", + "891 Team Orange/Team Orange/Black/(Black)\n", + "NEW\n", + "KIDS NIKE DRI-FIT CHALLENGE V JERSEY \n", + "SS US\n", + "FD7427 $47.00\n", + "SIZES: XS, S, M, L, XL\n", + "FABRIC: 100% polyester.\n", + "OFFER DATE: 01/01/24\n", + "END DATE: 12/31/25\n", + "The Nike Dri-FIT Challenge Jersey V is designed to keep your players cool and comfortable through 90 \n", + "minutes and beyond. Mesh on the back and side panels offer breathability where athletes need it most. \n", + "Body and sleeves are a Nike Dri-FIT knit fabric that moves sweat away to help keep players dry. This top \n", + "is made with 100% recycled material. Side panel construction uses a more efficient pattern to help reduce \n", + "material waste. Slim fit for a tailored look and feel.\n", + "010 Black/White/(White) 012 Wolf Grey/Black/(Black) 100 White/Black/(Black)\n", + "341 Gorge Green/White/(White) 419 College Navy/White/(White) 448 Valor Blue/White/(White)\n", + "480 Game Royal/White/(White) 657 University Red/White/(White) 692 Team Maroon/White/(White)\n", + "702 Volt/Black/(Black) 891 Team Orange/Black/(Black)\n", + "BACK VIEW 0.863721033128725\n" + ] + } + ], + "source": [ + "print(response.source_nodes[0].text, response.source_nodes[0].score)\n", + "print(\"\\n\")\n", + "print(response.source_nodes[1].text, response.source_nodes[1].score)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Retrieve top 10 most relevant nodes, but then rerank using Jina Reranker" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "By employing a reranker model, the prompt can be given more relevant context. This will lead to a more accurate response by the LLM." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "from llama_index.postprocessor.jinaai_rerank import JinaRerank\n", + "\n", + "jina_rerank = JinaRerank(api_key=api_key, top_n=2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "query_engine = index.as_query_engine(\n", + " similarity_top_k=10, node_postprocessors=[jina_rerank]\n", + ")\n", + "response = query_engine.query(\n", + " \"What is the best jersey by Nike in terms of fabric?\",\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "NIKE KIDS SOCCER – STOCK41Sustainable Materials\n", + "Sustainable Materials\n", + "KIDS DRI-FIT ADV VAPOR IV JERSEY US SS\n", + "DR0837 $77.00\n", + "SIZES: XS, S, M, L, XL\n", + "FABRIC: 100% polyester.\n", + "OFFER DATE: 01/01/23\n", + "END DATE: 12/31/24\n", + "Step on to the field ready for fast-paced play in the Nike Dri-FIT ADV Vapor Jersey. Engineered for \n", + "optimal breathability, its moisture-wicking design helps keep you dry and cool under match-day pressure. \n", + "Lightweight fabric in a relaxed, easy fit combats cling so you can focus on being the first to the ball. Lower \n", + "insets line up perfectly with design details on the Nike Dri-FIT ADV Vapor IV Shorts to create an on-field \n", + "look worthy of pro-level play. \n", + "010 Black/Black/Black/(White) 100 White/White/White/(Black)\n", + "419 College Navy/College Navy/Game Royal/(White) 480 Game Royal/Game Royal/College Navy/(White)\n", + "657 University Red/University Red/Bright Crimson/(White)\n", + "BACK VIEW\n", + "GRAPHIC KNIT DETAIL\n", + "KIDS NIKE DRI-FIT US SS STRIKE III JERSEY\n", + "DR0913 $50.00\n", + "SIZES: XS, S, M, L, XL\n", + "FABRIC: 100% polyester.\n", + "OFFER DATE: 01/01/23\n", + "END DATE: 12/31/24\n", + "Take the field in match-ready style in the lightweight Nike Strike Jersey. A relaxed, easy fit ensures that \n", + "nothing comes between you and the ball, and sweat-wicking fabric works with breathable mesh to help \n", + "keep you cool and composed during fast-paced play. Ribbed insets stretch with you to let you move without \n", + "restrictions. Embroidered Swoosh design trademark. \n", + "010 Black/Black/Black/(White) 011 Black/Volt/Volt/(White)\n", + "012 Wolf Grey/Black/Black/(White) 100 White/White/White/(Black)\n", + "419 College Navy/College Navy/Game Royal/(White) 448 Valor Blue/College Navy/College Navy/(White)\n", + "480 Game Royal/College Navy/College Navy/(White) 657 University Red/Bright Crimson/Bright Crimson/(White)\n", + "GRAPHIC KNIT DETAIL 0.3603765070438385\n", + "\n", + "\n", + "NIKE KIDS SOCCER – STOCK45\n", + "Sustainable MaterialsKIDS NIKE DRI-FIT US LS TIEMPO\n", + "PREMIER II JERSEY\n", + "DH8407 $32.00\n", + "SIZES: XS, S, M, L, XL\n", + "FABRIC: 100% polyester.\n", + "OFFER DATE: 01/01/22\n", + "END DATE: 12/31/26\n", + "The Nike Dri-FIT Tiempo Premier II Jersey brings you the cool performance of sweat-wicking fabric and a \n", + "mesh back panel kick in when the game heats up.\n", + "010 Black/White/(White) 100 White/White/(Black) 419 College Navy/White/(White)\n", + "480 Game Royal/White/(White) 657 University Red/White/(White)\n", + "KIDS NIKE DRI-FIT US SS TIEMPO\n", + "PREMIER II JERSEY\n", + "DH8390 $27.00\n", + "SIZES: XS, S, M, L, XL\n", + "FABRIC: 100% polyester.\n", + "OFFER DATE: 01/01/22\n", + "END DATE: 12/31/26\n", + "The Nike Dri-FIT Tiempo Premier II Jersey brings you the cool performance of sweat-wicking fabric and a \n", + "mesh back panel kick in when the game heats up.\n", + "010 Black/White/(White) 012 Wolf Grey/Black/(Black) 100 White/White/(Black)\n", + "341 Gorge Green/White/(White) 419 College Navy/White/(White) 448 Valor Blue/White/(White)\n", + "480 Game Royal/White/(White) 547 Court Purple/White/(White) 616 Vivid Pink/Black/(Black)\n", + "657 University Red/White/(White) 692 Team Maroon/White/(White) 702 Volt/Black/(Black)\n", + "891 Team Orange/Black/(Black)\n", + "Sustainable Materials 0.35767972469329834\n" + ] + } + ], + "source": [ + "print(response.source_nodes[0].text, response.source_nodes[0].score)\n", + "print(\"\\n\")\n", + "print(response.source_nodes[1].text, response.source_nodes[1].score)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/.gitignore b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..990c18de229088f55c6c514fd0f2d49981d1b0e7 --- /dev/null +++ b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/.gitignore @@ -0,0 +1,153 @@ +llama_index/_static +.DS_Store +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +bin/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +etc/ +include/ +lib/ +lib64/ +parts/ +sdist/ +share/ +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/ +.ruff_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 +notebooks/ + +# 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/ +pyvenv.cfg + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# Jetbrains +.idea +modules/ +*.swp + +# VsCode +.vscode + +# pipenv +Pipfile +Pipfile.lock + +# pyright +pyrightconfig.json diff --git a/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/BUILD b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/BUILD new file mode 100644 index 0000000000000000000000000000000000000000..0896ca890d8bffd60a44fa824f8d57fecd73ee53 --- /dev/null +++ b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/BUILD @@ -0,0 +1,3 @@ +poetry_requirements( + name="poetry", +) diff --git a/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/Makefile b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..b9eab05aa370629a4a3de75df3ff64cd53887b68 --- /dev/null +++ b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/Makefile @@ -0,0 +1,17 @@ +GIT_ROOT ?= $(shell git rev-parse --show-toplevel) + +help: ## Show all Makefile targets. + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}' + +format: ## Run code autoformatters (black). + pre-commit install + git ls-files | xargs pre-commit run black --files + +lint: ## Run linters: pre-commit (black, ruff, codespell) and mypy + pre-commit install && git ls-files | xargs pre-commit run --show-diff-on-failure --files + +test: ## Run tests via pytest. + pytest tests + +watch-docs: ## Build and watch documentation. + sphinx-autobuild docs/ docs/_build/html --open-browser --watch $(GIT_ROOT)/llama_index/ diff --git a/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/README.md b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b54b329952969bcb83b8f34ae0de5997037a9322 --- /dev/null +++ b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/README.md @@ -0,0 +1,8 @@ +# LlamaIndex Postprocessor Integration: Jina AI Rerank + +Jina Rerank is based on [Jina Reranking](), which is a state-of-the-art reranking model in terms of + +1. Input context length - Jina Reranking is capable of accepting 8K-length input context +2. Reranking performance - Jina Reranking outperforms other models on Mean Reciprocal Rank (MRR) and hit-rate, as shown in these [benchmarks](). + +Please pip install llama-index-postprocessor-jine-rerank to install Jina Rerank package. diff --git a/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/llama_index/postprocessor/jinaai_rerank/BUILD b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/llama_index/postprocessor/jinaai_rerank/BUILD new file mode 100644 index 0000000000000000000000000000000000000000..db46e8d6c978c67e301dd6c47bee08c1b3fd141c --- /dev/null +++ b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/llama_index/postprocessor/jinaai_rerank/BUILD @@ -0,0 +1 @@ +python_sources() diff --git a/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/llama_index/postprocessor/jinaai_rerank/__init__.py b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/llama_index/postprocessor/jinaai_rerank/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..226bc9c47e1e6376e840f9e3e95741747f31d6bf --- /dev/null +++ b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/llama_index/postprocessor/jinaai_rerank/__init__.py @@ -0,0 +1,3 @@ +from llama_index.postprocessor.jinaai_rerank.base import JinaRerank + +__all__ = ["JinaRerank"] diff --git a/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/llama_index/postprocessor/jinaai_rerank/base.py b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/llama_index/postprocessor/jinaai_rerank/base.py new file mode 100644 index 0000000000000000000000000000000000000000..5590680fe7a24b72b1334278601e50223e858c6a --- /dev/null +++ b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/llama_index/postprocessor/jinaai_rerank/base.py @@ -0,0 +1,84 @@ +from typing import Any, List, Optional +import requests + +from llama_index.core.base.llms.generic_utils import get_from_param_or_env +from llama_index.core.bridge.pydantic import Field, PrivateAttr +from llama_index.core.callbacks import CBEventType, EventPayload +from llama_index.core.postprocessor.types import BaseNodePostprocessor +from llama_index.core.schema import NodeWithScore, QueryBundle + +API_URL = "https://api.jina.ai/v1/rerank" + + +class JinaRerank(BaseNodePostprocessor): + api_key: str = Field(default=None, description="The JinaAI API key.") + model: str = Field( + default="jina-reranker-v1-base-en", + description="The model to use when calling Jina AI API", + ) + + top_n: int = Field(description="Top N nodes to return.") + + _session: Any = PrivateAttr() + + def __init__( + self, + top_n: int = 2, + model: str = "jina-reranker-v1-base-en", + api_key: Optional[str] = None, + ): + super().__init__(top_n=top_n, model=model) + self.api_key = get_from_param_or_env("api_key", api_key, "JINAAI_API_KEY", "") + self.model = model + self._session = requests.Session() + self._session.headers.update( + {"Authorization": f"Bearer {api_key}", "Accept-Encoding": "identity"} + ) + + @classmethod + def class_name(cls) -> str: + return "JinaRerank" + + def _postprocess_nodes( + self, + nodes: List[NodeWithScore], + query_bundle: Optional[QueryBundle] = None, + ) -> List[NodeWithScore]: + if query_bundle is None: + raise ValueError("Missing query bundle in extra info.") + if len(nodes) == 0: + return [] + + with self.callback_manager.event( + CBEventType.RERANKING, + payload={ + EventPayload.NODES: nodes, + EventPayload.MODEL_NAME: self.model, + EventPayload.QUERY_STR: query_bundle.query_str, + EventPayload.TOP_K: self.top_n, + }, + ) as event: + texts = [node.node.get_content() for node in nodes] + resp = self._session.post( # type: ignore + API_URL, + json={ + "query": query_bundle.query_str, + "documents": texts, + "model": self.model, + "top_n": self.top_n, + }, + ).json() + if "results" not in resp: + raise RuntimeError(resp["detail"]) + + results = resp["results"] + + new_nodes = [] + for result in results: + new_node_with_score = NodeWithScore( + node=nodes[result["index"]].node, score=result["relevance_score"] + ) + new_nodes.append(new_node_with_score) + event.on_end(payload={EventPayload.NODES: new_nodes}) + + return new_nodes diff --git a/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/pyproject.toml b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..a036ea6e9d28c0b66f0ee9ee8bc949e3e49da1c1 --- /dev/null +++ b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/pyproject.toml @@ -0,0 +1,62 @@ +[build-system] +build-backend = "poetry.core.masonry.api" +requires = ["poetry-core"] + +[tool.codespell] +check-filenames = true +check-hidden = true +skip = "*.csv,*.html,*.json,*.jsonl,*.pdf,*.txt,*.ipynb" + +[tool.llamahub] +contains_example = false +import_path = "llama_index.postprocessor.jinaai_rerank" + +[tool.llamahub.class_authors] +JinaRerank = "JoanFM" + +[tool.mypy] +disallow_untyped_defs = true +exclude = ["_static", "build", "examples", "notebooks", "venv"] +ignore_missing_imports = true +python_version = "3.8" + +[tool.poetry] +authors = ["Joan Fontanals <joan.fontanals.martinez@jina.ai>"] +description = "llama-index postprocessor jinaai rerank integration" +exclude = ["**/BUILD"] +license = "MIT" +name = "llama-index-postprocessor-jinaai-rerank" +readme = "README.md" +version = "0.1.2" + +[tool.poetry.dependencies] +python = ">=3.8.1,<4.0" +llama-index-core = "^0.10.1" + +[tool.poetry.group.dev.dependencies] +ipython = "8.10.0" +jupyter = "^1.0.0" +mypy = "0.991" +pre-commit = "3.2.0" +pylint = "2.15.10" +pytest = "7.2.1" +pytest-mock = "3.11.1" +ruff = "0.0.292" +tree-sitter-languages = "^1.8.0" +types-Deprecated = ">=0.1.0" +types-PyYAML = "^6.0.12.12" +types-protobuf = "^4.24.0.4" +types-redis = "4.5.5.0" +types-requests = "2.28.11.8" +types-setuptools = "67.1.0.0" + +[tool.poetry.group.dev.dependencies.black] +extras = ["jupyter"] +version = "<=23.9.1,>=23.7.0" + +[tool.poetry.group.dev.dependencies.codespell] +extras = ["toml"] +version = ">=v2.2.6" + +[[tool.poetry.packages]] +include = "llama_index/" diff --git a/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/tests/BUILD b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/tests/BUILD new file mode 100644 index 0000000000000000000000000000000000000000..dabf212d7e7162849c24a733909ac4f645d75a31 --- /dev/null +++ b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/tests/BUILD @@ -0,0 +1 @@ +python_tests() diff --git a/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/tests/__init__.py b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/tests/test_postprocessor_jinaai_rerank.py b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/tests/test_postprocessor_jinaai_rerank.py new file mode 100644 index 0000000000000000000000000000000000000000..c0c7148d1e516a2f425847cbaacdfe4b9b335415 --- /dev/null +++ b/llama-index-integrations/postprocessor/llama-index-postprocessor-jinaai-rerank/tests/test_postprocessor_jinaai_rerank.py @@ -0,0 +1,7 @@ +from llama_index.core.postprocessor.types import BaseNodePostprocessor +from llama_index.postprocessor.jinaai_rerank import JinaRerank + + +def test_class(): + names_of_base_classes = [b.__name__ for b in JinaRerank.__mro__] + assert BaseNodePostprocessor.__name__ in names_of_base_classes