Files
langchaingo/examples/anthropic-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

Anthropic Completion Example

Hello there, fellow Go enthusiasts and AI adventurers! 👋 Welcome to this exciting example of using the Anthropic API with Go!

What's in this directory?

This directory contains a simple yet powerful example of how to use the Anthropic API to generate text completions using Go. Here's what you'll find:

  1. anthropic_completion_example.go: This is the main Go file that demonstrates how to use the Anthropic API. It's a great starting point for your AI-powered adventures!

What does the code do?

The anthropic_completion_example.go file showcases how to:

  • Initialize an Anthropic LLM (Language Model) client
  • Generate text completions using the Claude 3 Opus model
  • Stream the generated text in real-time

It even includes a fun prompt asking Claude to write a poem about Golang-powered AI systems! 🤖📝

How to use this example

  1. Make sure you have Go installed on your system.
  2. Set up your Anthropic API key as an environment variable.
  3. Run the example using go run anthropic_completion_example.go.
  4. Watch as the AI-generated poem streams to your console!

Dependencies

This project uses the fantastic langchaingo library to interact with the Anthropic API. It's a great tool for building AI-powered applications in Go!

What to expect

When you run the example, you'll see a poem about Golang-powered AI systems being generated and printed to your console in real-time. It's like watching an AI poet at work! 🎭

Have fun!

We hope this example inspires you to create amazing AI-powered applications using Go and Anthropic's powerful language models. Happy coding! 🚀🎉