mirror of
https://github.com/vxcontrol/langchaingo.git
synced 2026-08-24 21:31:28 -04:00
064f09155c
- 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.
Perplexity Completion Example with LangChain Go
Hello there! 👋 This example demonstrates how to use the Perplexity API with LangChain Go to generate creative text completions. Let's break down what this exciting little program does!
What This Example Does
-
Environment Setup:
- The program starts by loading environment variables from a
.envfile. This is where you'll store your Perplexity API key.
- The program starts by loading environment variables from a
-
Perplexity LLM Configuration:
- It sets up a Large Language Model (LLM) client using Perplexity's API, which is compatible with the OpenAI interface.
- The model used is "llama-3.1-sonar-large-128k-online", a powerful language model hosted by Perplexity.
-
Text Generation:
- The example prompts the model to "What is a prime number?"
-
Streaming Output:
- As the model generates text, it streams the output directly to the console, allowing you to see the response being created in real-time!
Cool Features
- Real-time Streaming: Watch as the AI crafts the response word by word!
- Customizable: You can easily modify the prompt or adjust generation parameters.
- Perplexity Integration: Showcases how to use Perplexity's powerful models with LangChain Go.
Running the Example
- Make sure you have a Perplexity API key and set it in your
.envfile asPERPLEXITY_API_KEY=your_api_key_here. - Run the program and watch as it generates a creative response about prime numbers right before your eyes!
You can read more about the perplexity API here: Perplexity API Documentation.
Enjoy exploring the creative possibilities with Perplexity and LangChain Go! 🚀🐹