MCPcopy Index your code
hub / github.com/tmc/langchaingo

github.com/tmc/langchaingo @v0.1.14 sqlite

repository ↗ · DeepWiki ↗ · release v0.1.14 ↗
4,487 symbols 19,751 edges 679 files 2,014 documented · 45% 5 cross-repo links
README

🎉 Join our new official Discord community! Connect with other LangChain Go developers, get help and contribute: Join Discord

🦜️🔗 LangChain Go

go.dev reference scorecard Open in Dev Containers

⚡ Building applications with LLMs through composability, with Go! ⚡

🤔 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/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)
}
$ go run .
Socktastic

Resources

Join the Discord server for support and discussions: Join Discord

Here are some links to blog posts and articles on using Langchain Go:

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 and let us know.

Extension points exported contracts — how you extend this code

Tool (Interface)
Tool is a tool for the llm agent to interact with different applications. [12 implementers]
tools/tool.go
Embedder (Interface)
Embedder is the interface for creating vector embeddings from texts. [12 implementers]
embeddings/embedding.go
Handler (Interface)
Handler is the interface that allows for hooking into specific parts of an LLM application. nolint:all [9 implementers]
callbacks/callbacks.go
Loader (Interface)
Loader is the interface for loading and splitting documents from a source. [6 implementers]
documentloaders/documentloaders.go
Chain (Interface)
Chain is the interface all chains must implement. [19 implementers]
chains/chains.go
ChatMessage (Interface)
ChatMessage represents a message in a chat. [9 implementers]
llms/chat_messages.go
Model (Interface)
Model is an interface multi-modal models implement. [24 implementers]
llms/llms.go
ContentPart (Interface)
ContentPart is an interface all parts of content have to implement. [7 implementers]
llms/generatecontent.go

Core symbols most depended-on inside this repo

Run
called by 490
llms/compliance/suite.go
Close
called by 262
vectorstores/dolt/dolt.go
Error
called by 235
llms/errors.go
Skip
called by 209
llms/compliance/suite.go
OpenForTest
called by 157
internal/httprr/rr.go
Error
called by 154
llms/ollama/internal/ollamaclient/types.go
GenerateContent
called by 151
llms/llms.go
Recording
called by 150
internal/httprr/rr.go

Shape

Function 2,381
Method 1,361
Struct 569
FuncType 84
Interface 52
TypeAlias 40

Languages

Go100%
TypeScript1%

Modules by API surface

internal/devtools/lint/lint.go87 symbols
internal/httprr/rr.go42 symbols
llms/anthropic/internal/anthropicclient/messages.go37 symbols
llms/openai/internal/openaiclient/chat.go36 symbols
llms/ollama/options.go36 symbols
llms/chat_messages.go34 symbols
memory/zep/zep_test.go33 symbols
llms/googleai/shared_test/shared_test.go33 symbols
vectorstores/bedrockknowledgebases/bedrockknowledgebases_test.go31 symbols
vectorstores/alloydb/distance_strategy.go31 symbols
textsplitter/markdown_splitter.go31 symbols
llms/options.go31 symbols

Dependencies from manifests, versioned

cloud.google.com/gov0.116.0 · 1×
cloud.google.com/go/aiv0.7.0 · 1×
cloud.google.com/go/aiplatformv1.69.0 · 1×
cloud.google.com/go/alloydbv1.14.0 · 1×
cloud.google.com/go/alloydbconnv1.13.2 · 1×
cloud.google.com/go/auth/oauth2adaptv0.2.7 · 1×
cloud.google.com/go/cloudsqlconnv1.14.1 · 1×
cloud.google.com/go/compute/metadatav0.6.0 · 1×
cloud.google.com/go/longrunningv0.6.2 · 1×
cloud.google.com/go/vertexaiv0.12.0 · 1×

Datastores touched

(mongodb)Database · 1 repos
testdbDatabase · 1 repos

For agents

$ claude mcp add langchaingo \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact