Saravanan666/pypi-org huggingface dataset:
Package: llama-index-packs-multi-tenancy-rag
Multi-Tenancy RAG PackCreate a Multi-Tenancy RAG using VectorStoreIndex.CLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackMultiTenancyRAGPack--download-dir./multitenancy_rag_packYou can then inspect the files at./multitenancy_rag_packand use them as a template for your own project.Code UsageYou can download the pack to a the./multitenancy_rag_packdirectory:fromllama_index.core.llama_packimportdownload_llama_pack# download and install dependenciesMultiTenancyRAGPack=download_llama_pack("MultiTenancyRAGPack","./multitenancy_rag_pack")# You can use any llama-hub loader to get documents and add them to index for a user!multitenancy_rag_pack=MultiTenancyRAGPack()multitenancy_rag_pack.add(documents,"<user>")From here, you can use the pack, or inspect and modify the pack in./multitenancy_rag_pack.Therun()function is a light wrapper aroundindex.as_query_engine().query().response=multitenancy_rag_pack.run("<user query>",user="<user>",similarity_top_k=2)You can also use modules individually.# Use the index directlyindex=multitenancy_rag_pack.indexquery_engine=index.as_query_engine(filters=MetadataFilters(filters=[ExactMatchFilter(key="user",value="<user>",)]))retriever=index.as_retriever(filters=MetadataFilters(filters=[ExactMatchFilter(key="user",value="<user>",)]))
Package: llama-index-packs-neo4j-query-engine
Neo4j Query Engine PackThis LlamaPack creates a Neo4j query engine, and executes itsqueryfunction. This pack offers the option of creating multiple types of query engines, namely:Knowledge graph vector-based entity retrieval (default if no query engine type option is provided)Knowledge graph keyword-based entity retrievalKnowledge graph hybrid entity retrievalRaw vector index retrievalCustom combo query engine (vector similarity + KG entity retrieval)KnowledgeGraphQueryEngineKnowledgeGraphRAGRetrieverCLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackNeo4jQueryEnginePack--download-dir./neo4j_packYou can then inspect the files at./neo4j_packand use them as a template for your own project!Code UsageYou can download the pack to a./neo4j_packdirectory:fromllama_index.core.llama_packimportdownload_llama_pack# download and install dependenciesNeo4jQueryEnginePack=download_llama_pack("Neo4jQueryEnginePack","./neo4j_pack")From here, you can use the pack, or inspect and modify the pack in./neo4j_pack.Then, you can set up the pack like so:# Load the docs (example of Paleo diet from Wikipedia)fromllama_indeximportdownload_loaderWikipediaReader=download_loader("WikipediaReader")loader=WikipediaReader()docs=loader.load_data(pages=["Paleolithic diet"],auto_suggest=False)print(f"Loaded{len(docs)}documents")# get Neo4j credentials (assume it's stored in credentials.json)withopen("credentials.json")asf:neo4j_connection_params=json.load(f)username=neo4j_connection_params["username"]password=neo4j_connection_params["password"]url=neo4j_connection_params["url"]database=neo4j_connection_params["database"]# create the packneo4j_pack=Neo4jQueryEnginePack(username=username,password=password,url=url,database=database,docs=docs)Optionally, you can pass in thequery_engine_typefromNeo4jQueryEngineTypeto constructNeo4jQueryEnginePack. Ifquery_engine_typeis not defined, it defaults to Knowledge Graph vector based entity retrieval.fromllama_index.packs.neo4j_query_engine.baseimportNeo4jQueryEngineType# create the packneo4j_pack=Neo4jQueryEnginePack(username=username,password=password,url=url,database=database,docs=docs,query_engine_type=Neo4jQueryEngineType.KG_HYBRID,)Neo4jQueryEnginePackis a enum defined as follows:classNeo4jQueryEngineType(str,Enum):"""Neo4j query engine type"""KG_KEYWORD="keyword"KG_HYBRID="hybrid"RAW_VECTOR="vector"RAW_VECTOR_KG_COMBO="vector_kg"KG_QE="KnowledgeGraphQueryEngine"KG_RAG_RETRIEVER="KnowledgeGraphRAGRetriever"Therun()function is a light wrapper aroundquery_engine.query(), see a sample query below.response=neo4j_pack.run("Tell me about the benefits of paleo diet.")You can also use modules individually.# call the query_engine.query()query_engine=neo4j_pack.query_engineresponse=query_engine.query("query_str")
Package: llama-index-packs-node-parser
Semantic Chunking Llama PackThis LlamaPack implements the semantic chunking algorithm first proposed by Greg Kamradt in hisFive Levels of Text Splittingtutorial.How it works:Split text into sentences.For each sentence, generate an embedding.Measure cosine distance between each pair of consecutive sentences.Get the 95% percentile cosine distance, set that as the threshold.Create a new chunk if the cosine distance of a sentence compared to prev. exceeds that threshold.CLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackLLMCompilerAgentPack--download-dir./llm_compiler_agent_packYou can then inspect the files at./llm_compiler_agent_packand use them as a template for your own project!Code UsageYou can download the pack to a directory.NOTE: You must specifyskip_load=True- the pack contains multiple files,
which makes it hard to load directly.We will show you how to import the agent from these files!
Package: llama-index-packs-node-parser-semantic-chunking
Semantic Chunking Llama PackThis LlamaPack implements the semantic chunking algorithm first proposed by Greg Kamradt in hisFive Levels of Text Splittingtutorial.How it works:Split text into sentences.For each sentence, generate an embedding.Measure cosine distance between each pair of consecutive sentences.Get the 95% percentile cosine distance, set that as the threshold.Create a new chunk if the cosine distance of a sentence compared to prev. exceeds that threshold.CLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackLLMCompilerAgentPack--download-dir./llm_compiler_agent_packYou can then inspect the files at./llm_compiler_agent_packand use them as a template for your own project!Code UsageYou can download the pack to a directory.NOTE: You must specifyskip_load=True- the pack contains multiple files,
which makes it hard to load directly.We will show you how to import the agent from these files!
Package: llama-index-packs-ollama-query-engine
Ollama Query Engine PackCreate a query engine using completely local by OllamaCLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackOllamaQueryEnginePack--download-dir./ollama_packYou can then inspect the files at./ollama_packand use them as a template for your own project.Code UsageYou can download the pack to a the./ollama_packdirectory:fromllama_index.core.llama_packimportdownload_llama_pack# download and install dependenciesOllamaQueryEnginePack=download_llama_pack("OllamaQueryEnginePack","./ollama_pack")# You can use any llama-hub loader to get documents!ollama_pack=OllamaQueryEnginePack(model="llama2",documents=documents)From here, you can use the pack, or inspect and modify the pack in./ollama_pack.Therun()function is a light wrapper aroundindex.as_query_engine().query().response=ollama_pack.run("What is the title of the book of John?")You can also use modules individually.# Use the llmllm=ollama_pack.llmresponse=llm.complete("What is Ollama?")# Use the index directlyindex=ollama_pack.indexquery_engine=index.as_query_engine()retriever=index.as_retriever()
Package: llama-index-packs-panel-chatbot
🦙 Panel ChatBot PackBuild a chatbot to talk to your Github repository.Powered by LlamaIndex, OpenAI ChatGPT andHoloViz Panel.💁‍♀️ ExplanationThis templateDownloads and indexes a Github repository using the thellama_indexGithubRepositoryReader. The default repository isholoviz/panel.Creates aVectorStoreIndexpowered chat engine that will retrieve context from that data to respond to each user query.Creates a PanelChatInterfaceUI that will stream each answer from the chat engine.🖥️ CLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexPython package:pipinstallllama-index
llamaindex-clidownload-llamapackPanelChatPack--download-dir./panel_chat_packYou can then inspect the files in thepanel_chat_packfolder and use them as a template for your own project!To run the app directly, use in your terminal:exportOPENAI_API_KEY="sk-..."exportGITHUB_TOKEN='...'panelserve./panel_chat_pack/base.pyAs an alternative topanel serve, you can runpython./panel_chat_pack/base.py🎓 Learn MoreGithubRepositoryReaderVectorStoreIndexPanel Chat ComponentsPanel Chat Examples👍 CreditsMarc Skov Madsenfor creating the templateSophia Yangfor creating the cute LLama image.📈 Potential ImprovementsImproved Multi-user supportLoading queue: Users should not be able to download the same repository at the same time.Service ContextEnable users to define the service context includingmodel,temperatureetc.Better loading experienceLet the chat assistant show (more fine-grained) status messages. And provide more status changesFocus on the streaming textThe streaming text is not always in focus. I believe its a matter of adjusting theauto_scroll_limitlimit.Fix minor CSS issuesSee theCSS_FIXES_TO_BE_UPSTREAMED_TO_PANELvariable in the codeRepo ManagerSupport using multiple repos. For example the full HoloViz suite
Package: llama-index-packs-query
RAG Fusion Pipeline Llama PackThis LlamaPack creates the RAG Fusion Query Pipeline, which runs multiple retrievers in parallel (with varying chunk sizes), and aggregates the results in the end with reciprocal rank fusion.You can run it out of the box, but we also encourage you to inspect the code to take a look at how ourQueryPipelinesyntax works. More details on query pipelines can be found here:https://docs.llamaindex.ai/en/stable/module_guides/querying/pipeline/root.html.Check out ournotebook guideas well.CLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackRAGFusionPipelinePack--download-dir./rag_fusion_pipeline_packYou can then inspect the files at./rag_fusion_pipeline_packand use them as a template for your own project!Code UsageYou can download the pack to a./rag_fusion_pipeline_packdirectory:fromllama_index.core.llama_packimportdownload_llama_pack# download and install dependenciesRAGFusionPipelinePack=download_llama_pack("RAGFusionPipelinePack","./rag_fusion_pipeline_pack")From here, you can use the pack, or inspect and modify the pack in./rag_fusion_pipeline_pack.Then, you can set up the pack like so:# create the packpack=RAGFusionPipelinePack(docs,llm=OpenAI(model="gpt-3.5-turbo"))Therun()function is a light wrapper aroundquery_pipeline.run(*args, **kwargs).response=pack.run(input="What did the author do during his time in YC?")You can also use modules individually.# get query pipeline directlypack.query_pipeline# get retrievers for each chunk sizepack.retrievers# get query engines for each chunk sizepack.query_engines
Package: llama-index-packs-ragatouille-retriever
RAGatouille Retriever PackRAGatouille is acool librarythat lets you use e.g. ColBERT and other SOTA retrieval models in your RAG pipeline. You can use it to either run inference on ColBERT, or use it to train/fine-tune models.This LlamaPack shows you an easy way to bundle RAGatouille into your RAG pipeline. We use RAGatouille to index a corpus of documents (by default using colbertv2.0), and then we combine it with LlamaIndex query modules to synthesize an answer with an LLM.A full notebook guide can be foundhere.CLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackRAGatouilleRetrieverPack--download-dir./ragatouille_packYou can then inspect the files at./and use them as a template for your own project!Code UsageYou can download the pack to a./ragatouille_packdirectory:fromllama_index.core.llama_packimportdownload_llama_pack# download and install dependenciesRAGatouilleRetrieverPack=download_llama_pack("RAGatouilleRetrieverPack","./ragatouille_pack")From here, you can use the pack, or inspect and modify the pack in./ragatouille_pack.Then, you can set up the pack like so:# create the packragatouille_pack=RAGatouilleRetrieverPack(docs,# List[Document]llm=OpenAI(model="gpt-3.5-turbo"),index_name="my_index",top_k=5,)Therun()function is a light wrapper aroundquery_engine.query.response=ragatouille_pack.run("How does ColBERTv2 compare to BERT")You can also use modules individually.fromllama_index.core.response.notebook_utilsimportdisplay_source_noderetriever=ragatouille_pack.get_modules()["retriever"]nodes=retriever.retrieve("How does ColBERTv2 compare with BERT?")fornodeinnodes:display_source_node(node)# try out the RAG module directlyRAG=ragatouille_pack.get_modules()["RAG"]results=RAG.search("How does ColBERTv2 compare with BERT?",index_name=index_name,k=4)results
Package: llama-index-packs-rag-cli-local
RAG Local CLI PackThis LlamaPack implements a fully local version of ourRAG CLI,
with Mistral (through Ollama) andBGE-M3.CLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackLocalRAGCLIPack--download-dir./local_rag_cli_packYou can then inspect the files at./local_rag_cli_packand use them as a template for your own project!Code UsageYou can download the pack to a directory.NOTE: You must specifyskip_load=True- the pack contains multiple files,
which makes it hard to load directly.We will show you how to import the agent from these files!fromllama_index.llama_packimportdownload_llama_pack# download and install dependenciesdownload_llama_pack("LocalRAGCLIPack","./local_rag_cli_pack",skip_load=True)From here, you can use the pack. The most straightforward way is through the CLI. You can directly run base.py, or run thesetup_cli.shscript.cdlocal_rag_cli_pack# option 1pythonbase.pyrag-h# option 2 - you may need sudo# default name is lcli_localsudoshsetup_cli.sh
lcli_localrag-hYou can also directly get modules from the pack.fromlocal_rag_cli_pack.baseimportLocalRAGCLIPackpack=LocalRAGCLIPack(verbose=True,llm_model_name="mistral",embed_model_name="BAAI/bge-m3")# will spin up the CLIpack.run()# get modulesrag_cli=pack.get_modules()["rag_cli"]rag_cli.cli()
Package: llama-index-packs-rag-evaluator
Retrieval-Augmented Generation (RAG) Evaluation PackGet benchmark scores on your own RAG pipeline (i.e.QueryEngine) on a RAG
dataset (i.e.,LabelledRagDataset). Specifically this pack takes in as input a
query engine and aLabelledRagDataset, which can also be downloaded fromllama-hub.CLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackRagEvaluatorPack--download-dir./rag_evaluator_packYou can then inspect the files at./rag_evaluator_packand use them as a template for your own project!Code UsageYou can download the pack to the./rag_evaluator_packdirectory through python
code as well. The sample script below demonstrates how to constructRagEvaluatorPackusing aLabelledRagDatasetdownloaded fromllama-huband a simple RAG pipeline
built off of its source documents.fromllama_index.core.llama_datasetimportdownload_llama_datasetfromllama_index.core.llama_packimportdownload_llama_packfromllama_indeximportVectorStoreIndex# download a LabelledRagDataset from llama-hubrag_dataset,documents=download_llama_dataset("PaulGrahamEssayDataset","./paul_graham")# build a basic RAG pipeline off of the source documentsindex=VectorStoreIndex.from_documents(documents=documents)query_engine=index.as_query_engine()# Time to benchmark/evaluate this RAG pipeline# Download and install dependenciesRagEvaluatorPack=download_llama_pack("RagEvaluatorPack","./rag_evaluator_pack")# construction requires a query_engine, a rag_dataset, and optionally a judge_llmrag_evaluator_pack=RagEvaluatorPack(query_engine=query_engine,rag_dataset=rag_dataset)# PERFORM EVALUATIONbenchmark_df=rag_evaluator_pack.run()# async arun() also supportedprint(benchmark_df)Output:rag                            base_rag
metrics
mean_correctness_score         4.511364
mean_relevancy_score           0.931818
mean_faithfulness_score        1.000000
mean_context_similarity_score  0.945952Note thatrag_evaluator_pack.run()will also save two files in the same directory
in which the pack was invoked:.
├──benchmark.csv(CSVformatofthebenchmarkscores)└──_evaluations.json(rawevaluationresultsforallexamples&predictions)
Package: llama-index-packs-redis-ingestion-pipeline
Redis Ingestion Pipeline PackThis LlamaPack creates aningestion pipeline, with both a cache and vector store backed by Redis.CLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackRedisIngestionPipelinePack--download-dir./redis_ingestion_packYou can then inspect the files at./redis_ingestion_packand use them as a template for your own project!Code UsageYou can download the pack to a./redis_ingestion_packdirectory:fromllama_index.core.llama_packimportdownload_llama_pack# download and install dependenciesRedisIngestionPipelinePack=download_llama_pack("RedisIngestionPipelinePack","./redis_ingestion_pack")From here, you can use the pack, or inspect and modify the pack in./redis_ingestion_pack.Then, you can set up the pack like so:fromllama_index.core.text_splitterimportSentenceSplitterfromllama_index.core.embeddingsimportOpenAIEmbeddingtransformations=[SentenceSplitter(),OpenAIEmbedding()]# create the packingest_pack=RedisIngestionPipelinePack(transformations,hostname="localhost",port=6379,cache_collection_name="ingest_cache",vector_collection_name="vector_store",)Therun()function is a light wrapper aroundpipeline.run().You can use this to ingest data and then create an index from the vector store.pipeline.run(documents)index=VectorStoreIndex.from_vector_store(inget_pack.vector_store)You can learn more about the ingestion pipeline at theLlamaIndex documentation.
Package: llama-index-packs-resume-screener
Resumer Screener PackThis LlamaPack loads a resume file, and review it against a user specified job description and screening criteria.CLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackResumeScreenerPack--download-dir./resume_screener_packYou can then inspect the files at./resume_screener_packand use them as a template for your own project!Code UsageYou can download the pack to a./resume_screener_packdirectory:fromllama_index.core.llama_packimportdownload_llama_pack# download and install dependenciesResumeScreenerPack=download_llama_pack("ResumeScreenerPack","./resume_screener_pack")From here, you can use the pack, or inspect and modify the pack in./resume_screener_pack.Then, you can set up the pack like so:# create the packresume_screener=ResumeScreenerPack(job_description="<general job description>",criteria=["<job criterion>","<another job criterion>"],)response=resume_screener.run(resume_path="resume.pdf")print(response.overall_decision)Theresponsewill be a pydantic model with the following schemaclassCriteriaDecision(BaseModel):"""The decision made based on a single criteria"""decision:Field(type=bool,description="The decision made based on the criteria")reasoning:Field(type=str,description="The reasoning behind the decision")classResumeScreenerDecision(BaseModel):"""The decision made by the resume screener"""criteria_decisions:Field(type=List[CriteriaDecision],description="The decisions made based on the criteria",)overall_reasoning:Field(type=str,description="The reasoning behind the overall decision")overall_decision:Field(type=bool,description="The overall decision made based on the criteria",)
Package: llama-index-packs-retry-engine-weaviate
Retry Query EngineThis LlamaPack inserts your data intoWeaviateand uses theRetry Query Enginefor your RAG application.CLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackWeaviateRetryEnginePack--download-dir./weaviate_packYou can then inspect the files at./weaviate_packand use them as a template for your own project.Code UsageYou can download the pack to a the./weaviate_packdirectory:fromllama_index.core.llama_packimportdownload_llama_pack# download and install dependenciesWeaviateRetryEnginePack=download_llama_pack("WeaviateRetryEnginePack","./weaviate_pack")From here, you can use the pack, or inspect and modify the pack in./weaviate_pack.Then, you can set up the pack like so:# setup pack argumentsfromllama_index.core.vector_stores.typesimportMetadataInfo,VectorStoreInfovector_store_info=VectorStoreInfo(content_info="brief biography of celebrities",metadata_info=[MetadataInfo(name="category",type="str",description=("Category of the celebrity, one of [Sports Entertainment, Business, Music]"),),],)importweaviateclient=weaviate.Client()nodes=[...]# create the packweaviate_pack=WeaviateRetryQueryEnginePack(collection_name="test",vector_store_info=vector_store_index,nodes=nodes,client=client,)Therun()function is a light wrapper aroundquery_engine.query().response=weaviate_pack.run("Tell me a bout a Music celebritiy.")You can also use modules individually.# use the retrieverretriever=weaviate_pack.retrievernodes=retriever.retrieve("query_str")# use the query enginequery_engine=weaviate_pack.query_engineresponse=query_engine.query("query_str")
Package: llama-index-packs-self-discover
Self-Discover LlamaPackThis LlamaPack implementsSelf-Discover: Large Language Models Self-Compose Reasoning Structurespaper.It has two stages for the given task:STAGE-1:a. SELECT: Selects subset of reasoning Modules.b. ADAPT: Adapts selected reasoning modules to the task.c. IMPLEMENT: It gives reasoning structure for the task.STAGE-2: Uses the generated reasoning structure for the task to generate an answer.The implementation is inspired from thecodebaseCLI UsageYou can download llamapacks directly usingllamaindex-cli, which comes installed with thellama-indexpython package:llamaindex-clidownload-llamapackSelfDiscoverPack--download-dir./self_discover_packYou can then inspect the files at./self_discover_packand use them as a template for your own project!Code UsageThere are two ways using LlamaPack:Dodownload_llama_packto load the Self-Discover LlamaPack.Directly useSelfDiscoverPackUsingdownload_llama_packfromllama_index.llama_packimportdownload_llama_pack# download and install dependenciesSelfDiscoverPack=download_llama_pack("SelfDiscoverPack","./self_discover_pack")self_discover_pack=SelfDiscoverPack(verbose=True,llm=llm)Directly useSelfRAGPackfromllama_index.packs.self_discoverimportSelfDiscoverPackself_discover_pack=SelfRAGPack(llm=llm,verbose=True)The run() function serves as a concise wrapper that implements the logic outlined in the "self-discover" paper, applying it to a sample task as illustrated below.Emma needs to prepare 50 invitations for her upcoming birthday party. She can handwrite 10 invitations in an hour. After working for 2 hours, she takes a break for 30 minutes. If she resumes writing at the same pace, how long will it take her to complete all 50 invitations?output=pack.run("<task>")