go-llamaindex

module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: MIT

README

go-llamaindex

⚠️ EXPERIMENTAL AI-GENERATED CODE ⚠️

This is an AI-generated conversion of LlamaIndex concepts to Go. It has not been thoroughly tested, audited, or optimized for production use. Use at your own risk and thoroughly test any functionality before deploying in production environments.


Overview

go-llamaindex is a comprehensive Go implementation of the LlamaIndex framework for building LLM-powered applications. It provides a complete toolkit for document processing, embedding generation, vector storage, retrieval, agents, workflows, and evaluation—all in idiomatic Go.

Installation

go get github.com/aqua777/go-llamaindex

Examples

For runnable examples covering all features, see the examples/ directory with 60+ examples across 16 categories including RAG pipelines, agents, workflows, evaluation, and more.


Implemented Components

Core Schema & Base Types

Package: schema/

  • Node System — Node relationships (SOURCE, PREVIOUS, NEXT, PARENT, CHILD), RelatedNodeInfo, SHA256-based hashing
  • MetadataMode — Modes: ALL, EMBED, LLM, NONE with exclusion key support
  • MediaResource — Fields: Data, Text, Path, URL, MimeType, Embeddings
  • ImageNode — Image data (base64, path, URL)
  • IndexNodeIndexID field for recursive retrieval
  • BaseComponentToJSON(), FromJSON(), ToDict(), FromDict(), ClassName()
  • TransformComponentTransform(nodes []Node) []Node

LLM Interface & Providers

Package: llm/

  • LLM InterfaceComplete(), Chat(), Stream()
  • LLMMetadataContextWindow, NumOutputTokens, IsChat, IsFunctionCalling, IsMultiModal
  • ChatMessage TypesMessageRole (system, user, assistant, tool), ContentBlock (text, image, tool call, tool result), multi-modal support
  • Tool CallingToolCall, ToolResult, ToolMetadata, LLMWithToolCalling interface, ToolChoice enum
  • Structured OutputResponseFormat with json_object and json_schema types, LLMWithStructuredOutput interface

Providers:

  • OpenAI
  • Anthropic
  • Ollama
  • Cohere
  • Azure OpenAI
  • Mistral AI
  • Groq
  • DeepSeek
  • AWS Bedrock

Embedding Interface & Providers

Package: embedding/

  • EmbeddingModel InterfaceGetTextEmbedding(), GetQueryEmbedding(), GetTextEmbeddingsBatch()
  • EmbeddingInfoDimensions, MaxTokens, TokenizerName, IsMultiModal
  • Similarity FunctionsCosineSimilarity, EuclideanDistance, DotProduct, TopKSimilar, normalization utilities
  • MultiModal EmbeddingMultiModalEmbeddingModel interface with GetImageEmbedding()
  • Sparse EmbeddingsSparseEmbedding, BM25 and BM25Plus models, HybridEmbeddingModel interface

Providers:

  • OpenAI
  • Ollama
  • Cohere
  • HuggingFace
  • Azure OpenAI
  • AWS Bedrock

Text Processing

Packages: textsplitter/, nodeparser/, validation/

Text Splitters:

  • SentenceSplitter — Sentence-aware splitting with metadata-conscious mode
  • TokenTextSplitter — Token-based splitting with custom tokenizer support
  • MarkdownSplitter — Preserves code blocks, splits by headers
  • SentenceWindowSplitter — Configurable context window around sentences

Tokenization:

  • TikToken Integrationcl100k_base, p50k_base, r50k_base, o200k_base encodings

Node Parsers:

  • SentenceNodeParser — Wraps SentenceSplitter with event callbacks
  • SimpleNodeParser — One node per document

Validation:

  • RequirePositive(), RequireNonNegative(), RequireNotEmpty()
  • Splitter-specific validation functions

Storage Layer

Package: storage/

Key-Value Store:

  • KVStore interface with Put, Get, Delete, GetAll
  • SimpleKVStore (in-memory) and FileKVStore (file-based)

Document Store:

  • DocStore interface with document management and hash tracking
  • KVDocumentStore and SimpleDocumentStore implementations

