https://github.com/tmc/langchaingo
LangChain for Go, the easiest way to write LLM-based programs in Go
https://github.com/tmc/langchaingo
ai go golang langchain
Last synced: 10 days ago
JSON representation
LangChain for Go, the easiest way to write LLM-based programs in Go
- Host: GitHub
- URL: https://github.com/tmc/langchaingo
- Owner: tmc
- License: mit
- Created: 2023-02-18T20:04:54.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-05-06T05:24:44.000Z (18 days ago)
- Last Synced: 2025-05-07T06:19:44.857Z (17 days ago)
- Topics: ai, go, golang, langchain
- Language: Go
- Homepage: https://tmc.github.io/langchaingo/
- Size: 12.7 MB
- Stars: 6,485
- Watchers: 59
- Forks: 814
- Open Issues: 316
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-go - langchaingo - LangChainGo is a framework for developing applications powered by language models. (Artificial Intelligence)
- awesome-go - langchaingo - LangChainGo is a framework for developing applications powered by language models. (Artificial Intelligence)
- awesome-go-with-stars - langchaingo - LangChainGo is a framework for developing applications powered by language models. (Artificial Intelligence)
- awesome-go-cn - langchaingo
- jimsghstars - tmc/langchaingo - LangChain for Go, the easiest way to write LLM-based programs in Go (Go)
- awesome-repositories - tmc/langchaingo - LangChain for Go, the easiest way to write LLM-based programs in Go (Go)
- awesome-go-cn - langchaingo
- awesome-go - langchaingo - LangChainGo is a framework for developing applications powered by language models. (Artificial Intelligence)
- awesome-ai - langchaingo - LangChain for Go, the easiest way to write LLM-based programs in Go. (Agent)
- awesome-ai - langchaingo - LangChain for Go, the easiest way to write LLM-based programs in Go. (Agent)
- awesome-langchain - Langchain Go
- StarryDivineSky - tmc/langchaingo
- awesome-go - langchaingo - LangChainGo is a framework for developing applications powered by language models. (Artificial Intelligence)
- awesome-ai-agents - LangChainGo
- awesomeLibrary - langchaingo - LangChain for Go, the easiest way to write LLM-based programs in Go (语言资源库 / go)
- awesome-go - langchaingo - LangChainGo is a framework for developing applications powered by language models. Stars:`6.5K`. (Artificial Intelligence)
- fucking-awesome-go - langchaingo - LangChainGo is a framework for developing applications powered by language models. (Artificial Intelligence)
- awesome-golang-ai - langchaingo - based programs in Go. (Large Language Model / DevTools)
- awesome-go-plus - langchaingo - LangChainGo is a framework for developing applications powered by language models.  (Artificial Intelligence)
- awesome-go-plus - langchaingo - LangChainGo is a framework for developing applications powered by language models.  (Artificial Intelligence)
- AiTreasureBox - tmc/langchaingo - 05-13_6531_2](https://img.shields.io/github/stars/tmc/langchaingo.svg)|LangChain for Go, the easiest way to write LLM-based programs in Go| (Repos)
- awesome-go - langchaingo - 基于语言模型开发应用的框架。 (人工智能 (AI))
- awesome-langchain-zh - Langchain Go
README
> 🎉 **Join our new official Discord community!** Connect with other LangChain Go developers, get help and contribute: [Join Discord](https://discord.gg/t9UbBQs2rG)
# 🦜️🔗 LangChain Go
[](https://pkg.go.dev/github.com/tmc/langchaingo)
[](https://goreportcard.com/report/github.com/tmc/langchaingo)
[](https://discord.gg/t9UbBQs2rG)
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/tmc/langchaingo)
[](https://codespaces.new/tmc/langchaingo)
⚡ Building applications with LLMs through composability, with Go! ⚡
## 🤔 What is this?
This is the Go language implementation of [LangChain](https://github.com/langchain-ai/langchain).
## 📖 Documentation
- [Documentation Site](https://tmc.github.io/langchaingo/docs/)
- [API Reference](https://pkg.go.dev/github.com/tmc/langchaingo)## 🎉 Examples
See [./examples](./examples) for example usage.
```go
package mainimport (
"context"
"fmt"
"log""github.com/tmc/langchaingo/llms"
"github.com/tmc/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)
}
``````shell
$ go run .
Socktastic
```# Resources
Join the Discord server for support and discussions: [Join Discord](https://discord.gg/t9UbBQs2rG)
Here are some links to blog posts and articles on using Langchain Go:
- [Using Gemini models in Go with LangChainGo](https://eli.thegreenplace.net/2024/using-gemini-models-in-go-with-langchaingo/) - Jan 2024
- [Using Ollama with LangChainGo](https://eli.thegreenplace.net/2023/using-ollama-with-langchaingo/) - Nov 2023
- [Creating a simple ChatGPT clone with Go](https://sausheong.com/creating-a-simple-chatgpt-clone-with-go-c40b4bec9267?sk=53a2bcf4ce3b0cfae1a4c26897c0deb0) - Aug 2023
- [Creating a ChatGPT Clone that Runs on Your Laptop with Go](https://sausheong.com/creating-a-chatgpt-clone-that-runs-on-your-laptop-with-go-bf9d41f1cf88?sk=05dc67b60fdac6effb1aca84dd2d654e) - Aug 2023# Contributors
There is a momentum for moving the development of langchaingo to a more community effort, if you are interested in being a maintainer or you are a contributor please join our [Discord](https://discord.gg/t9UbBQs2rG) and let us know.