Guides

Enhancing Your Weaviate Workflow: Tracing with Langtrace

Darshit Suratwala

Darshit Suratwala

· 2 min read
langtrace weaviate integration cover art

In the era of LLMs, vector databases have become crucial in efficiently storing and querying high-dimensional data. Weaviate is an open-source vector database that stores both objects and vectors, allowing for the combination of vector search with structured filtering with the fault tolerance and scalability of a cloud-native database. To optimize and debug interactions with such a sophisticated system, tracing API calls is essential. This is where Langtrace, an SDK designed for tracing interactions with LLM (Large Language Models) and vector databases, comes into play.

Image

In this blog, we’ll explore how to integrate Langtrace into a project using Weaviate. This integration will help us monitor, trace, and debug API calls, providing valuable insights into the behavior of our vector database operations.

Prerequisites

  • Weaviate account with valid API key.
  • Langtrace project API key (can be either from Langtrace cloud or self-hosted)

Getting Started

For the sake of the demo, we will be using Weaviate Cloud with python SDK. If you wish to try different approaches for Weaviate, follow the official docs here.

Want a video tutorial? Watch it here!

Installing required dependencies

pip install weaviate-client langtrace-python-sdk

Create Collection

Copy the script on your local machine and export the following variables with actual values on your terminal

export WCS_DEMO_URL="<WEVIATE CLUSTER URL>"
export WCS_DEMO_RO_KEY="<WEAVIATE API KEY>"
export LANGTRACE_API_KEY="<Langtrace Project API key>"
export OPENAI_API_KEY="<OpenAI API KEY>"

Uncomment the `create()` & `insert()` methods call and run the script to create an example collection

python3 query_text.py

Query Weaviate

Once the collection is created, comment back the create & insert methods and uncomment query_data_near_text() to query the Weaviate data and observe traces. Run the script again.

You will now see traces being pushed to your Langtrace project!

Exploring additional Langtrace integrations? Take a look at our documentation.

Join our Discord community for the latest updates and engage with fellow enthusiasts. Should you encounter any challenges or queries, don’t hesitate to reach out — we’re here to assist. Start your journey of enhanced observability and optimization with Langtrace today.

Happy langTracing!

Darshit Suratwala

About Darshit Suratwala

Software Engineer