gogentic

module
v0.20.157 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0

README

gogentic

LLM Agents in Go

Overview

gogentic is a modular, extensible framework for building agentic LLM (Large Language Model) applications in Go. It is inspired by and forked from langchaingo, with a focus on improved tool and assistant abstractions, schema generation, and MCP (Message Control Protocol) support.

Features

  • Agentic LLM Flows: Compose complex agent behaviors using assistants, tools, and callbacks.
  • Schema Generation: Automatic JSON schema generation for tool parameters and message formats.
  • MCP Support: Native integration with MCP for distributed, real-time, and local transport communication.
  • Pluggable Tools: Easily define, register, and use tools with LLM agents.
  • Multi-format Encoding: Support for JSON, YAML, TOML, and custom encodings.
  • Memory and Persistence: In-memory and Redis-backed chat/message stores.
  • Testable and Extensible: Mocking, test utilities, and clear interfaces for rapid development.

Architecture

  • assistants/: Core agent and assistant logic, tool orchestration, and callback handling.
  • tools/: Tool interface, registration, and MCP integration. Includes example tools (e.g., tavily).
  • llmfactory/: LLM model factory and configuration (OpenAI, Azure, etc.).
  • chatmodel/: Message and IO schema definitions for chat-based LLMs.
  • encoding/: Pluggable encoders/decoders (json, yaml, toml, dummy).
  • store/: Message and chat storage (memory, Redis).
  • mcp/: Model Context Protocol extensions to mcp-golang (local, SSE, internal transport).
  • schema/: JSON schema generation utilities.
  • llmutils/: Utility functions for LLM operations.
  • mocks/: Mock implementations for testing.

Quickstart

go get github.com/effective-security/gogentic

See assistants/assistants.go and tools/tools.go for core interfaces and extension points.

Usage Example

import (
    "github.com/effective-security/gogentic/assistants"
    "github.com/effective-security/gogentic/tools"
)

// Define and register tools, create an assistant, and run agentic flows...

Coding Guidelines

See AGENTS.md for detailed coding standards, error handling, and testing practices.

  • Use require and assert from testify for tests
  • Use cockroachdb/errors for error handling
  • Prefer table-driven and parallel tests
  • Document all exported types, functions, and interfaces

Contributing

  • Run make lint and make test before submitting PRs
  • Follow the guidelines in AGENTS.md

License

Apache 2.0

Directories