Index Store:

  • IndexStore interface supporting VectorStore, List, KeywordTable, Tree, KG types
  • KVIndexStore and SimpleIndexStore implementations

Chat Store:

  • ChatStore interface for conversation history
  • SimpleChatStore implementation

Vector Store:

  • VectorStore interface with Add() and Query()
  • Query modes: Default, Sparse, Hybrid, MMR
  • Filter operators: EQ, GT, LT, NE, IN, NIN, TEXT_MATCH, CONTAINS, etc.
  • Implementations: SimpleVectorStore (in-memory), ChromemStore (persistent)

Storage Context:

  • Combines DocStore, IndexStore, VectorStores
  • Persistence and JSON serialization support

Prompt System

Package: prompts/

  • PromptTemplate — Template string with {variable} placeholders, Format(), PartialFormat()
  • ChatPromptTemplate — System/user/assistant message templates
  • PromptType EnumSummary, QuestionAnswer, Refine, TreeInsert, TreeSelect, KeywordExtract
  • PromptMixin InterfaceGetPrompts(), UpdatePrompts()
  • Default PromptsDefaultSummaryPrompt, DefaultTextQAPrompt, DefaultRefinePrompt, etc.

Retrieval System

Package: rag/retriever/

  • Retriever InterfaceRetrieve(ctx, query) ([]NodeWithScore, error)
  • VectorRetriever — Vector store queries with embedding support
  • FusionRetriever — Combines retrievers with ReciprocalRank, RelativeScore, DistBasedScore, Simple modes
  • AutoMergingRetriever — Merges child nodes into parents with configurable threshold
  • RouterRetriever — Routes queries via Selector interface

Response Synthesis

Package: rag/synthesizer/

  • Synthesizer InterfaceSynthesize(), GetResponse()
  • SimpleSynthesizer — Single LLM call with merged chunks
  • RefineSynthesizer — Iterative refinement across chunks
  • CompactAndRefineSynthesizer — Compacts before refining
  • TreeSummarizeSynthesizer — Recursive bottom-up summarization
  • AccumulateSynthesizer — Per-chunk responses concatenated
  • ResponseMode EnumRefine, Compact, SimpleSummarize, TreeSummarize, Accumulate

Query Engine

Package: rag/queryengine/

  • QueryEngine InterfaceQuery(ctx, query) (*Response, error)
  • RetrieverQueryEngine — Combines retriever and synthesizer
  • SubQuestionQueryEngine — Decomposes complex queries
  • RouterQueryEngine — Routes to appropriate engines
  • RetryQueryEngine — Retries on failure
  • TransformQueryEngine — Query transformation with IdentityTransform, HyDETransform

Index Abstractions

Package: index/

  • BaseIndex InterfaceAsRetriever(), AsQueryEngine(), InsertNodes(), DeleteNodes(), RefreshDocuments()
  • VectorStoreIndex — Embedding generation and batch insertion
  • SummaryIndex (ListIndex) — List structure with Default/Embedding/LLM retriever modes
  • KeywordTableIndex — Keyword extraction with stop word removal
  • TreeIndex — Hierarchical summarization with TreeAllLeafRetriever, TreeRootRetriever, TreeSelectLeafRetriever
  • KnowledgeGraphIndex — Triplet extraction with keyword/embedding/hybrid retrieval modes

Tools & Function Calling

Package: tools/

  • Tool InterfaceCall(), Metadata()
  • ToolMetadataName, Description, Parameters (JSON Schema), OpenAI conversions
  • FunctionTool — Automatic schema generation from function signatures
  • QueryEngineTool — Wraps query engine as tool
  • RetrieverTool — Wraps retriever as tool

Memory System

Package: memory/

  • Memory InterfaceGet, GetAll, Put, PutMessages, Set, Reset
  • SimpleMemory — Stores all messages
  • ChatMemoryBuffer — Fixed-size buffer with token limit
  • ChatSummaryMemoryBuffer — LLM-based summarization of older messages
  • VectorMemory — Vector-based memory retrieval

Chat Engine

