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

File details

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

File metadata

File hashes

Hashes for llama_index_readers_azcognitive_search-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4ffb32f9927183a5b7c51fe5ec0f7c2484b792fdbea2d8bf9fd9f7bd75b6964b
MD5 d8e915526bcd5f85d18d71e8eafd2ff2
BLAKE2b-256 2b2cb1dfc853a970dbf5c3d46962853d86e44a7ae5cd3b537753ccfe93c189f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_readers_azcognitive_search-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0ef5d68156c62ad3cf908ba1918a8efa6d3375a2406f57333247fe94c0fc80d
MD5 fff52d2e94b76cd663a5f215d4538ee1
BLAKE2b-256 b60f228e608ffdd7f074044a8158ac6a0357be60fc21f910fdc17057d36bb66c

See more details on using hashes here.

Supported by

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