atomic-agents

module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: MIT

README

Atomic Agents Golang version

Go Reference Go goreleaser GitHub go.mod Go version of a Go module GoReportCard GitHub license GitHub release

Building AI agents, atomically. This is an implementation for Atomic Agents in Golang.

The Atomic Agents framework is designed around the concept of atomicity to be an extremely lightweight and modular framework for building Agentic AI pipelines and applications without sacrificing developer experience and maintainability. The framework provides a set of tools and agents that can be combined to create powerful applications. It is built on top of instructor and leverages the power of jsonschema for data and schema validation and serialization. All logic and control flows are written in Golang, enabling developers to apply familiar best practices and workflows from traditional software development without compromising flexibility or clarity.

Anatomy of an Agent

In Atomic Agents, an agent is composed of several key components:

  • System Prompt: Defines the agent's behavior and purpose.
  • Input Schema: Specifies the structure and validation rules for the agent's input.
  • Output Schema: Specifies the structure and validation rules for the agent's output.
  • Memory: Stores conversation history or other relevant data.
  • Context Providers: Inject dynamic context into the agent's system prompt at runtime.

Here's a high-level architecture diagram:

High-level architecture overview of Atomic Agents Diagram showing what is sent to the LLM in the prompt

For more details please read from the original website.

Why reinvent wheel

  • don't like python
  • easy integrate into exists Golang projects
  • better performance

Installation

go get -u github.com/bububa/atomic-agents

Project Structure

Atomic Agents with the following main components:

  1. agents/: The core Atomic Agents library
  2. components/: The Atomic Agents components contains Message, Memory, SystemPromptGenerator, SystemPromptContextProvider utilities
  3. schema/: Defines the Input/Output schema structures and interfaces
  4. examples/: Example projects showcasing Atomic Agents usage
  5. tools/: A collection of tools that can be used with Atomic Agents

Quickstart & Examples

A complete list of examples can be found in the examples directory.

Here's a quick snippet demonstrating how easy it is to create a powerful agent with Atomic Agents:

package main

import (
	"context"
	"fmt"

	"github.com/bububa/atomic-agents/agents"
	"github.com/bububa/atomic-agents/components"
	"github.com/bububa/atomic-agents/schema"
)

func main() {
	ctx := context.Background()
	mem := components.NewMemory(10)
	initMsg := mem.NewMessage(components.AssistantRole, schema.CreateOutput("Hello! How can I assist you today?"))
	agent := agents.NewAgent[schema.Input, schema.Output](
		agents.WithClient(newInstructor()),
		agents.WithMemory(mem),
		agents.WithModel("gpt-4o-mini"),
		agents.WithTemperature(0.5),
		agents.WithMaxTokens(1000))
	output := schema.NewOutput("")
	input := schema.NewInput("Today is 2024-01-01, only response with the date without any other words")
	if err := agent.Run(ctx, input, output); err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(agent.SystemPrompt())
	fmt.Println("")
	fmt.Printf("Agent: %s\n", initMsg.Content().(schema.Output).ChatMessage)
	fmt.Printf("User: %s\n", input.ChatMessage)
	fmt.Printf("Agent: %s\n", output.ChatMessage)
	// Output:
	// # IDENTITY and PURPOSE
	// - This is a conversation with a helpful and friendly AI assistant.
	//
	// # OUTPUT INSTRUCTIONS
	// - Always respond using the proper JSON schema.
	// - Always use the available additional information and context to enhance the response.
	//
	// Agent: Hello! How can I assist you today?
	// User: Today is 2024-01-01, only response with the date without any other words
	// Agent: 2024-01-01
}

License

This project is licensed under the MIT License—see the LICENSE file for details.

Directories

Path Synopsis
Package agents include BaseAgent
Package agents include BaseAgent
Package components includes AgentMemory etc.
Package components includes AgentMemory etc.
optimizer
Package optimizer provides prompt optimization capabilities for Language Learning Models.
Package optimizer provides prompt optimization capabilities for Language Learning Models.
orchestration
Package Orchestration # Orchestration Agent Example This example demonstrates how to create an Orchestrator Agent that intelligently decides between using a search tool or a calculator tool based on user input.
Package Orchestration # Orchestration Agent Example This example demonstrates how to create an Orchestrator Agent that intelligently decides between using a search tool or a calculator tool based on user input.
quickstart
Package quickstart quickstart examples for the Atomic Agents project.
Package quickstart quickstart examples for the Atomic Agents project.
vision
Package vision Basic Vision Example This example demonstrates how to use the Atomic Agents framework to analyze images with text, specifically focusing on extracting structured information from nutrition labels using GPT-4 Vision capabilities.
Package vision Basic Vision Example This example demonstrates how to use the Atomic Agents framework to analyze images with text, specifically focusing on extracting structured information from nutrition labels using GPT-4 Vision capabilities.
websearch
Package websearch demonstrates an intelligent web search agent built using the Atomic Agents framework.
Package websearch demonstrates an intelligent web search agent built using the Atomic Agents framework.
Pachage schema include BaseIOSchema etc.
Pachage schema include BaseIOSchema etc.
calculator
Package calculator The Calculator Tool is a utility within the Atomic Agents ecosystem designed for performing a variety of mathematical calculations.
Package calculator The Calculator Tool is a utility within the Atomic Agents ecosystem designed for performing a variety of mathematical calculations.
orchestration
Package orchestration includes tools orchestration
Package orchestration includes tools orchestration
searxng
Package searxng The SearxNG Search Tool is a powerful utility within the Atomic Agents ecosystem that allows you to perform searches using SearxNG, a privacy-respecting metasearch engine.
Package searxng The SearxNG Search Tool is a powerful utility within the Atomic Agents ecosystem that allows you to perform searches using SearxNG, a privacy-respecting metasearch engine.
webscraper
Package webscraper The Webpage Scraper Tool is a utility within the Atomic Agents ecosystem designed for scraping web content and converting it to markdown format.
Package webscraper The Webpage Scraper Tool is a utility within the Atomic Agents ecosystem designed for scraping web content and converting it to markdown format.

Jump to

Keyboard shortcuts

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