llama-index readers azcognitive_search integration
Project description
Azure Cognitive Search Loader
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 import download_loader
AzCognitiveSearchReader = download_loader("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 import VectorStoreIndex, download_loader
from langchain.chains.conversation.memory import ConversationBufferMemory
from langchain.agents import Tool, AgentExecutor, load_tools, initialize_agent
AzCognitiveSearchReader = download_loader("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 and/or subsequently used as a Tool in a LangChain Agent. See here for examples.
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
Close
Hashes for llama_index_readers_azcognitive_search-0.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e36b8510ae7e70fccc1ba464f7ab69485de5f32eb32bb0c62c42f995eac988e4 |
|
MD5 | 213f0a4bf2b8591b5ea5c7b9a286790b |
|
BLAKE2b-256 | 75ed3d1184679e2fa55dda09f352041ccd1c434adfc08039b142877669d6f1b0 |
Close
Hashes for llama_index_readers_azcognitive_search-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b0f91e91f97dbe4a6a2e1a82451686c67d3f369fc01c8558d777a359db6f5f7 |
|
MD5 | cadfd8fe3c8ac6642c2168efef25916c |
|
BLAKE2b-256 | 633994264877e4a38bc6aff26425523adc3846647033b1d2efd5a94edbbc5281 |