Path Synopsis
Package assistants provides the core logic for building LLM agents: orchestration, tool integration, callbacks, and structured I/O.
Package assistants provides the core logic for building LLM agents: orchestration, tool integration, callbacks, and structured I/O.
Package chatmodel defines common chat I/O types, context helpers, and parser interfaces used across the project.
Package chatmodel defines common chat I/O types, context helpers, and parser interfaces used across the project.
Package encoding provides a pluggable framework to describe, encode and decode structured data for agentic flows.
Package encoding provides a pluggable framework to describe, encode and decode structured data for agentic flows.
dummy
Package dummy encoder/decoder
Package dummy encoder/decoder
json
Package json json encoder/decoder
Package json json encoder/decoder
toml
Package toml encoder/decoder
Package toml encoder/decoder
yaml
Package yaml encoder/decoder
Package yaml encoder/decoder
mcp
Package mcp implements the Model Context Protocol client/server and common transports (stdio, HTTP/SSE, local).
Package mcp implements the Model Context Protocol client/server and common transports (stdio, HTTP/SSE, local).
internal/protocol
This file implements the core protocol layer for JSON-RPC communication in the MCP SDK.
This file implements the core protocol layer for JSON-RPC communication in the MCP SDK.
transport
Package transport defines the minimal interfaces and shared types for MCP transports used by the client and server.
Package transport defines the minimal interfaces and shared types for MCP transports used by the client and server.
transport/localtransport
Package localtransport implements local transport mechanisms for MCP, enabling efficient in-process and local communication for agentic flows.
Package localtransport implements local transport mechanisms for MCP, enabling efficient in-process and local communication for agentic flows.
transport/sse
Package sse implements Server-Sent Events (SSE) transport for MCP, enabling real-time, bidirectional communication for agentic flows over HTTP.
Package sse implements Server-Sent Events (SSE) transport for MCP, enabling real-time, bidirectional communication for agentic flows over HTTP.
transport/sse/internal/sse
Package sse provides the low-level implementation of Server-Sent Events (SSE) transport for MCP, handling connection management, message streaming, and protocol details.
Package sse provides the low-level implementation of Server-Sent Events (SSE) transport for MCP, handling connection management, message streaming, and protocol details.
transport/stdio/internal/stdio
This file implements the stdio transport layer for JSON-RPC communication.
This file implements the stdio transport layer for JSON-RPC communication.
Package mocks provides mock implementations of assistants, tools, and LLMs for testing and development purposes.
Package mocks provides mock implementations of assistants, tools, and LLMs for testing and development purposes.
mockassitants
Package mockassitants is a generated GoMock package.
Package mockassitants is a generated GoMock package.
mockllmfactory
Package mockllmfactory is a generated GoMock package.
Package mockllmfactory is a generated GoMock package.
mockllms
Package mockllms is a generated GoMock package.
Package mockllms is a generated GoMock package.
mocktools
Package mocktools is a generated GoMock package.
Package mocktools is a generated GoMock package.
pkg
llmfactory
Package llmfactory constructs provider models from configuration, resolves assistant→model preferences (with optional per‑org overrides), and supports capability filtering and per‑org model restrictions.
Package llmfactory constructs provider models from configuration, resolves assistant→model preferences (with optional per‑org overrides), and supports capability filtering and per‑org model restrictions.
llms
Package llms provides unified support for interacting with different Language Models (LLMs) from various providers.
Package llms provides unified support for interacting with different Language Models (LLMs) from various providers.
llms/anthropic
Package anthropic implements the Anthropic (Claude) llms.Model with options for API key, model selection, and custom HTTP client or AWS config when used via Bedrock (see NewBedrock in this package).
Package anthropic implements the Anthropic (Claude) llms.Model with options for API key, model selection, and custom HTTP client or AWS config when used via Bedrock (see NewBedrock in this package).
llms/bedrock
Package bedrock implements an llms.Model backed by AWS Bedrock.
Package bedrock implements an llms.Model backed by AWS Bedrock.
llms/cloudflare
Package cloudflare implements an llms.Model for Cloudflare AI Gateway and compatible APIs.
Package cloudflare implements an llms.Model for Cloudflare AI Gateway and compatible APIs.
llms/googleai
Package googleai implements Google AI (Vertex/Gemini) llms.Model wrappers.
Package googleai implements Google AI (Vertex/Gemini) llms.Model wrappers.
llms/googleai/internal/cmd command
Code generator for vertex.go from googleai.go nolint
Code generator for vertex.go from googleai.go nolint
llms/openai
Package openai provides an llms.Model implementation for OpenAI-compatible APIs, including OpenAI and Azure OpenAI endpoints.
Package openai provides an llms.Model implementation for OpenAI-compatible APIs, including OpenAI and Azure OpenAI endpoints.
llmutils
Package llmutils provides utilities for formatting prompts, cleaning model outputs, rendering data as JSON/YAML/markdown, and inspecting chat messages.
Package llmutils provides utilities for formatting prompts, cleaning model outputs, rendering data as JSON/YAML/markdown, and inspecting chat messages.
prompts
Package prompts contains prompt templates and utilities for working with LLMs.
Package prompts contains prompt templates and utilities for working with LLMs.
prompts/internal/fstring
Package fstring contains template format with f-string.
Package fstring contains template format with f-string.
schema
Package schema provides helpers to generate JSON Schemas from Go types and shape those schemas for LLM prompting.
Package schema provides helpers to generate JSON Schemas from Go types and shape those schemas for LLM prompting.
Package skills implements the Agent Skills open standard (https://agentskills.io) for AI assistants.
Package skills implements the Agent Skills open standard (https://agentskills.io) for AI assistants.
Package store provides interfaces and implementations for chat and message storage, supporting in-memory and Redis backends for agentic flows.
Package store provides interfaces and implementations for chat and message storage, supporting in-memory and Redis backends for agentic flows.
Package tools defines the Tool interface for LLM agents, including registration, parameter schema, and MCP integration.
Package tools defines the Tool interface for LLM agents, including registration, parameter schema, and MCP integration.

Jump to

Keyboard shortcuts

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