Package: chatengine/

  • ChatEngine InterfaceChat, ChatWithHistory, StreamChat, Reset, ChatHistory
  • SimpleChatEngine — Direct LLM chat
  • ContextChatEngine — RAG-enhanced with retriever
  • CondensePlusContextChatEngine — Query condensation + context retrieval

Agent System

Package: agent/

  • Agent InterfaceAgentState, AgentStep, ToolSelection, ToolCallResult, AgentOutput
  • ReAct Agent — Thought-action-observation loop
  • FunctionCallingReActAgent — OpenAI function calling integration
  • Output ParserActionReasoningStep, ObservationReasoningStep, ResponseReasoningStep
  • Formatter — ReAct chat formatter with system templates

Evaluation Framework

Package: evaluation/

  • Evaluator InterfaceEvaluationResult, EvaluateInput, EvaluatorRegistry
  • FaithfulnessEvaluator — Checks response support by context
  • RelevancyEvaluator — Context and answer relevancy
  • CorrectnessEvaluator — 1-5 scoring with reference comparison
  • SemanticSimilarityEvaluator — Cosine, dot product, euclidean similarity
  • BatchEvalRunner — Concurrent evaluation

Callbacks & Instrumentation

Package: callbacks/

  • CBEventType EnumChunking, NodeParsing, Embedding, LLM, Query, Retrieve, Synthesize, Tree, SubQuestion, FunctionCall, Reranking, AgentStep
  • CallbackHandler InterfaceOnEventStart, OnEventEnd, StartTrace, EndTrace
  • CallbackManager — Thread-safe event dispatch
  • Handlers: LoggingHandler, TokenCountingHandler, EventCollectorHandler

Document Readers

Package: rag/reader/

  • Reader InterfaceLoadData(), LazyReader, FileReader, ReaderWithContext
  • SimpleDirectoryReader — Recursive traversal, extension filtering
  • JSONReader — Object, array, JSONL support
  • HTMLReader — Script/style removal, entity decoding, metadata extraction
  • MarkdownReader — YAML frontmatter, header-based splitting
  • PDFReader — PDF extraction via ledongthuc/pdf
  • CSVReader — CSV/TSV with streaming support for large files
  • ExcelReader — Multi-sheet support, column selection by name/index/letter
  • DocxReader — Paragraphs, tables, document properties, optional image extraction

Ingestion Pipeline

Package: ingestion/

  • IngestionPipeline — Transformation chains via TransformComponent
  • Caching — Document deduplication
  • DocstoreStrategyUPSERTS, DUPLICATES_ONLY, UPSERTS_AND_DELETE

Postprocessors

Package: postprocessor/

  • SimilarityPostprocessor — Filter by score threshold
  • KeywordPostprocessor — Required/excluded keywords
  • MetadataReplacementPostprocessor — Replace content with metadata
  • LongContextReorder — Reorder for long context models
  • TopKPostprocessor — Limit returned nodes
  • LLMRerank — LLM-based reranking
  • RankGPTRerank — Conversational ranking with sliding window
  • PIIPostprocessor — Email, phone, SSN, credit card, IP masking
  • NodeRecencyPostprocessor — Time-based weighting (linear, exponential, step)

Metadata Extractors

Package: extractors/

  • MetadataExtractor InterfaceBaseExtractor, LLMExtractor, ExtractorChain
  • TitleExtractor
  • SummaryExtractor
  • KeywordsExtractor
  • QuestionsAnsweredExtractor

Workflow System

Package: workflow/

  • Workflow TypesWorkflow, Event, Context, StateStore, EventFactory, Handler
  • Workflow EngineRun, RunStream, retry support
  • Step Decorators — Logging, timing, conditional, fallback, chain, middleware
  • Common EventsStart, Stop, Error, InputRequired, HumanResponse

Structured Programs

Package: program/

  • Program InterfaceOutputParser, JSONOutputParser, PydanticOutputParser
  • FunctionProgram — Function-based structured output via tool calling
  • LLMProgram — LLM-based structured output with parsing

Object Index

Package: objects/

  • ObjectNodeMapping InterfaceBaseObjectNodeMapping, SimpleObjectNodeMapping
  • ToolNodeMappingToolRetriever for tool-based retrieval
  • TypedObjectNodeMapping — Generic typed mapping

