This commit is contained in:
seehi 2024-03-08 21:50:38 +08:00
parent 451cbd7e46
commit 6a388b53f1
16 changed files with 19 additions and 9 deletions

View file

@ -1,4 +1,5 @@
"""RAG pipeline"""
import asyncio
from pydantic import BaseModel

View file

@ -1,4 +1,5 @@
"""Agent with RAG search"""
"""Agent with RAG search."""
import asyncio
from examples.rag_pipeline import DOC_PATH, QUESTION
@ -8,7 +9,8 @@ from metagpt.roles import Sales
async def search():
"""Agent with RAG search"""
"""Agent with RAG search."""
store = SimpleEngine.from_docs(input_files=[DOC_PATH])
role = Sales(profile="Sales", store=store)
result = await role.run(QUESTION)

View file

@ -1,6 +1,5 @@
"""Engines init"""
__all__ = ["SimpleEngine"]
from metagpt.rag.engines.simple import SimpleEngine
__all__ = ["SimpleEngine"]

View file

@ -1,6 +1,5 @@
"""Simple Engine."""
from typing import Optional
from llama_index.core import SimpleDirectoryReader, VectorStoreIndex

View file

@ -1,4 +1,5 @@
"""RAG factories"""
from metagpt.rag.factories.retriever import get_retriever
from metagpt.rag.factories.ranker import get_rankers
from metagpt.rag.factories.embedding import get_rag_embedding

View file

@ -1,4 +1,5 @@
"""Base Factory."""
from typing import Any, Callable

View file

@ -1,4 +1,5 @@
"""RAG Embedding Factory."""
from llama_index.core.embeddings import BaseEmbedding
from llama_index.embeddings.azure_openai import AzureOpenAIEmbedding
from llama_index.embeddings.openai import OpenAIEmbedding

View file

@ -1,4 +1,5 @@
"""RAG Index Factory."""
import chromadb
from llama_index.core import StorageContext, VectorStoreIndex, load_index_from_storage
from llama_index.core.embeddings import BaseEmbedding

View file

@ -1,4 +1,5 @@
"""RAG Interfaces."""
from typing import Any, Protocol

View file

@ -1,4 +1,5 @@
"""RAG LLM."""
from typing import Any
from llama_index.core.llms import (

View file

@ -1,4 +1,4 @@
"""Retrievers init"""
"""Retrievers init."""
from metagpt.rag.retrievers.hybrid_retriever import SimpleHybridRetriever

View file

@ -1,6 +1,5 @@
"""Base retriever."""
from abc import abstractmethod
from llama_index.core.retrievers import BaseRetriever

View file

@ -1,4 +1,5 @@
"""BM25 retriever."""
from llama_index.core.schema import BaseNode
from llama_index.retrievers.bm25 import BM25Retriever
from rank_bm25 import BM25Okapi

View file

@ -1,10 +1,11 @@
"""Chroma retriever."""
from llama_index.core.retrievers import VectorIndexRetriever
from llama_index.core.schema import BaseNode
class ChromaRetriever(VectorIndexRetriever):
"""FAISS retriever."""
"""Chroma retriever."""
def add_nodes(self, nodes: list[BaseNode], **kwargs):
"""Support add nodes"""

View file

@ -1,4 +1,5 @@
"""FAISS retriever."""
from llama_index.core.retrievers import VectorIndexRetriever
from llama_index.core.schema import BaseNode

View file

@ -1,4 +1,5 @@
"""Hybrid retriever."""
import copy
from llama_index.core.schema import BaseNode, QueryType