- Added support for a new chunk type, ChunkTypeDone, to signal the completion of streaming sessions. - Updated various examples and tests to handle the new done chunk, ensuring proper signaling of stream completion. - Refactored streaming functions to include calls to CallWithDone, improving the clarity and reliability of streaming responses. - Enhanced documentation to reflect the changes in chunk types and their usage in streaming contexts.
⚠️ This is a fork of the original github.com/tmc/langchaingo repository.
🦜️🔗 LangChain Go (fork)
⚡ Building applications with LLMs through composability, with Go! ⚡
🚀 Important Announcement 🚀
Starting from release v0.1.13-update.1, this fork is now a full-fledged library that does not require any
replacedirectives in your go.mod file. You can simply add it to your project with:go get github.com/vxcontrol/langchaingo@latest
Why this fork?
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.
Branch Structure and Versioning
This repository follows a specific branching strategy to maintain both upstream compatibility and custom enhancements:
Branch Management
- 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
mainafter 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-vxcontrolfor each release. These branches are stable and never force-pushed.
Versioning
Release tags follow the format v0.1.13-update.1, where:
v0.1.13corresponds to the latest upstream release version-update.1indicates 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.
Dependency Management
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
Branch Visualization
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)
For Contributors
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.
Acknowledgements
Special thanks to Travis Cline (@tmc) and all contributors who have made this project possible.
Original resources
- Documentation: pkg.go.dev/github.com/tmc/langchaingo
- Discord: Join the official LangChain Go community
🤔 What is this?
This is the Go language implementation of LangChain.
📖 Documentation
🎉 Examples
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
Resources
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