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.
Hugging Face LLM Example with LangChain Go
This example demonstrates how to use the LangChain Go library to interact with Hugging Face's language models. It's a simple and fun way to generate text using various models hosted on the Hugging Face platform.
What This Example Does
-
Sets up a Hugging Face LLM Client:
- The example shows how to create a client for Hugging Face's language models.
- It provides options to use a custom token and model or use default settings.
-
Generates Text:
- The script sends a prompt to the language model asking for a company name that makes colorful socks.
- It demonstrates how to use different generation options like specifying a model (in this case, "gpt2").
-
Handles Responses:
- The generated text is printed to the console.
- Any errors during the process are properly handled and logged.
Key Features
- Flexibility in Model Selection: You can easily switch between different Hugging Face models.
- Customizable Generation Options: The example shows how to use options like
WithModel, and comments out additional options likeWithTopK,WithTopP, andWithSeedfor further customization. - Error Handling: Demonstrates proper error checking and logging.
How to Use
- Ensure you have the necessary dependencies installed.
- Optionally, set up your Hugging Face API token as an environment variable.
- Run the script to see a generated company name for a colorful sock company!
This example is perfect for anyone looking to get started with LangChain Go and Hugging Face's language models. It's a springboard for more complex applications and experiments with different models and prompts. Have fun generating creative company names!