package main
import (
"context"
"log"
"github.com/curaious/uno/pkg/agent-framework/core"
"github.com/curaious/uno/pkg/agent-framework/history"
"github.com/curaious/uno/pkg/agent-framework/summariser"
"github.com/curaious/uno/pkg/gateway"
"github.com/curaious/uno/pkg/llm"
"github.com/curaious/uno/pkg/llm/responses"
"github.com/curaious/uno/pkg/sdk"
)
func main() {
// Initialize SDK client
client, err := sdk.New(&sdk.ClientOptions{
LLMConfigs: sdk.NewInMemoryConfigStore([]*gateway.ProviderConfig{
{
ProviderName: llm.ProviderNameOpenAI,
BaseURL: "",
CustomHeaders: nil,
ApiKeys: []*gateway.APIKeyConfig{
{
Name: "Key 1",
APIKey: "",
},
},
},
}),
})
if err != nil {
log.Fatal(err)
}
// Create main agent LLM
model := client.NewLLM(sdk.LLMOptions{
Provider: llm.ProviderNameOpenAI,
Model: "gpt-4o-mini",
})
// Create summarizer LLM (can use a cheaper/faster model)
summarizerLLM := client.NewLLM(sdk.LLMOptions{
Provider: llm.ProviderNameOpenAI,
Model: "gpt-4o-mini",
})
// Create summarizer instruction
summarizerInstruction := client.Prompt(
"You are a conversation summarizer. Create concise summaries that preserve important context, decisions, and information needed for future interactions.",
)
// Create LLM summarizer
summarizer := summariser.NewLLMHistorySummarizer(&summariser.LLMHistorySummarizerOptions{
LLM: summarizerLLM,
InstructionProvider: summarizerInstruction,
TokenThreshold: 1000, // Summarize when tokens exceed 1000
KeepRecentCount: 5, // Keep last 5 runs
Parameters: responses.Parameters{},
})
// Create conversation manager with summarizer
history := client.NewConversationManager(
history.WithSummarizer(summarizer),
)
// Create agent with history
agent := client.NewAgent(&sdk.AgentOptions{
Name: "Assistant",
Instruction: client.Prompt("You are a helpful assistant."),
LLM: model,
History: history,
})
// Execute agent (summarization happens automatically when threshold is exceeded)
out, err := agent.Execute(context.Background(), &agents.AgentInput{
Messages: []responses.InputMessageUnion{
responses.UserMessage("Hello!"),
},
})
if err != nil {
log.Fatal(err)
}
log.Println(out[0].OfOutputMessage.Content[0].OfOutputText.Text)
}