Documentation
¶
Overview ¶
Package hostedagent adapts local API-backed models to the ADK agent interface.
The package centers on New, which wraps a google.golang.org/adk/model.LLM into an ADK agent. Helper constructors such as NewOpenAIModel and NewAIStudioModel build model implementations for common hosted providers.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New wraps a hosted model as an ADK agent.
Example ¶
package main
import (
"context"
"fmt"
"iter"
"google.golang.org/adk/model"
)
type exampleModel struct{}
func (exampleModel) Name() string {
return "example-model"
}
func (exampleModel) GenerateContent(context.Context, *model.LLMRequest, bool) iter.Seq2[*model.LLMResponse, error] {
return func(func(*model.LLMResponse, error) bool) {}
}
func main() {
agent, err := New(Config{
Name: "assistant",
Description: "Hosted assistant",
Model: exampleModel{},
})
if err != nil {
fmt.Println(err)
return
}
fmt.Println(agent.Name())
fmt.Println(agent.Description())
}
Output: assistant Hosted assistant
Types ¶
type Config ¶
type Config struct {
// Name is the ADK agent display name.
Name string
// Description is the ADK agent description.
Description string
// Instruction is appended after GlobalInstruction for each model request.
Instruction string
// GlobalInstruction is prepended before Instruction for each model request.
GlobalInstruction string
// Model handles underlying content generation.
Model model.LLM
}
Config describes an ADK agent backed by a hosted model implementation.
type OpenAIModel ¶
type OpenAIModel struct {
// contains filtered or unexported fields
}
OpenAIModel adapts the OpenAI chat completions API to the ADK model interface.
func NewOpenAIModel ¶
func NewOpenAIModel(apiKey, modelName string) (*OpenAIModel, error)
NewOpenAIModel creates an ADK-compatible model backed by the OpenAI API.
func (*OpenAIModel) GenerateContent ¶
func (m *OpenAIModel) GenerateContent(ctx context.Context, req *model.LLMRequest, _ bool) iter.Seq2[*model.LLMResponse, error]
GenerateContent sends a single non-streaming request to the OpenAI API.
func (*OpenAIModel) Name ¶
func (m *OpenAIModel) Name() string
Name returns the configured OpenAI model identifier.