Skip to main content

Objective

Objective is an engine for building modern, AI-native search.

Key features include:

  • Semantic, automatically understanding natural language queries, synonyms, typos, and multiple languages.
  • Hybrid, capable of exact matching and approximate matching in one API without requiring you to develop lexical / keyword matching as well as vector-based approximate nearest neighbors (ANN) engines.
  • Deep, surfacing relevant Highlights from different media by going inside the content and pulling out relevant bits.

Setup

To use Objective be sure to install the latest langchain-community with pip install -qU langchain-community.

Next you'll need to sign up and copy your API key.

import os
from langchain_community.document_loaders import TextLoader
from langchain_community.vectorstores import Objective
from langchain_text_splitters import CharacterTextSplitter
loader = TextLoader("../../how_to/state_of_the_union.txt")
documents = loader.load()
documents = CharacterTextSplitter().split_documents(documents)
# Note: You must either set an OBJECTIVE_KEY environment variable OR set your key here
objective_key = os.getenv("OBJECTIVE_KEY")
docsearch = Objective.from_documents(documents, None, api_key=objective_key)
index_id = docsearch.create_index()
print(f"Created index ID: {index_id}")
status=docsearch.index_status(index_id)
# status returns an object with UPLOADED, READY, ERROR, and PROCESSING document counts
if status["UPLOADED"] != status["READY"]:
print(f"Not all documents processed yet, please retry: {status}")
else:
print("Ready to proceed")
docsearch.search("Ketanji", search_type="doesnt matter", index_id=index_id)

Was this page helpful?


You can also leave detailed feedback on GitHub.