Documentation
¶
Index ¶
- Constants
- type Intermediate
- type Mock
- func (svc *Mock) Answer(ctx context.Context, flow *workflow.Flow, question string) (answer string, err error)
- func (svc *Mock) Ask(ctx context.Context, q string) (answer string, err error)
- func (svc *Mock) AskAgent(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Mock) Forecast(ctx context.Context, lat float64, lng float64) (summary string, temperatureC float64, precipitationChance int, err error)
- func (svc *Mock) LatLng(ctx context.Context, location string) (lat float64, lng float64, err error)
- func (svc *Mock) MockAnswer(...) *Mock
- func (svc *Mock) MockAsk(handler func(ctx context.Context, q string) (answer string, err error)) *Mock
- func (svc *Mock) MockAskAgent(...) *Mock
- func (svc *Mock) MockForecast(...) *Mock
- func (svc *Mock) MockLatLng(...) *Mock
- func (svc *Mock) OnShutdown(ctx context.Context) (err error)
- func (svc *Mock) OnStartup(ctx context.Context) (err error)
- type Service
- func (svc *Service) Answer(ctx context.Context, flow *workflow.Flow, question string) (answer string, err error)
- func (svc *Service) Ask(ctx context.Context, q string) (answer string, err error)
- func (svc *Service) AskAgent(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Service) Forecast(ctx context.Context, lat float64, lng float64) (summary string, temperatureC float64, precipitationChance int, err error)
- func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service
- func (svc *Service) LatLng(ctx context.Context, location string) (lat float64, lng float64, err error)
- func (svc *Service) OnShutdown(ctx context.Context) (err error)
- func (svc *Service) OnStartup(ctx context.Context) (err error)
- type ToDo
Constants ¶
const ( Hostname = weatherapi.Hostname Version = weatherapi.Version Description = weatherapi.Description )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Intermediate ¶
Intermediate extends and customizes the generic base connector.
func NewIntermediate ¶
func NewIntermediate(impl ToDo) *Intermediate
NewIntermediate creates a new instance of the intermediate.
type Mock ¶
type Mock struct {
*Intermediate
// contains filtered or unexported fields
}
Mock is a mockable version of the microservice, allowing functions, event sinks and web handlers to be mocked.
func (*Mock) Answer ¶
func (svc *Mock) Answer(ctx context.Context, flow *workflow.Flow, question string) (answer string, err error)
Answer executes the mock handler.
func (*Mock) AskAgent ¶
AskAgent returns the workflow graph, or a mocked graph if MockAskAgent was called.
func (*Mock) Forecast ¶
func (svc *Mock) Forecast(ctx context.Context, lat float64, lng float64) (summary string, temperatureC float64, precipitationChance int, err error)
Forecast executes the mock handler.
func (*Mock) MockAnswer ¶
func (svc *Mock) MockAnswer(handler func(ctx context.Context, flow *workflow.Flow, question string) (answer string, err error)) *Mock
MockAnswer sets up a mock handler for Answer.
func (*Mock) MockAsk ¶
func (svc *Mock) MockAsk(handler func(ctx context.Context, q string) (answer string, err error)) *Mock
MockAsk sets up a mock handler for Ask.
func (*Mock) MockAskAgent ¶
func (svc *Mock) MockAskAgent(handler func(ctx context.Context, flow *workflow.Flow, question string) (answer string, err error)) *Mock
MockAskAgent sets up a mock handler for the AskAgent workflow. The handler receives typed inputs from the workflow's state and returns typed outputs. A nil handler clears the mock.
func (*Mock) MockForecast ¶
func (svc *Mock) MockForecast(handler func(ctx context.Context, lat float64, lng float64) (summary string, temperatureC float64, precipitationChance int, err error)) *Mock
MockForecast sets up a mock handler for Forecast.
func (*Mock) MockLatLng ¶
func (svc *Mock) MockLatLng(handler func(ctx context.Context, location string) (lat float64, lng float64, err error)) *Mock
MockLatLng sets up a mock handler for LatLng.
func (*Mock) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
type Service ¶
type Service struct {
*Intermediate // IMPORTANT: Do not remove
}
Service implements the weather.example agent, which answers natural-language weather questions. It geocodes a location to coordinates and fetches that location's forecast, exposing both as LLM tools and letting the model chain them to answer a question.
func (*Service) Answer ¶
func (svc *Service) Answer(ctx context.Context, flow *workflow.Flow, question string) (answer string, err error)
Answer runs the LLM tool-calling loop for a weather question, chaining the LatLng and Forecast tools, and returns the agent's reply.
func (*Service) Ask ¶
Ask runs the weather agent synchronously for a natural-language question and returns its answer. It executes the same tool-calling loop as the AskAgent workflow, but in-process via a single llm.core Chat call rather than as a durable workflow, giving the tour one browser-clickable endpoint.
func (*Service) AskAgent ¶
AskAgent answers a natural-language weather question. It runs the LLM tool-calling loop as a durable workflow, letting the model geocode a location with LatLng and fetch its forecast with Forecast before composing a reply.
func (*Service) Forecast ¶
func (svc *Service) Forecast(ctx context.Context, lat float64, lng float64) (summary string, temperatureC float64, precipitationChance int, err error)
Forecast returns the current weather forecast for a latitude/longitude coordinate.
func (*Service) LatLng ¶
func (svc *Service) LatLng(ctx context.Context, location string) (lat float64, lng float64, err error)
LatLng geocodes a location name into its latitude and longitude coordinates.
func (*Service) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
type ToDo ¶
type ToDo interface {
OnStartup(ctx context.Context) (err error)
OnShutdown(ctx context.Context) (err error)
LatLng(ctx context.Context, location string) (lat float64, lng float64, err error) // MARKER: LatLng
Forecast(ctx context.Context, lat float64, lng float64) (summary string, temperatureC float64, precipitationChance int, err error) // MARKER: Forecast
Ask(ctx context.Context, q string) (answer string, err error) // MARKER: Ask
Answer(ctx context.Context, flow *workflow.Flow, question string) (answer string, err error) // MARKER: Answer
AskAgent(ctx context.Context) (graph *workflow.Graph, err error) // MARKER: AskAgent
}
ToDo is implemented by the service or mock. The intermediate delegates handling to this interface.