Files
langchaingo/examples/redis-vectorstore-example
Dmitry Ng 064f09155c chore(deps): bump Go toolchain to 1.26.5 and fix vulnerable dependencies
- Raised the `go` directive from 1.24.1 to 1.26.5 to satisfy pgx/v5 and ollama's minimum Go version requirements and to pick up 15 patched standard library CVEs.
- Updated `pgx/v5`, `otel`/`otel/sdk`/`otlptracehttp`, `x/net`, and the AWS `eventstream` protocol package to their latest requested versions.
- Remediated govulncheck-flagged CVEs in `grpc`, `x/text`, `x/crypto`, `antchfx/xpath`, AWS SDK `bedrock*`/`s3` services, `etcd/server`, and `mongo-driver` v1/v2.
- Fixed ollama's `MainGPU` API type change (`int` -> `*int`) in `llms/ollama/options.go` without breaking the public `WithRunnerMainGPU` signature.
2026-08-04 13:57:26 +03:00
..

Redis Vector Store Example with LangChain Go

Hello there! 👋 Welcome to this exciting example that demonstrates how to use a Redis vector store with LangChain Go! Let's dive in and see what this cool code does! 🚀

What's This All About?

This example showcases how to:

  1. Set up a Redis vector store
  2. Add documents to the store
  3. Perform similarity searches
  4. Use a retrieval-based question-answering system

It's a fantastic way to learn about vector databases and how they can be used in AI applications!

The Magic Ingredients 🧙‍♂️

  • Redis: Our trusty vector store
  • Ollama: A local LLM server for embeddings and text generation
  • LangChain Go: The glue that brings it all together!

What Happens in the Code?

  1. Setting Up: We start by connecting to a Redis server and creating a new vector store index.

  2. Adding Data: We add a bunch of documents about cities to our vector store. Each document contains the city name and some metadata like population and area.

  3. Similarity Search: We perform a similarity search for "Tokyo" and get the 2 most similar results. This shows how vector stores can find related information quickly!

  4. Question Answering: Here's where it gets really cool! We set up a retrieval QA chain that:

    • Takes a question
    • Searches the vector store for relevant information
    • Passes that info to an LLM to generate an answer
  5. Embeddings: We use the Ollama server to generate embeddings for our documents and queries. This is what makes the similarity search possible!

Why This is Awesome 🌟

  • Fast Searches: Vector stores allow for lightning-fast similarity searches on large datasets.
  • Flexible Data: You can store any kind of data with associated metadata.
  • AI-Powered QA: By combining a vector store with an LLM, you can create powerful question-answering systems.

Ready to Try?

Make sure you have Redis running locally and an Ollama server set up with "gemma3:4b" and "gemma:2b" models. Then run the code and watch the magic happen!

Happy coding, and have fun exploring the world of vector stores and AI! 🎉🤖