Pre-built Agents
RAG Powered Agents
Chat Agent
Quick Start

Quick Start

Getting Started with AI-Horizon Chat Agent SDK

AI-Horizon's Chat Agent utilizes cutting-edge chatbot architecture, abstracting the intricacies of constructing an advanced LLM-powered chatbot. This empowers developers to prioritize data and prompt quality, along with the application's use case, rather than investing extensive time in piecing together different building blocks and indexes for the backend RAG pipeline.

The AI-Horizon Chat Agent seamlessly integrates all the essential components of a chatbot.

What are the different techniques and parameters available for passing to the ChatBot in AI-Horizon?

Techniques

TechniqueWhat is its function?
pdf_chatchat with the PDF documents
website_chatautomatically scraps the site content & one can chat with the site data
docx_chatchat with MS Word document
txt_chatchat with text files
youtube_chatchat with YouTube content that includes transcriptions
webpage_chatchat using webpage data automatically scraped from the webpage's content

Chat with PDF

Sample Code

import os
from <<package name>> import ChatBot
 
# Set your OpenAI API key
os.environ['OPENAI_API_KEY'] = 'sk-'
 
# Initialize the PDF Chatbot with the path to the PDF file
chatbot = ChatBot.pdf_chat(
    input_files=["PATH/TO/YOUR/PDF/FILE"],
)
 
# Ask a question related to the PDF content
response = chatbot.chat("Your query here")
 
# Print the chatbot's response
print(response.response)
 
# Access source nodes for additional information
for n, source in enumerate(response.source_nodes):
    print(f"Source {n+1}")
    print(source.text)

Types of Arguments

pdf_chat(
    input_dir: Optional[str] = None,
    input_files: Optional[List] = None,
    exclude_hidden: bool = True,
    filename_as_id: bool = True,
    recursive: bool = True,
    required_exts: Optional[List[str]] = None,
    system_prompt: str = None,
    query_wrapper_prompt: str = None,
    embed_model: Union[str, EmbedType] = "default",
    llm_params: dict = None,
    vector_store_params: dict = None,
    service_context_params: dict = None,
    chat_engine_params: dict = None,
    retriever_params: dict = None,
)

Types of Arguments

input_dir string
Use input_dir to parse all the .pdf files from a directory.

input_files list
Pass a list of .pdf file paths.

exclude_hidden boolean
Set to true to ignore hidden files when using input_dir.

filename_as_id boolean
Set to true to consider the filename as the ID for indexing the parsed data.

recursive boolean
Set to true to parse files from all subdirectories.

system_prompt string
System-wide prompt to be prepended to all input prompts, used to guide system “decision making”.

query_wrapper_prompt string
A specific wrapper instruction for passed-in input queries.

embed_model string
The default embed model is OpenAI text-embedding-ada-002. Default fallback model is bge from Hugging Face.

llm_params object
Default language model is OpenAI gpt-4-0125-preview. Default temperature is 0.

vector_store_params object
The default vector store is Embedded Weaviate DB.

service_context_params object
Default chunk_size is 1024 tokens. Default overlap is 20 tokens.

chat_engine_params object
Default is none.

retriever_params object
Default is none.

Integrations

Vector Store Integrations

AI-Horizon + Weaviate

Local Embedded

vector_store_params = {
    "vector_store_type": "WeaviateVectorStore",
    "index_name": "IndexName" // first letter should be capital
}

Cloud/Self hosted

vector_store_params = {
    "vector_store_type": "WeaviateVectorStore",
    "url": "https://sample..weaviate.network",
    "api_key": "DB_API_KEY",
    "index_name": "IndexName" # first letter should be capital
}

AI-Horizon + Supabase Pgvector

First, install vecs and supabase:

 
pip install vecs supabase
then use following parameters              
vector_store_params = {
    "vector_store_type": "SupabaseVectorStore",
    "postgres_connection_string": "postgresql://<user>:<password>@<host>:<port>/<db_name>",
    "collection_name":"base_demo",
  }

AI-Horizon + Qdrant Vector Store

First, install qdrant_client:

pip install -U qdrant_client

Local Embedded

client = qdrant_client.QdrantClient(
    location=":memory:" 
)
vector_store_params = {
    "vector_store_type": "QdrantVectorStore",
    "client": client,
    "collection_name": "base_demo",
}

Cloud/Self Hosted

client = qdrant_client.QdrantClient( 
    uri="http://<host>:<port>",
    api_key="<qdrant-api-key>"
)
vector_store_params = {
    "vector_store_type": "QdrantVectorStore",
    "client": client,
    "collection_name": "base_demo",
}

AI-Horizon + LanceDB Vector Store

First install LanceDB:

pip install -U lanced

Local Embedded

vector_store_params = {
    "vector_store_type": "LanceDBVectorStore",
    "uri": "/tmp/lancedb",
    "table_name": "base_demo"
}

AI-Horizon + Azure Cognitive Search

First, install the required packages:

pip install azure-search-documents==11.4.0 azure-identity

Cloud/Self hosted

To set up Azure Cognitive Search in a self-hosted environment, follow these steps:

  1. Import the necessary modules and classes:
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents import SearchClient
from azure.core.credentials import AzureKeyCredential
search_service_name = getpass.getpass("Azure Cognitive Search Service Name")
 
key = getpass.getpass("Azure Cognitive Search Key")
 
cognitive_search_credential = AzureKeyCredential(key)
 
service_endpoint = f"https://{search_service_name}.search.windows.net"
 
index_name = "quickstart"
 
index_client = SearchIndexClient(
    endpoint=service_endpoint,
    credential=cognitive_search_credential,
)
 
vector_store_params = {
    "vector_store_type": "CognitiveSearchVectorStore",
    "search_or_index_client": index_client),
    "index_name":index_name,
}

LLM Integration

For integrating OpenAI's language model (LLM) with AI-Horizon, follow these steps:

  1. Define the parameters for LLM integration:
llm_params = {
    "model": "gpt-4-0125-preview",
    "api_key": "sk-",
    "temperature": 0,
    "top_p": 0,
}

AI-Horizon + Azure OpenAI Integration

To integrate Azure's OpenAI model with AI-Horizon, follow these steps:

  1. Define the parameters for Azure OpenAI integration:
llm_params = {
    "model": "azure/gpt-35-turbo-16k",
    "api_base": "https://<deployment_namer>.azure.com/",
    "api_version": "2024-02-15-preview",
    "api_key": "<YOUR-API-KEY>",
    "max_retries": 1
}