Skip to main content

A vector similarity search engine for humans🥳

Project description

VSSLite

A vector similarity search engine for humans🥳

🎁 Install

$ pip install vsslite

✨ Features

VSSLite provides a user-friendly interface for langchain and sqlite-vss.

🧩 Start API server

$ export OPENAI_APIKEY="YOUR_API_KEY"
$ python -m vsslite

Or

import uvicorn
from vsslite import LangChainVSSLiteServer

app = LangChainVSSLiteServer(YOUR_API_KEY).app
uvicorn.run(app, host="127.0.0.1", port=8000)

Go http://127.0.0.1:8000/docs to know the details and try it out.

🔍 Search

from vsslite import LangChainVSSLiteClient

# Initialize
vss = LangChainVSSLiteClient()

# Add data with embeddings
vss.add("The difference between eel and conger eel is that eel is more expensive.")
vss.add("Red pandas are smaller than pandas, but when it comes to cuteness, there is no \"lesser\" about them.")
vss.add("There is no difference between \"Ohagi\" and \"Botamochi\" themselves; they are used interchangeably depending on the season.")

# Search
print(vss.search("fish", count=1))
print(vss.search("animal", count=1))
print(vss.search("food", count=1))

Now you can get these search results.

$ python run.py

[{'page_content': 'The difference between eel and conger eel is that eel is more expensive.', 'metadata': {'source': 'inline'}}]
[{'page_content': 'Red pandas are smaller than pandas, but when it comes to cuteness, there is no "lesser" about them.', 'metadata': {'source': 'inline'}}]
[{'page_content': 'There is no difference between "Ohagi" and "Botamochi" themselves; they are used interchangeably depending on the season.', 'metadata': {'source': 'inline'}}]

🔧 Data management (Add, Get, Update, Delete)

Helps CRUD.

# Add
id = vss.add("The difference between eel and conger eel is that eel is more expensive.")[0]
# Get
vss.get(id)
# Update
vss.update(id, "The difference between eel and conger eel is that eel is more expensive. Una-jiro is cheaper than both of them.")
# Delete
vss.delete(id)
# Delete all
vss.delete_all()

Upload data. Accept Text, PDF, CSV and JSON for now.

vss.upload("path/to/data.json")

🍻 Asynchronous

Use async methods when you use VSSLite in server apps.

await vss.aadd("~~~")
await vss.aupdate(id, "~~~")
await vss.aget(id)
await vss.adelete(id)
await vss.aupdate_all()
await vss.asearch("~~~")
await vss.aupload("~~~")

🧇 Namespace

VSSLite supports namespaces for dividing the set of documents to search or update.

vss = LangChainVSSLiteClient()

# Search product documents
vss.search("What is the difference between super size and ultra size?", namespace="product")
# Search company documents
vss.search("Who is the CTO of Unagiken?", namespace="company")

💬 Web UI

You can quickly launch a Q&A web service based on documents 🚅

Install dependency

$ pip install streamlit
$ pip install streamlit-chat

Make a script

This is an example for OpenAI terms of use (upload terms of use to VSSServer with namespace openai). Save this script as runui.py.

import asyncio
from vsslite.chat import (
    ChatUI,
    VSSQAFunction
)

# Setup QA function
openai_qa_func = VSSQAFunction(
    name="get_openai_terms_of_use",
    description="Get information about terms of use of OpenAI services including ChatGPT.",
    parameters={"type": "object", "properties": {}},
    namespace="openai",
    # answer_lang="Japanese",  # <- Uncomment if you want to get answer in Japanese
    verbose=True
)

# Start app
chatui = ChatUI(temperature=0.5, functions=[openai_qa_func])
asyncio.run(chatui.start())

Start UI

$ streamlit run runui.py

See https://docs.streamlit.io to know more about Streamlit.

🍪 Classic version (based on SQLite)

See v0.3.0 README

🥰 Special thanks

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

vsslite-0.5.2-py3-none-any.whl (17.1 kB view hashes)

Uploaded Python 3

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