Skip to the content.

Provider-Agnostic Go AI Library

Build AI-powered Go applications with swappable providers, modular interfaces, and production-ready tooling.

import (
    "github.com/bachtiarpanjaitan/ihandai-go"
    _ "github.com/bachtiarpanjaitan/ihandai-go/plugins/ollama"
)

ai, _ := ihandai.New(
    ihandai.WithLLM("ollama", llm.WithModel("llama3")),
    ihandai.WithEmbedding("ollama", embedding.WithModel("nomic-embed-text")),
    ihandai.WithMemory(memory.NewInMemoryStore()),
)
defer ai.Close()

resp, _ := ai.Ask(ctx, "What is RAG?", ihandai.WithTopK(5))

Installation

go get github.com/bachtiarpanjaitan/ihandai-go

Features

Feature Description
🔍 RAG Pipeline Load → Split → Embed → Search → Rerank → Chat
🎯 Retrieval Strategies TopK, MMR (diversity), MultiQuery (expansion)
🤖 Agents ReAct agent loop with tool calling, retry, reflection
🧠 Memory Multi-turn conversations with token-aware window
⚙️ Workflows DAG-based parallel execution, conditional branching
🔌 MCP Model Context Protocol client + filesystem server
📡 Streaming Real-time token streaming via channels
🛡️ Production Rate limiter, circuit breaker, tracing

Supported Providers

LLM & Embedding

Provider Type Interface
Ollama Local ChatCompleter, Embedder
OpenAI Cloud ChatCompleter, Embedder (planned)
Anthropic Cloud ChatCompleter (planned)
Google Gemini Cloud ChatCompleter (planned)

Vector Stores

Provider Type
Qdrant Self-hosted / Cloud (planned)
pgvector PostgreSQL extension (planned)
Milvus Self-hosted / Cloud (planned)

Core Principles

Quick Example: RAG Chatbot

package main

import (
    "bufio"
    "context"
    "fmt"
    "log"
    "os"

    "github.com/bachtiarpanjaitan/ihandai-go"
    "github.com/bachtiarpanjaitan/ihandai-go/pkg/llm"
    "github.com/bachtiarpanjaitan/ihandai-go/pkg/embedding"
    "github.com/bachtiarpanjaitan/ihandai-go/pkg/memory"
    _ "github.com/bachtiarpanjaitan/ihandai-go/plugins/ollama"
)

func main() {
    ai, _ := ihandai.New(
        ihandai.WithLLM("ollama", llm.WithModel("llama3")),
        ihandai.WithEmbedding("ollama", embedding.WithModel("nomic-embed-text")),
        ihandai.WithVectorStore("mock"),
        ihandai.WithMemory(memory.NewInMemoryStore()),
    )
    defer ai.Close()

    scanner := bufio.NewScanner(os.Stdin)
    session := "default"
    for {
        fmt.Print("> ")
        scanner.Scan()
        resp, _ := ai.AskConversation(context.Background(), session, scanner.Text())
        fmt.Println(resp.Content)
    }
}

License & Contributing