Files
langchaingo/examples/vertex-completion-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
..
2024-06-20 23:47:52 -04:00

Vertex AI Completion Example

Welcome to this cheerful example of using Google's Vertex AI with LangChain Go! 🎉

This example demonstrates how to use the Vertex AI API to generate text completions using LangChain Go. It's a simple and fun way to interact with Google's powerful language models!

What This Example Does

  1. Sets Up Vertex AI: The code configures a connection to Google's Vertex AI service using your GCP project details and credentials.

  2. Creates a Language Model: It initializes a language model (LLM) using the Vertex AI service.

  3. Generates Text: The example then uses this LLM to generate an answer to the question "Who was the second person to walk on the moon?"

  4. Prints the Result: Finally, it prints the generated answer to the console.

How to Run

Before running this example, make sure you've set the following environment variables:

  • VERTEX_PROJECT: Your Google Cloud Project ID
  • VERTEX_LOCATION: The GCP location (region) for Vertex AI (e.g., "us-central1")
  • VERTEX_CREDENTIALS: Path to your GCP service account credentials JSON file

Once you've set these up, just run the Go file, and watch the magic happen! 🚀

Why It's Cool

This example showcases how easy it is to tap into advanced AI capabilities using LangChain Go and Google's Vertex AI. Whether you're building a chatbot, a question-answering system, or any other AI-powered application, this code provides a great starting point!

Happy coding, and may your AI adventures be ever exciting! 🌟