Advanced Features
  • Selectors (selector/) — LLMSingleSelector, LLMMultiSelector, SelectionOutputParser
  • Question Generation (questiongen/) — LLMQuestionGenerator with few-shot prompts
  • Output Parsers (outputparser/) — JSONOutputParser, ListOutputParser, BooleanOutputParser
  • Graph Store (graphstore/) — GraphStore interface, Triplet, EntityNode, Relation, SimpleGraphStore

Dependencies


Limitations

As an AI-generated conversion, this implementation may have:

  • Incomplete feature coverage compared to Python/TypeScript LlamaIndex
  • Potential bugs or edge cases not yet discovered
  • Performance characteristics not optimized
  • Limited testing and validation

Contributing

This is experimental code. Contributions are welcome but expect significant changes as the codebase matures.

License

See individual dependency licenses.

Directories

Path Synopsis
Package agent provides agent abstractions for autonomous reasoning with tools.
Package agent provides agent abstractions for autonomous reasoning with tools.
Package callbacks provides callback and instrumentation support for LlamaIndex.
Package callbacks provides callback and instrumentation support for LlamaIndex.
Package chatengine provides chat engine abstractions for conversational AI.
Package chatengine provides chat engine abstractions for conversational AI.
Package evaluation provides evaluation metrics for RAG systems.
Package evaluation provides evaluation metrics for RAG systems.
Package extractors provides metadata extraction functionality for nodes.
Package extractors provides metadata extraction functionality for nodes.
Package graphstore provides graph store interfaces and implementations for knowledge graphs.
Package graphstore provides graph store interfaces and implementations for knowledge graphs.
Package index provides index abstractions for LlamaIndex.
Package index provides index abstractions for LlamaIndex.
Package ingestion provides document ingestion pipeline functionality.
Package ingestion provides document ingestion pipeline functionality.
llm
bedrock module
Package memory provides memory abstractions for chat history management.
Package memory provides memory abstractions for chat history management.
Package objects provides object-to-node mapping for go-llamaindex.
Package objects provides object-to-node mapping for go-llamaindex.
Package outputparser provides output parsing functionality.
Package outputparser provides output parsing functionality.
Package postprocessor provides node postprocessing functionality.
Package postprocessor provides node postprocessing functionality.
Package program provides structured LLM output programs for go-llamaindex.
Package program provides structured LLM output programs for go-llamaindex.
Package prompts provides prompt templates and utilities for LLM interactions.
Package prompts provides prompt templates and utilities for LLM interactions.
Package questiongen provides question generation functionality.
Package questiongen provides question generation functionality.
rag
queryengine
Package queryengine provides query engine implementations for RAG systems.
Package queryengine provides query engine implementations for RAG systems.
reader
Package reader provides document loading functionality for go-llamaindex.
Package reader provides document loading functionality for go-llamaindex.
retriever
Package retriever provides retrieval implementations for RAG systems.
Package retriever provides retrieval implementations for RAG systems.
synthesizer
Package synthesizer provides response synthesis implementations for RAG systems.
Package synthesizer provides response synthesis implementations for RAG systems.
Package selector provides query routing functionality.
Package selector provides query routing functionality.
Package storage provides unified storage management for LlamaIndex.
Package storage provides unified storage management for LlamaIndex.
chatstore
Package chatstore provides chat store interfaces and implementations.
Package chatstore provides chat store interfaces and implementations.
docstore
Package docstore provides document store interfaces and implementations.
Package docstore provides document store interfaces and implementations.
indexstore
Package indexstore provides index store interfaces and implementations.
Package indexstore provides index store interfaces and implementations.
kvstore
Package kvstore provides key-value store interfaces and implementations.
Package kvstore provides key-value store interfaces and implementations.
Package tools provides tool abstractions for LlamaIndex.
Package tools provides tool abstractions for LlamaIndex.
Package validation provides input validation utilities for go-llamaindex.
Package validation provides input validation utilities for go-llamaindex.
Package workflow provides an event-driven workflow orchestration system.
Package workflow provides an event-driven workflow orchestration system.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL