Skip to main content

llama-index readers azcognitive_search integration

Project description

Azure Cognitive Search Loader

pip install llama-index-readers-azcognitive-search

The AzCognitiveSearchReader Loader returns a set of texts corresponding to documents retrieved from specific index of Azure Cognitive Search. The user initializes the loader with credentials (service name and key) and the index name.

Usage

Here's an example usage of the AzCognitiveSearchReader.

from llama_index.readers.azcognitive_search import AzCognitiveSearchReader

reader = AzCognitiveSearchReader(
    "<Azure_Cognitive_Search_NAME>",
    "<Azure_Cognitive_Search_KEY>",
    "<Index_name>",
)


query_sample = ""
documents = reader.load_data(
    query="<search_term>",
    content_field="<content_field_name>",
    filter="<azure_search_filter>",
)

Usage in combination with langchain

from llama_index.core import VectorStoreIndex, download_loader
from langchain.chains.conversation.memory import ConversationBufferMemory
from langchain.agents import Tool, AgentExecutor, load_tools, initialize_agent

from llama_index.readers.azcognitive_search import AzCognitiveSearchReader

az_loader = AzCognitiveSearchReader(
    COGNITIVE_SEARCH_SERVICE_NAME, COGNITIVE_SEARCH_KEY, INDEX_NAME
)

documents = az_loader.load_data(query, field_name)

index = VectorStoreIndex.from_documents(
    documents, service_context=service_context
)

tools = [
    Tool(
        name="Azure cognitive search index",
        func=lambda q: index.query(q),
        description=f"Useful when you want answer questions about the text on azure cognitive search.",
    ),
]
memory = ConversationBufferMemory(memory_key="chat_history")
agent_chain = initialize_agent(
    tools, llm, agent="zero-shot-react-description", memory=memory
)

result = agent_chain.run(input="How can I contact with my health insurance?")

This loader is designed to be used as a way to load data into LlamaIndex.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file llama_index_readers_azcognitive_search-0.4.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_readers_azcognitive_search-0.4.1.tar.gz
Algorithm Hash digest
SHA256 813d0d47efa2fa4aceb5eaeeb9699065671dc4daae1ea2a72dbc5062ae7bc022
MD5 c159652cf447bee9d3fef8d0b280e899
BLAKE2b-256 ff5b2d6257f2019665d993611472c1ba62ae8d3a254b4708e9ef3b0e2e4012fb

See more details on using hashes here.

File details

Details for the file llama_index_readers_azcognitive_search-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_readers_azcognitive_search-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2e2144228d32978b0220562a297172e602d35bd03dc43960fc294f59a6841a3
MD5 b6cdce3f837a0ba8d6b8e2e1db6ba853
BLAKE2b-256 349e6df955ece2d004eecbe77ac01f101a87d315da982b21c235c90c12a46f5f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page