repo stringlengths 6 47 | file_url stringlengths 77 269 | file_path stringlengths 5 186 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-07 08:35:43 2026-01-07 08:55:24 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/memory/langchain_adapter_test.go | memory/langchain_adapter_test.go | package memory
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tmc/langchaingo/llms"
langchainmemory "github.com/tmc/langchaingo/memory"
)
func TestLangChainMemory_ConversationBuffer(t *testing.T) {
ctx := context.Background()
// Create a c... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/memory/memory_test.go | memory/memory_test.go | package memory
import (
"context"
"testing"
)
func TestSequentialMemory(t *testing.T) {
ctx := context.Background()
mem := NewSequentialMemory()
// Add messages
msg1 := NewMessage("user", "Hello")
msg2 := NewMessage("assistant", "Hi there!")
msg3 := NewMessage("user", "How are you?")
if err := mem.AddMessa... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/engine.go | rag/engine.go | package rag
import (
"context"
"fmt"
"math"
"strings"
)
// BaseEngine provides common functionality for RAG engines
type BaseEngine struct {
retriever Retriever
embedder Embedder
config *Config
metrics *Metrics
}
// NewBaseEngine creates a new base RAG engine
func NewBaseEngine(retriever Retriever, emb... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/langgraph_adapter_test.go | rag/langgraph_adapter_test.go | package rag
import (
"context"
"errors"
"testing"
"time"
)
// mockEngine is a mock implementation of Engine for testing
type mockEngine struct {
queryResult *QueryResult
queryError error
queryCalled bool
queryInput string
}
func (m *mockEngine) Query(ctx context.Context, query string) (*QueryResult, error)... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/adapters_test.go | rag/adapters_test.go | package rag
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/tmc/langchaingo/schema"
"github.com/tmc/langchaingo/textsplitter"
)
type mockLCEmbedder struct{}
func (m *mockLCEmbedder) EmbedDocuments(ctx context.Context, texts []string) ([][]float32, error) {
res := make([][]float32... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/adapters.go | rag/adapters.go | package rag
import (
"context"
"fmt"
"maps"
"strings"
"time"
"github.com/tmc/langchaingo/documentloaders"
"github.com/tmc/langchaingo/embeddings"
"github.com/tmc/langchaingo/schema"
"github.com/tmc/langchaingo/textsplitter"
"github.com/tmc/langchaingo/vectorstores"
)
// LangChainDocumentLoader adapts langc... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/pipeline.go | rag/pipeline.go | package rag
import (
"context"
"fmt"
"maps"
"strings"
"time"
"github.com/smallnest/langgraphgo/graph"
"github.com/tmc/langchaingo/llms"
)
// RAGState represents the state flowing through a RAG pipeline
type RAGState struct {
Query string
Documents []RAGDocument
RetrievedDocuments []RA... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/doc.go | rag/doc.go | // RAG (Retrieval-Augmented Generation) Package
//
// The rag package provides comprehensive RAG (Retrieval-Augmented Generation) capabilities
// for the LangGraph Go framework. It integrates various RAG approaches including traditional
// vector-based retrieval and advanced GraphRAG techniques.
//
// # Features
//
// ... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/langgraph_adapter.go | rag/langgraph_adapter.go | package rag
import (
"context"
"fmt"
"github.com/tmc/langchaingo/tools"
)
// ========================================
// LangGraph Adapters
// ========================================
// NewRetrievalNode creates a LangGraph node function that retrieves documents using the RAG engine.
// It expects the input stat... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/types.go | rag/types.go | package rag
import (
"context"
"time"
)
// ========================================
// Core Types
// ========================================
// Document represents a document or document chunk in the RAG system
type Document struct {
ID string `json:"id"`
Content string `json:"content"`... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/pipeline_test.go | rag/pipeline_test.go | package rag
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/tmc/langchaingo/llms"
)
type mockLLM struct{}
func (m *mockLLM) GenerateContent(ctx context.Context, messages []llms.MessageContent, options ...llms.CallOption) (*llms.ContentResponse, error) {
return &llms.ContentRespons... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/retriever/vector.go | rag/retriever/vector.go | package retriever
import (
"context"
"fmt"
"github.com/smallnest/langgraphgo/rag"
)
// VectorRetriever implements document retrieval using vector similarity
type VectorRetriever struct {
vectorStore rag.VectorStore
embedder rag.Embedder
config rag.RetrievalConfig
}
// NewVectorRetriever creates a new ... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/retriever/llm_reranker.go | rag/retriever/llm_reranker.go | package retriever
import (
"context"
"fmt"
"maps"
"strings"
"github.com/smallnest/langgraphgo/rag"
"github.com/tmc/langchaingo/llms"
)
// LLMRerankerConfig configures the LLM-based reranker
type LLMRerankerConfig struct {
// TopK is the number of documents to return
TopK int
// ScoreThreshold is the minimum... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/retriever/graph.go | rag/retriever/graph.go | package retriever
import (
"context"
"fmt"
"strings"
"github.com/smallnest/langgraphgo/rag"
)
// GraphRetriever implements document retrieval using knowledge graphs
type GraphRetriever struct {
knowledgeGraph rag.KnowledgeGraph
embedder rag.Embedder
config rag.RetrievalConfig
}
// NewGraphRetri... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/retriever/hybrid.go | rag/retriever/hybrid.go | package retriever
import (
"context"
"fmt"
"github.com/smallnest/langgraphgo/rag"
)
// HybridRetriever combines multiple retrieval strategies
type HybridRetriever struct {
retrievers []rag.Retriever
weights []float64
config rag.RetrievalConfig
}
// NewHybridRetriever creates a new hybrid retriever that... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/retriever/common_test.go | rag/retriever/common_test.go | package retriever
import (
"context"
"github.com/smallnest/langgraphgo/rag"
)
type mockEmbedder struct{}
func (m *mockEmbedder) EmbedDocument(ctx context.Context, text string) ([]float32, error) {
return []float32{0.1, 0.2}, nil
}
func (m *mockEmbedder) EmbedDocuments(ctx context.Context, texts []string) ([][]fl... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/retriever/cohere_reranker.go | rag/retriever/cohere_reranker.go | package retriever
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"maps"
"net/http"
"os"
"time"
"github.com/smallnest/langgraphgo/rag"
)
// CohereRerankerConfig configures the Cohere reranker
type CohereRerankerConfig struct {
// Model is the Cohere rerank model to use
// Options: "rerank-v3.5", "r... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/retriever/graph_test.go | rag/retriever/graph_test.go | package retriever
import (
"context"
"testing"
"github.com/smallnest/langgraphgo/rag"
"github.com/stretchr/testify/assert"
)
type mockKG struct {
entities []*rag.Entity
}
func (m *mockKG) Query(ctx context.Context, q *rag.GraphQuery) (*rag.GraphQueryResult, error) {
scores := make([]float64, len(m.entities))
... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/retriever/jina_reranker.go | rag/retriever/jina_reranker.go | package retriever
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"maps"
"net/http"
"os"
"time"
"github.com/smallnest/langgraphgo/rag"
)
// JinaRerankerConfig configures the Jina reranker
type JinaRerankerConfig struct {
// Model is the Jina rerank model to use
// Options: "jina-reranker-v1-base-en... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/retriever/cross_encoder_reranker.go | rag/retriever/cross_encoder_reranker.go | package retriever
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"maps"
"net/http"
"time"
"github.com/smallnest/langgraphgo/rag"
)
// CrossEncoderRerankerConfig configures the Cross-Encoder reranker
type CrossEncoderRerankerConfig struct {
// ModelName is the name of the cross-encoder model
// Comm... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/retriever/vector_test.go | rag/retriever/vector_test.go | package retriever
import (
"context"
"testing"
"github.com/smallnest/langgraphgo/rag"
"github.com/stretchr/testify/assert"
)
type mockVectorStore struct {
docs []rag.Document
}
func (m *mockVectorStore) Add(ctx context.Context, documents []rag.Document) error {
m.docs = append(m.docs, documents...)
return ni... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/retriever/hybrid_test.go | rag/retriever/hybrid_test.go | package retriever
import (
"context"
"testing"
"github.com/smallnest/langgraphgo/rag"
"github.com/stretchr/testify/assert"
)
func TestHybridRetriever(t *testing.T) {
ctx := context.Background()
r1 := &mockRetriever{docs: []rag.Document{{ID: "1", Content: "r1"}}}
r2 := &mockRetriever{docs: []rag.Document{{ID: ... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/retriever/reranker.go | rag/retriever/reranker.go | package retriever
import (
"context"
"strings"
"github.com/smallnest/langgraphgo/rag"
)
// SimpleReranker is a simple reranker that scores documents based on keyword matching
type SimpleReranker struct {
// Can be extended with more sophisticated reranking logic
}
// NewSimpleReranker creates a new SimpleRerank... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/retriever/reranker_test.go | rag/retriever/reranker_test.go | package retriever
import (
"context"
"testing"
"github.com/smallnest/langgraphgo/rag"
"github.com/stretchr/testify/assert"
)
func TestSimpleReranker(t *testing.T) {
ctx := context.Background()
r := NewSimpleReranker()
assert.NotNil(t, r)
docs := []rag.DocumentSearchResult{
{Document: rag.Document{Content:... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/store/vector.go | rag/store/vector.go | package store
import (
"context"
"fmt"
"math"
"time"
"github.com/smallnest/langgraphgo/rag"
)
// InMemoryVectorStore is a simple in-memory vector store implementation
type InMemoryVectorStore struct {
documents []rag.Document
embeddings [][]float32
embedder rag.Embedder
}
// NewInMemoryVectorStore create... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/store/falkordb.go | rag/store/falkordb.go | package store
import (
"context"
"fmt"
"maps"
"net/url"
"regexp"
"strings"
"github.com/redis/go-redis/v9"
"github.com/smallnest/langgraphgo/rag"
)
// FalkorDBGraph implements a FalkorDB knowledge graph
type FalkorDBGraph struct {
client redis.UniversalClient
graphName string
}
// NewFalkorDBGraph creat... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/store/mock.go | rag/store/mock.go | package store
import (
"context"
"math"
"strings"
"github.com/smallnest/langgraphgo/rag"
)
// MockEmbedder is a simple mock embedder for testing
type MockEmbedder struct {
Dimension int
}
// NewMockEmbedder creates a new MockEmbedder
func NewMockEmbedder(dimension int) *MockEmbedder {
return &MockEmbedder{
... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/store/mock_test.go | rag/store/mock_test.go | package store
import (
"context"
"testing"
"github.com/smallnest/langgraphgo/rag"
"github.com/stretchr/testify/assert"
)
func TestMockComponents(t *testing.T) {
ctx := context.Background()
t.Run("MockEmbedder", func(t *testing.T) {
e := NewMockEmbedder(2)
assert.Equal(t, 2, e.GetDimension())
emb, err :... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/store/knowledge_graph.go | rag/store/knowledge_graph.go | package store
import (
"context"
"fmt"
"strings"
"github.com/smallnest/langgraphgo/rag"
)
// NewKnowledgeGraph creates a new knowledge graph based on the database URL
func NewKnowledgeGraph(databaseURL string) (rag.KnowledgeGraph, error) {
if strings.HasPrefix(databaseURL, "memory://") {
return &MemoryGraph{
... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/store/vector_test.go | rag/store/vector_test.go | package store
import (
"context"
"testing"
"github.com/smallnest/langgraphgo/rag"
"github.com/stretchr/testify/assert"
)
type mockEmbedder struct {
dim int
}
func (m *mockEmbedder) EmbedDocument(ctx context.Context, text string) ([]float32, error) {
res := make([]float32, m.dim)
for i := 0; i < m.dim; i++ {
... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/store/falkordb_internal.go | rag/store/falkordb_internal.go | package store
import (
"context"
"crypto/rand"
"fmt"
"os"
"strings"
"github.com/olekukonko/tablewriter"
"github.com/redis/go-redis/v9"
)
func quoteString(i any) any {
switch x := i.(type) {
case string:
if len(x) == 0 {
return "\"\""
}
// Escape single quotes for Cypher compatibility
x = strings.... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/store/falkordb_test.go | rag/store/falkordb_test.go | package store
import (
"testing"
"github.com/smallnest/langgraphgo/rag"
"github.com/stretchr/testify/assert"
)
func TestNewFalkorDBGraph(t *testing.T) {
t.Run("Valid connection string with custom graph name", func(t *testing.T) {
g, err := NewFalkorDBGraph("falkordb://localhost:6379/custom_graph")
assert.NoE... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/store/knowledge_graph_test.go | rag/store/knowledge_graph_test.go | package store
import (
"context"
"testing"
"github.com/smallnest/langgraphgo/rag"
"github.com/stretchr/testify/assert"
)
func TestInMemoryKnowledgeGraph(t *testing.T) {
ctx := context.Background()
kgInterface, err := NewKnowledgeGraph("memory://")
assert.NoError(t, err)
kg := kgInterface.(*MemoryGraph)
asse... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/engine/vector.go | rag/engine/vector.go | package engine
import (
"context"
"fmt"
"math"
"strings"
"time"
"github.com/smallnest/langgraphgo/rag"
"github.com/smallnest/langgraphgo/rag/splitter"
)
// vectorStoreRetrieverAdapter adapts vector store to Retriever interface
type vectorStoreRetrieverAdapter struct {
vectorStore rag.VectorStore
embedder ... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/engine/graph.go | rag/engine/graph.go | package engine
import (
"context"
"encoding/json"
"fmt"
"strings"
"time"
"unicode"
"github.com/smallnest/langgraphgo/rag"
)
// GraphRAGEngine implements GraphRAG functionality with knowledge graphs
type GraphRAGEngine struct {
config rag.GraphRAGConfig
knowledgeGraph rag.KnowledgeGraph
embedder ... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/engine/common_test.go | rag/engine/common_test.go | package engine
import (
"context"
"github.com/smallnest/langgraphgo/rag"
)
type mockRetriever struct {
docs []rag.Document
}
func (m *mockRetriever) Retrieve(ctx context.Context, query string) ([]rag.Document, error) {
return m.docs, nil
}
func (m *mockRetriever) RetrieveWithK(ctx context.Context, query string,... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/engine/graph_test.go | rag/engine/graph_test.go | package engine
import (
"context"
"testing"
"github.com/smallnest/langgraphgo/rag"
"github.com/stretchr/testify/assert"
)
type mockKG struct {
entities []*rag.Entity
}
func (m *mockKG) Query(ctx context.Context, q *rag.GraphQuery) (*rag.GraphQueryResult, error) {
return &rag.GraphQueryResult{Entities: m.entit... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/engine/lightrag_test.go | rag/engine/lightrag_test.go | package engine
import (
"context"
"fmt"
"strings"
"testing"
"time"
"github.com/smallnest/langgraphgo/rag"
"github.com/smallnest/langgraphgo/rag/store"
)
// MockLLM implements the LLMInterface for testing
type MockLLM struct{}
func (m *MockLLM) Generate(ctx context.Context, prompt string) (string, error) {
r... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/engine/vector_test.go | rag/engine/vector_test.go | package engine
import (
"context"
"testing"
"github.com/smallnest/langgraphgo/rag"
"github.com/stretchr/testify/assert"
)
func TestVectorRAGEngine(t *testing.T) {
ctx := context.Background()
llm := &mockLLM{}
store := &mockVectorStore{docs: []rag.Document{{Content: "c1"}}}
embedder := &mockEmbedder{}
e, er... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/engine/engine_test.go | rag/engine/engine_test.go | package engine
import (
"context"
"testing"
"github.com/smallnest/langgraphgo/rag"
"github.com/stretchr/testify/assert"
)
func TestBaseEngine(t *testing.T) {
ctx := context.Background()
retriever := &mockRetriever{docs: []rag.Document{{ID: "1", Content: "c1"}}}
embedder := &mockEmbedder{}
e := rag.NewBaseEn... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/engine/lightrag.go | rag/engine/lightrag.go | package engine
import (
"context"
"fmt"
"slices"
"strings"
"sync"
"time"
"github.com/smallnest/langgraphgo/rag"
)
// LightRAGEngine implements LightRAG functionality
// LightRAG combines low-level semantic chunks with high-level graph structures
// It supports four retrieval modes: naive, local, global, and h... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/loader/static.go | rag/loader/static.go | package loader
import (
"context"
"maps"
"github.com/smallnest/langgraphgo/rag"
)
// StaticDocumentLoader loads documents from a static list
type StaticDocumentLoader struct {
Documents []rag.Document
}
// NewStaticDocumentLoader creates a new StaticDocumentLoader
func NewStaticDocumentLoader(documents []rag.Do... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/loader/static_test.go | rag/loader/static_test.go | package loader
import (
"context"
"testing"
"github.com/smallnest/langgraphgo/rag"
"github.com/stretchr/testify/assert"
)
func TestStaticDocumentLoader(t *testing.T) {
ctx := context.Background()
docs := []rag.Document{
{ID: "1", Content: "static 1"},
{ID: "2", Content: "static 2"},
}
loader := NewStati... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/loader/text.go | rag/loader/text.go | package loader
import (
"bufio"
"context"
"fmt"
"io"
"maps"
"os"
"strings"
"github.com/smallnest/langgraphgo/rag"
)
// TextLoader loads documents from text files
type TextLoader struct {
filePath string
encoding string
metadata map[string]any
lineSeparator string
}
// TextLoaderOption con... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/loader/text_test.go | rag/loader/text_test.go | package loader
import (
"context"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
)
func TestTextLoader(t *testing.T) {
ctx := context.Background()
content := "Line 1\nLine 2\nLine 3"
tmpDir := t.TempDir()
tmpFile := filepath.Join(tmpDir, "test.txt")
err := os.WriteFile(tmpFile, []byte(... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/splitter/splitter_test.go | rag/splitter/splitter_test.go | package splitter
import (
"strings"
"testing"
"github.com/smallnest/langgraphgo/rag"
"github.com/stretchr/testify/assert"
)
func TestRecursiveCharacterTextSplitter(t *testing.T) {
t.Run("Basic splitting", func(t *testing.T) {
s := NewRecursiveCharacterTextSplitter(
WithChunkSize(10),
WithChunkOverlap(0)... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/splitter/recursive.go | rag/splitter/recursive.go | package splitter
import (
"fmt"
"maps"
"strings"
"unicode"
"github.com/smallnest/langgraphgo/rag"
)
// RecursiveCharacterTextSplitter recursively splits text while keeping related pieces together
type RecursiveCharacterTextSplitter struct {
separators []string
chunkSize int
chunkOverlap int
lengthFunc ... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/rag/splitter/simple.go | rag/splitter/simple.go | package splitter
import (
"maps"
"strings"
"github.com/smallnest/langgraphgo/rag"
)
// SimpleTextSplitter splits text into chunks of a given size
type SimpleTextSplitter struct {
ChunkSize int
ChunkOverlap int
Separator string
}
// NewSimpleTextSplitter creates a new SimpleTextSplitter
func NewSimpleTex... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/conditional_routing/main.go | examples/conditional_routing/main.go | package main
import (
"context"
"fmt"
"log"
"github.com/smallnest/langgraphgo/graph"
)
type Task struct {
ID string
Priority string
Content string
}
func main() {
// Create graph
g := graph.NewStateGraph[map[string]any]()
g.AddNode("router", "router", func(ctx context.Context, state map[string]any... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/configuration/main.go | examples/configuration/main.go | package main
import (
"context"
"fmt"
"log"
"github.com/smallnest/langgraphgo/graph"
)
func main() {
// Create a new state graph with map state
g := graph.NewStateGraph[map[string]any]()
g.AddNode("process", "process", func(ctx context.Context, state map[string]any) (map[string]any, error) {
// Access conf... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/ptc_basic/main.go | examples/ptc_basic/main.go | package main
import (
"context"
"fmt"
"log"
"math"
"strconv"
"strings"
"github.com/smallnest/langgraphgo/ptc"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/llms/openai"
"github.com/tmc/langchaingo/tools"
)
// CalculatorTool performs arithmetic operations
type CalculatorTool struct{}
func (... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/visualization/main.go | examples/visualization/main.go | package main
import (
"context"
"fmt"
"github.com/smallnest/langgraphgo/graph"
)
func main() {
// Create a graph
g := graph.NewStateGraph[map[string]any]()
// 1. Define nodes
g.AddNode("validate_input", "validate_input", func(ctx context.Context, state map[string]any) (map[string]any, error) {
return map[s... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/lightrag_advanced/main.go | examples/lightrag_advanced/main.go | package main
import (
"context"
"fmt"
"log"
"os"
"strings"
"time"
"github.com/smallnest/langgraphgo/rag"
"github.com/smallnest/langgraphgo/rag/engine"
"github.com/smallnest/langgraphgo/rag/store"
"github.com/tmc/langchaingo/llms/openai"
)
// OpenAILLMAdapter wraps langchaingo's openai.LLM to implement rag.... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/rag_falkordb_debug/main.go | examples/rag_falkordb_debug/main.go | package main
import (
"context"
"fmt"
"log"
"reflect"
"strings"
"github.com/redis/go-redis/v9"
"github.com/smallnest/langgraphgo/rag/store"
)
func main() {
ctx := context.Background()
// Test direct Redis connection first
fmt.Println("Testing direct Redis connection...")
client := redis.NewClient(&redis.... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/smart_messages/main.go | examples/smart_messages/main.go | package main
import (
"context"
"fmt"
"github.com/smallnest/langgraphgo/graph"
)
func main() {
g := graph.NewStateGraph[map[string]any]()
g.AddNode("user_input", "user_input", func(ctx context.Context, state map[string]any) (map[string]any, error) {
// In a real app, this would get input from UI
// Here we... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/ptc_expense_analysis/expense_tools.go | examples/ptc_expense_analysis/expense_tools.go | package main
import (
"context"
"encoding/json"
"fmt"
"math/rand"
"time"
)
// ExpenseItem represents a single expense line item
type ExpenseItem struct {
ID string `json:"id"`
EmployeeID string `json:"employee_id"`
Category string `json:"category"`
Amount float64 `json:"amount"`
... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/ptc_expense_analysis/main.go | examples/ptc_expense_analysis/main.go | package main
import (
"context"
"fmt"
"log"
"time"
"github.com/smallnest/langgraphgo/ptc"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/llms/openai"
"github.com/tmc/langchaingo/tools"
)
func main() {
fmt.Println("=== PTC (Programmatic Tool Calling) Example ===")
fmt.Println("This example de... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/tool_brave/main.go | examples/tool_brave/main.go | package main
import (
"context"
"fmt"
"log"
"os"
"github.com/smallnest/langgraphgo/prebuilt"
"github.com/smallnest/langgraphgo/tool"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/llms/openai"
"github.com/tmc/langchaingo/tools"
)
func main() {
// Check for API keys
if os.Getenv("BRAVE_API_K... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/parallel_execution/main.go | examples/parallel_execution/main.go | package main
import (
"context"
"fmt"
"time"
"github.com/smallnest/langgraphgo/graph"
)
func main() {
// Create a new state graph with typed state
g := graph.NewStateGraph[map[string]any]()
// Define Schema
// Using map schema where "results" accumulates values
schema := graph.NewMapSchema()
schema.Regist... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/durable_execution/main.go | examples/durable_execution/main.go | package main
import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"sort"
"time"
"github.com/smallnest/langgraphgo/graph"
"github.com/smallnest/langgraphgo/store"
)
// --- Simple File-based Checkpoint Store for Demo ---
type DiskStore struct {
FilePath string
}
func NewDiskStore(path string) *DiskStore {
... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/rag_basic/main.go | examples/rag_basic/main.go | package main
import (
"context"
"fmt"
"log"
"strings"
"github.com/smallnest/langgraphgo/graph"
"github.com/smallnest/langgraphgo/rag"
"github.com/smallnest/langgraphgo/rag/retriever"
"github.com/smallnest/langgraphgo/rag/store"
"github.com/tmc/langchaingo/llms/openai"
)
func main() {
ctx := context.Backgro... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/basic_example/main.go | examples/basic_example/main.go | package main
import (
"context"
"fmt"
"time"
"github.com/smallnest/langgraphgo/graph"
)
// Simple example demonstrating all major features
func main() {
fmt.Println("🚀 LangGraphGo Basic Example")
fmt.Println("============================")
runBasicExample()
runStreamingExample()
runCheckpointingExample()
... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/api_interrupt_demo/main.go | examples/api_interrupt_demo/main.go | // Package main demonstrates a request-response API pattern with checkpoint-based
// interrupt handling for conversational agents.
//
// This example shows how to:
// 1. Build an HTTP API that handles conversational flows with interrupts
// 2. Automatically save checkpoints when interrupts occur (Issue #70 fix)
// 3. D... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/dynamic_interrupt/main.go | examples/dynamic_interrupt/main.go | package main
import (
"context"
"errors"
"fmt"
"log"
"github.com/smallnest/langgraphgo/graph"
)
func main() {
// Create a state graph with map state
g := graph.NewStateGraph[map[string]any]()
g.AddNode("ask_name", "ask_name", func(ctx context.Context, state map[string]any) (map[string]any, error) {
// Thi... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/chat_agent_async/main.go | examples/chat_agent_async/main.go | package main
import (
"context"
"fmt"
"log"
"time"
"github.com/smallnest/langgraphgo/prebuilt"
"github.com/tmc/langchaingo/llms/openai"
)
func main() {
fmt.Println("=== ChatAgent AsyncChat Demo ===")
fmt.Println("This example demonstrates streaming responses from the agent.")
fmt.Println()
llm, err := ope... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/memory/main.go | examples/memory/main.go | // LangGraphGo 内存策略演示程序
//
// 这个程序演示了 LangGraphGo 中所有可用的内存管理策略。
// 运行方式: go run memory_examples.go
//
// 演示的内存策略:
// 1. Sequential Memory - 存储所有消息
// 2. Sliding Window Memory - 只保留最近的消息
// 3. Buffer Memory - 灵活的缓冲限制
// 4. Summarization Memory - 压缩旧消息
// 5. Retrieval Memory - 基于相似度检索
// 6. Hierarchical Memory - 分层存储
// ... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/lightrag_simple/main.go | examples/lightrag_simple/main.go | package main
import (
"context"
"fmt"
"log"
"os"
"strings"
"time"
"github.com/smallnest/langgraphgo/rag"
"github.com/smallnest/langgraphgo/rag/engine"
"github.com/smallnest/langgraphgo/rag/store"
"github.com/tmc/langchaingo/llms/openai"
)
// OpenAILLMAdapter wraps langchaingo's openai.LLM to implement rag.... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/reflexive_metacognitive/main.go | examples/reflexive_metacognitive/main.go | // Reflexive Metacognitive Agent
//
// This example implements the "Reflexive Metacognitive Agent" architecture
// from the Agentic Architectures series by Fareed Khan.
//
// Architecture Overview:
//
// A metacognitive agent maintains an explicit "self-model" — a structured
// representation of its own knowledge, tool... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/tool_tavily/main.go | examples/tool_tavily/main.go | package main
import (
"context"
"fmt"
"log"
"os"
"github.com/smallnest/langgraphgo/prebuilt"
"github.com/smallnest/langgraphgo/tool"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/llms/openai"
"github.com/tmc/langchaingo/tools"
)
func main() {
// Check for API keys
if os.Getenv("TAVILY_API_... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/arith_example/main.go | examples/arith_example/main.go | package main
import (
"context"
"fmt"
"log"
"github.com/smallnest/langgraphgo/graph"
"github.com/tmc/langchaingo/llms/openai"
)
func main() {
// Initialize LLM
model, err := openai.New()
if err != nil {
log.Fatal(err)
}
// Create state graph
g := graph.NewStateGraph[map[string]any]()
// Add arith nod... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/rag_falkordb_fast/main.go | examples/rag_falkordb_fast/main.go | package main
import (
"context"
"fmt"
"log"
"strings"
"time"
"github.com/smallnest/langgraphgo/adapter"
"github.com/smallnest/langgraphgo/rag"
"github.com/smallnest/langgraphgo/rag/store"
"github.com/tmc/langchaingo/llms/openai"
)
func main() {
ctx := context.Background()
// Initialize LLM
ollm, err := ... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/rag_conditional/main.go | examples/rag_conditional/main.go | package main
import (
"context"
"fmt"
"log"
"github.com/smallnest/langgraphgo/graph"
"github.com/smallnest/langgraphgo/rag"
"github.com/smallnest/langgraphgo/rag/retriever"
"github.com/smallnest/langgraphgo/rag/store"
"github.com/tmc/langchaingo/llms/openai"
)
func main() {
ctx := context.Background()
llm... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/rag_reranker/main.go | examples/rag_reranker/main.go | package main
import (
"context"
"fmt"
"log"
"os"
"strings"
"github.com/smallnest/langgraphgo/rag"
"github.com/smallnest/langgraphgo/rag/retriever"
"github.com/smallnest/langgraphgo/rag/splitter"
"github.com/smallnest/langgraphgo/rag/store"
"github.com/tmc/langchaingo/llms/openai"
)
func main() {
// Check ... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/memory_graph_integration/main.go | examples/memory_graph_integration/main.go | package main
import (
"context"
"fmt"
"log"
"github.com/smallnest/langgraphgo/graph"
)
// AgentState for the example
type AgentState struct {
Query string
Intent string
Info string
Response string
}
func classifyIntent(ctx context.Context, state map[string]any) (map[string]any, error) {
agentState... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/file_checkpointing/main.go | examples/file_checkpointing/main.go | package main
import (
"context"
"fmt"
"log"
"os"
"path/filepath"
"github.com/smallnest/langgraphgo/graph"
)
func main() {
// Create a temporary directory for checkpoints
checkpointDir := "./checkpoints"
if err := os.MkdirAll(checkpointDir, 0755); err != nil {
log.Fatal(err)
}
defer os.RemoveAll(checkpoi... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/langchain_example/main.go | examples/langchain_example/main.go | //go:build ignore
// +build ignore
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/smallnest/langgraphgo/graph"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/llms/googleai"
"github.com/tmc/langchaingo/llms/openai"
)
// Example 1: Using OpenAI with LangChain
func OpenAIExample() ... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/rag_chroma_example/main.go | examples/rag_chroma_example/main.go | package main
import (
"context"
"fmt"
"log"
"github.com/smallnest/langgraphgo/graph"
"github.com/smallnest/langgraphgo/rag"
"github.com/smallnest/langgraphgo/rag/retriever"
"github.com/smallnest/langgraphgo/rag/store"
"github.com/tmc/langchaingo/llms/openai"
)
func main() {
ctx := context.Background()
// ... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/complex_tools/tools.go | examples/complex_tools/tools.go | package main
import (
"context"
"encoding/json"
"fmt"
"math"
"time"
)
// HotelBookingParams 酒店预订参数
type HotelBookingParams struct {
CheckIn string `json:"check_in"`
CheckOut string `json:"check_out"`
Guests int `json:"guests"`
RoomType string `json:"room_type"`
Brea... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/complex_tools/main.go | examples/complex_tools/main.go | package main
import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/llms/openai"
"github.com/tmc/langchaingo/tools"
"github.com/smallnest/langgraphgo/prebuilt"
)
func main() {
// 检查API密钥
if os.Getenv("OPENAI_API_KEY") == "" {
log.Fatal("未设置OPEN... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/rag_langchain_vectorstore_example/main.go | examples/rag_langchain_vectorstore_example/main.go | package main
import (
"context"
"fmt"
"log"
"github.com/smallnest/langgraphgo/graph"
"github.com/smallnest/langgraphgo/rag"
"github.com/smallnest/langgraphgo/rag/retriever"
"github.com/smallnest/langgraphgo/rag/store"
"github.com/tmc/langchaingo/llms/openai"
)
func main() {
ctx := context.Background()
llm... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/streaming_modes/main.go | examples/streaming_modes/main.go | package main
import (
"context"
"fmt"
"time"
"github.com/smallnest/langgraphgo/graph"
)
func main() {
// Create a streaming graph
g := graph.NewStreamingStateGraph[map[string]any]()
// Define nodes
g.AddNode("step_1", "step_1", func(ctx context.Context, state map[string]any) (map[string]any, error) {
time... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/swarm/main.go | examples/swarm/main.go | package main
import (
"context"
"fmt"
"log"
"github.com/smallnest/langgraphgo/graph"
)
// Swarm style: Multiple specialized agents that can hand off to each other directly.
// This is different from Supervisor style where a central node routes.
// Here, nodes themselves decide next step.
func main() {
// Defin... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/mental_loop/main.go | examples/mental_loop/main.go | // Mental Loop Trading Agent
//
// This example implements the "Mental Loop" (Simulator-in-the-Loop) architecture
// from the Agentic Architectures series by Fareed Khan.
//
// Architecture Overview:
//
// 1. OBSERVE: The agent observes the current state of the environment
// 2. PROPOSE: Based on goals and current stat... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/file_checkpointing_resume/main.go | examples/file_checkpointing_resume/main.go | package main
import (
"context"
"fmt"
"log"
"os"
"github.com/smallnest/langgraphgo/graph"
)
func main() {
// Create a temporary directory for checkpoints
checkpointDir := "./checkpoints_resume"
if err := os.MkdirAll(checkpointDir, 0755); err != nil {
log.Fatal(err)
}
defer os.RemoveAll(checkpointDir) // ... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/logger/main.go | examples/logger/main.go | package main
import (
"os"
"github.com/kataras/golog"
"github.com/smallnest/langgraphgo/log"
)
func main() {
// 示例 1: 使用默认的 golog logger
defaultLogger := golog.Default
logger1 := log.NewGologLogger(defaultLogger)
logger1.Info("使用默认 golog logger")
logger1.SetLevel(log.LogLevelDebug)
logger1.Debug("调试信息")
/... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/rag_query_rewrite/main.go | examples/rag_query_rewrite/main.go | package main
import (
"context"
"fmt"
"github.com/smallnest/langgraphgo/graph"
)
func main() {
g := graph.NewStateGraph[map[string]any]()
g.AddNode("rewrite_query", "Rewrite user query for better retrieval", func(ctx context.Context, state map[string]any) (map[string]any, error) {
query, _ := state["query"].... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/reflection_agent/main.go | examples/reflection_agent/main.go | package main
import (
"context"
"fmt"
"log"
"os"
"strings"
"github.com/smallnest/langgraphgo/prebuilt"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/llms/openai"
)
func main() {
// Check for API key
if os.Getenv("OPENAI_API_KEY") == "" {
log.Fatal("OPENAI_API_KEY environment variable is r... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/pev_agent/main.go | examples/pev_agent/main.go | package main
import (
"context"
"fmt"
"log"
"os"
"strings"
"github.com/smallnest/langgraphgo/prebuilt"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/llms/openai"
"github.com/tmc/langchaingo/tools"
)
// CalculatorTool for PEV demo
type CalculatorTool struct{}
func (t CalculatorTool) Name() s... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/generic_state_graph_react_agent/main.go | examples/generic_state_graph_react_agent/main.go | package main
import (
"context"
"fmt"
_ "github.com/smallnest/langgraphgo/prebuilt"
_ "github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/tools"
)
// SimpleCounterTool is a basic tool that counts
type SimpleCounterTool struct {
count int
}
func (t *SimpleCounterTool) Name() string {
return "counter... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/rag_falkordb_debug_query/main.go | examples/rag_falkordb_debug_query/main.go | package main
import (
"context"
"fmt"
"log"
"github.com/redis/go-redis/v9"
"github.com/smallnest/langgraphgo/rag"
"github.com/smallnest/langgraphgo/rag/store"
)
func main() {
ctx := context.Background()
// 连接到FalkorDB
client := redis.NewClient(&redis.Options{Addr: "localhost:6379"})
defer client.Close()
... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/custom_reducer/main.go | examples/custom_reducer/main.go | package main
import (
"context"
"fmt"
"github.com/smallnest/langgraphgo/graph"
)
func main() {
// Create a new state graph with typed state map[string]any
g := graph.NewStateGraph[map[string]any]()
// Define schema with custom reducer for "tags"
schema := graph.NewMapSchema()
// Using generic AppendReducer
... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/streaming_pipeline/main.go | examples/streaming_pipeline/main.go | package main
import (
"context"
"fmt"
"strings"
"time"
"github.com/smallnest/langgraphgo/graph"
)
func main() {
// Create a streaming graph for a text processing pipeline
g := graph.NewStreamingStateGraph[map[string]any]()
// Define nodes
analyze := g.AddNode("analyze", "analyze", func(ctx context.Context,... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/memory_basic/main.go | examples/memory_basic/main.go | package main
import (
"context"
"fmt"
"log"
"github.com/smallnest/langgraphgo/memory"
"github.com/tmc/langchaingo/llms"
langchainmemory "github.com/tmc/langchaingo/memory"
)
func main() {
ctx := context.Background()
// Example 1: Basic ConversationBuffer
fmt.Println("=== Example 1: Basic ConversationBuffer... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/state_schema/main.go | examples/state_schema/main.go | package main
import (
"context"
"fmt"
"github.com/smallnest/langgraphgo/graph"
)
func main() {
// Create a new state graph with typed state
g := graph.NewStateGraph[map[string]any]()
// Define Schema
// Using map schema where "steps" accumulates values
schema := graph.NewMapSchema()
schema.RegisterReducer(... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/time_travel/main.go | examples/time_travel/main.go | package main
import (
"context"
"fmt"
"log"
"time"
"github.com/smallnest/langgraphgo/graph"
)
func main() {
// Create a checkpointable graph
g := graph.NewCheckpointableStateGraph[map[string]any]()
// 1. Initial State Node
g.AddNode("A", "A", func(ctx context.Context, state map[string]any) (map[string]any,... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/human_in_the_loop/main.go | examples/human_in_the_loop/main.go | package main
import (
"context"
"errors"
"fmt"
"log"
"github.com/smallnest/langgraphgo/graph"
)
// State represents the workflow state
type State struct {
Input string
Approved bool
Output string
}
func main() {
// Create a new graph with typed state
g := graph.NewStateGraph[State]()
// Define node... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/tree_of_thoughts/main.go | examples/tree_of_thoughts/main.go | package main
import (
"context"
"fmt"
"log"
"sort"
"strings"
"github.com/smallnest/langgraphgo/prebuilt"
)
// RiverState represents the state of the wolf-goat-cabbage river crossing puzzle
type RiverState struct {
LeftBank map[string]bool // Items on the left bank
RightBank map[string]bool // Items on... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/conditional_edges_example/main.go | examples/conditional_edges_example/main.go | //go:build ignore
// +build ignore
package main
import (
"context"
"fmt"
"strings"
"github.com/smallnest/langgraphgo/graph"
"github.com/tmc/langchaingo/llms"
)
func main() {
fmt.Println("🔀 Conditional Edges Example")
fmt.Println("============================\n")
// Example 1: Simple Intent Router
SimpleI... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/basic_llm/main.go | examples/basic_llm/main.go | package main
import (
"context"
"fmt"
"log"
"github.com/smallnest/langgraphgo/graph"
"github.com/tmc/langchaingo/llms/openai"
)
func main() {
// Initialize LLM
model, err := openai.New()
if err != nil {
log.Fatal(err)
}
g := graph.NewStateGraph[map[string]any]()
g.AddNode("generate", "generate", func(... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
smallnest/langgraphgo | https://github.com/smallnest/langgraphgo/blob/600df7fe3e6254f2329f606732feaecfbd52d9f2/examples/planning_agent/main.go | examples/planning_agent/main.go | package main
import (
"context"
"fmt"
"log"
"os"
"github.com/smallnest/langgraphgo/graph"
"github.com/smallnest/langgraphgo/prebuilt"
"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/llms/openai"
"github.com/tmc/langchaingo/tools"
)
func main() {
if os.Getenv("OPENAI_API_KEY") == "" {
log.Fa... | go | MIT | 600df7fe3e6254f2329f606732feaecfbd52d9f2 | 2026-01-07T10:38:05.929544Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.