micro-agent-go

command module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2025 License: MIT Imports: 4 Imported by: 0

README

Micro Agent

µAgent is a Go tiny library that simplifies the creation of AI agents using the OpenAI API. See it as a lightweight wrapper around the OpenAI Go SDK.

AI Agent is only a pattern. µAgent only helps you implement it faster.

You can use any LLM provider compatible with OpenAI API - I mainly work with Docker Model Runner.

Installation

To install the Micro Agent library, use go get:

go get github.com/micro-agent/micro-agent-go

Then import it in your Go code:

import mu "github.com/micro-agent/micro-agent-go/agent/mu"

Quick Start Example

func main() {

	ctx := context.Background()

    client := openai.NewClient(
		option.WithBaseURL("http://localhost:12434/engines/llama.cpp/v1"),
		option.WithAPIKey(""),
	)

	chatAgent, err := mu.NewAgent(ctx, "Bob",
		mu.WithClient(client),
		mu.WithParams(openai.ChatCompletionNewParams{
			Model:       "ai/qwen2.5:1.5B-F16",
			Temperature: openai.Opt(0.0),
			Messages:    []openai.ChatCompletionMessageParamUnion{},
		}),
	)
	if err != nil {
		panic(err)
	}

	_, err = chatAgent.RunStream(
		[]openai.ChatCompletionMessageParamUnion{
			openai.SystemMessage("Your name is Bob. You are a helpful AI assistant."),
			openai.UserMessage("Hello what is your name? What can you do for me?"),
		},
		func(content string) error {
			if content != "" {
				fmt.Print(content)
			}
			return nil 
		})

	if err != nil {
		panic(err)
	}
}

By default the completion add the message to the conversation history. You can reset the list of the messages (🚧 WIP).

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
agent
experimental/a2a
Package a2a provides experimental functionality for µ-agent.
Package a2a provides experimental functionality for µ-agent.
msg
mu
rag
ui

Jump to

Keyboard shortcuts

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