Introduction to the Agency Project
Agency is an innovative library tailored for developers who are enthusiastic about harnessing the potential of Large Language Models (LLMs) and other generative artificial intelligence technologies. It offers a clean, effective, and Go-idiomatic approach, making it a robust choice for those immersed in the Go language ecosystem.
Quick Start Guide
Getting started with Agency is straightforward. First, install the package using:
go get github.com/neurocult/agency
The library supports a variety of applications, including chat interfaces. Below is a simple example that demonstrates creating a chat assistant using the OpenAI API:
package main
import (
"bufio"
"context"
"fmt"
"os"
_ "github.com/joho/godotenv/autoload"
"github.com/neurocult/agency"
"github.com/neurocult/agency/providers/openai"
)
func main() {
assistant := openai.
New(openai.Params{Key: os.Getenv("OPENAI_API_KEY")}).
TextToText(openai.TextToTextParams{Model: "gpt-3.5-turbo"}).
SetPrompt("You are helpful assistant.")
messages := []agency.Message{}
reader := bufio.NewReader(os.Stdin)
ctx := context.Background()
for {
fmt.Print("User: ")
text, err := reader.ReadString('\n')
if err != nil {
panic(err)
}
input := agency.UserMessage(text)
answer, err := assistant.SetMessages(messages).Execute(ctx, input)
if err != nil {
panic(err)
}
fmt.Println("Assistant: ", answer)
messages = append(messages, input, answer)
}
}
This example sets up a simple conversation between a user and a virtual assistant, showcasing the library's ease of use.
Key Features
-
Pure Go: The library is fast and lightweight, written entirely in Go, eliminating the need to work with Python or JavaScript.
-
Clean Code and Architecture: Agency encourages developers to separate business logic from concrete implementations, ensuring code remains organized and understandable.
-
Customization: Developers can easily create custom operations by implementing simple interfaces.
-
Composable Processes: Operations can be composed together into structured processes, with the ability to observe each step through interceptors.
-
OpenAI API Support: Agency provides bindings for OpenAI APIs, supporting various functionalities like text-to-text, text-to-image, text-to-speech, and speech-to-text.
The Need for Agency
Agency isn't just another AI library; it's driven by the desire to empower its users to construct autonomous AI systems. Whether for building chat interfaces or conducting complex data analysis, Agency aims to simplify the creation and management of intelligent agents. This library fills a gap in the generative AI landscape, where Go-native solutions are scarce, by offering a clean and simple alternative prioritized on performance and static typing.
Tutorial and Roadmap
For those looking to dive deeper, there is a comprehensive tutorial available, with part 1 already released.
As for the future, several enhancements are planned:
- Support for external function calls
- Inclusion of metadata functionalities like token usage and audio duration
- Expansion of provider adapters beyond OpenAI
- Addition of image-to-text operations
- Development of a robust API for autonomous agents
- Implementation of tagging and JSON output parsing
Agency is committed to advancing the development and deployment of AI solutions, making them accessible through the elegance of Go language.