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.
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:
For more details please read from the original website.
- don't like python
- easy integrate into exists Golang projects
- better performance
go get -u github.com/bububa/atomic-agents
Atomic Agents with the following main components:
agents/
: The core Atomic Agents library
Agent[I schema.Schema, O schema.Schema]
: generative basic Agent, contains interfaces:TypeableAgent
StreamableAgent
AnonymousAgent
AnonymousStreamableAgent
Chain[I schema.Schema, O schema.Schema]
: an Agent which is a agents chainOrchestrationAgent[I schema.Schema, O schema.Schema]
: orchestration AgentToolAgent[I schema.Schema, T schema.Schema, O schema.Schema]
: Agent with toolRAG[O schema.Schema]
: RAG also implementsTypeableAgent
,StreamableAgent
,AnonymousAgent
andAnonymousStreamableAgent
interfaces
components/
: The Atomic Agents components
message
: Defines the Message structure for input/outputmemory
: Defines a in memory Memory Storesystemprompt
: Contains SystemPromptGenerator
andContextProvider
embedder
: Defines the embedder interface, contains severalProvider
includingOpenAI
,Gemini
,VoyageAI
,HuggingFace
,Cohere
implementationsvectordb
: Defines a vectordb interface, contains severalProvider
s includingMemory
,Chromem
,Milvus
document
Defines aDocument
interface use for RAG, implementedFile
,Http
document types. Provide aParser
interface which transform document content into specific stringparsers/pdf
: aPDF
parserparsers/html
: aHTML
parserparsers/docx
: aDOCx
parserparsers/pptx
: aPPTx
parserparsers/xlsx
: aXLSx
parser
schema/
: Defines the Input/Output schema structures and interfacesexamples/
: Example projects showcasing Atomic Agents usagetools/
: A collection of tools that can be used with Atomic Agents
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
}
This project is licensed under the MIT License—see the LICENSE file for details.