agentscope.rag.llama_index_knowledge module
This module is an integration of the Llama index RAG into AgentScope package
- class LlamaIndexKnowledge(knowledge_id: str, emb_model: ModelWrapperBase | BaseEmbedding | None = None, knowledge_config: dict | None = None, model: ModelWrapperBase | None = None, persist_root: str | None = None, overwrite_index: bool | None = False, showprogress: bool | None = True, **kwargs: Any)[source]
Bases:
Knowledge
This class is a wrapper with the llama index RAG.
- retrieve(query: str, similarity_top_k: int | None = None, to_list_strs: bool = False, retriever: BaseRetriever | None = None, **kwargs: Any) list[Any] [source]
This is a basic retrieve function for knowledge. It will build a retriever on the fly and return the result of the query. :param query: query is expected to be a question in string :type query: str :param similarity_top_k: the number of most similar data returned by the
retriever.
- Parameters:
to_list_strs (bool) – whether returns the list of strings; if False, return NodeWithScore
retriever (BaseRetriever) – for advanced usage, user can pass their own retriever.
- Returns:
list of str or NodeWithScore
- Return type:
list[Any]
More advanced query processing can refer to https://docs.llamaindex.ai/en/stable/examples/query_transformations/query_transform_cookbook.html