⚠️ This is a fork of the original github.com/tmc/langchaingo repository.
⚡ Building applications with LLMs through composability, with Go! ⚡
Starting from release v0.1.13-update.1, this fork is now a full-fledged library that does not require any
replace
directives in your go.mod file. You can simply add it to your project with:go get github.com/vxcontrol/langchaingo@latest
This fork was created to incorporate functionality from open Pull Requests that haven't been merged into the original repository yet. You can view the list of accepted PRs in our v0.1.13-update.0 release and in the main-pull-requests branch.
Additionally, this repository contains custom improvements and enhancements related to langchaingo support, which will be published as releases. The original repository's state can be accessed in the main branch, which will be regularly updated with upstream changes.
This fork is primarily maintained for use in the PentAGI project, an autonomous AI Agents system for performing complex penetration testing tasks.
This repository follows a specific branching strategy to maintain both upstream compatibility and custom enhancements:
- main: Fully synchronized with upstream (
tmc/langchaingo
). Never force-pushed. - main-pull-requests: Contains merged PRs from upstream that haven't been officially merged. Rebased on
main
after synchronization (commit hashes will change). - main-vxcontrol: Default branch containing all current enhancements. Rebased on
main-pull-requests
(commit hashes will change). - release/v*: Created from
main-vxcontrol
for each release. These branches are stable and never force-pushed.
Release tags follow the format v0.1.13-update.1
, where:
v0.1.13
corresponds to the latest upstream release version-update.1
indicates our increment number (starting at 1 and incrementing with each new release)
Each new release cumulatively includes all changes from previous releases on top of the current upstream state, ensuring that you always get the complete set of enhancements when using a specific tag.
Important: When using this fork in your projects, always reference release tags rather than commit hashes. This ensures proper dependency resolution since branches like main-vxcontrol
undergo rebasing and their commit hashes change over time.
go get github.com/vxcontrol/langchaingo@v0.1.13-update.1
main A---B---C---D---E---F (synced with upstream)
\
main-pull-requests \---G---H---I (rebased on main, PRs from upstream)
\
main-vxcontrol \---J---K---L (default branch, rebased on main-pull-requests)
\
release/vM.M.P-update.N M (tagged stable release)
If you want to contribute to this fork, please create Pull Requests based on the current state of the main-vxcontrol
branch. Even though commit hashes in this branch may change due to rebasing, your contributions will be included in the next release when enough changes have accumulated.
When creating a PR, please ensure your changes are well-tested and include appropriate documentation. Once merged, your contributions will be included in the next stable release with fixed commit hashes.
Special thanks to Travis Cline (@tmc) and all contributors who have made this project possible.
- Documentation: pkg.go.dev/github.com/tmc/langchaingo
- Discord: Join the official LangChain Go community
This is the Go language implementation of LangChain.
See ./examples for example usage.
package main
import (
"context"
"fmt"
"log"
"github.com/vxcontrol/langchaingo/llms"
"github.com/vxcontrol/langchaingo/llms/openai"
)
func main() {
ctx := context.Background()
llm, err := openai.New()
if err != nil {
log.Fatal(err)
}
prompt := "What would be a good company name for a company that makes colorful socks?"
completion, err := llms.GenerateFromSinglePrompt(ctx, llm, prompt)
if err != nil {
log.Fatal(err)
}
fmt.Println(completion)
}
$ go run .
Socktastic
Join the Discord server for support and discussions: Join Discord
Here are some links to blog posts and articles on using Langchain Go:
- Using Gemini models in Go with LangChainGo - Jan 2024
- Using Ollama with LangChainGo - Nov 2023
- Creating a simple ChatGPT clone with Go - Aug 2023
- Creating a ChatGPT Clone that Runs on Your Laptop with Go - Aug 2023