Documentation
¶
Index ¶
- Constants
- type Intermediate
- type Mock
- func (svc *Mock) AwaitDecision(ctx context.Context, flow *workflow.Flow, ...) (accepted bool, flightIndexOut int, err error)
- func (svc *Mock) BookFlight(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Mock) ChooseSeat(ctx context.Context, flow *workflow.Flow, seatPreference string, ...) (seat string, err error)
- func (svc *Mock) ChooseSeatAgent(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Mock) ConfirmBooking(ctx context.Context, flow *workflow.Flow, ...) (confirmation string, airline string, flightNo string, err error)
- func (svc *Mock) Demo(w http.ResponseWriter, r *http.Request) (err error)
- func (svc *Mock) MockAwaitDecision(...) *Mock
- func (svc *Mock) MockBookFlight(...) *Mock
- func (svc *Mock) MockChooseSeat(...) *Mock
- func (svc *Mock) MockChooseSeatAgent(...) *Mock
- func (svc *Mock) MockConfirmBooking(...) *Mock
- func (svc *Mock) MockDemo(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock
- func (svc *Mock) MockNoFlights(...) *Mock
- func (svc *Mock) MockPickSeat(...) *Mock
- func (svc *Mock) MockProposeFlight(...) *Mock
- func (svc *Mock) MockSearchFlights(...) *Mock
- func (svc *Mock) NoFlights(ctx context.Context, flow *workflow.Flow) (confirmation string, err error)
- func (svc *Mock) OnShutdown(ctx context.Context) (err error)
- func (svc *Mock) OnStartup(ctx context.Context) (err error)
- func (svc *Mock) PickSeat(ctx context.Context, flow *workflow.Flow, seatPreference string, ...) (seat string, err error)
- func (svc *Mock) ProposeFlight(ctx context.Context, flow *workflow.Flow, candidates []flightbookingapi.Flight, ...) (currentFlight flightbookingapi.Flight, exhausted bool, err error)
- func (svc *Mock) SearchFlights(ctx context.Context, flow *workflow.Flow, origin string, destination string) (candidates []flightbookingapi.Flight, flightIndex int, err error)
- type Service
- func (svc *Service) AwaitDecision(ctx context.Context, flow *workflow.Flow, ...) (accepted bool, flightIndexOut int, err error)
- func (svc *Service) BookFlight(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Service) ChooseSeat(ctx context.Context, flow *workflow.Flow, seatPreference string, ...) (seat string, err error)
- func (svc *Service) ChooseSeatAgent(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Service) ConfirmBooking(ctx context.Context, flow *workflow.Flow, ...) (confirmation string, airline string, flightNo string, err error)
- func (svc *Service) Demo(w http.ResponseWriter, r *http.Request) (err error)
- func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service
- func (svc *Service) NoFlights(ctx context.Context, flow *workflow.Flow) (confirmation string, err error)
- func (svc *Service) OnShutdown(ctx context.Context) (err error)
- func (svc *Service) OnStartup(ctx context.Context) (err error)
- func (svc *Service) PickSeat(ctx context.Context, flow *workflow.Flow, seatPreference string, ...) (seat string, err error)
- func (svc *Service) ProposeFlight(ctx context.Context, flow *workflow.Flow, candidates []flightbookingapi.Flight, ...) (currentFlight flightbookingapi.Flight, exhausted bool, err error)
- func (svc *Service) SearchFlights(ctx context.Context, flow *workflow.Flow, origin string, destination string) (candidates []flightbookingapi.Flight, flightIndex int, err error)
- type ToDo
Constants ¶
const ( Hostname = flightbookingapi.Hostname Version = flightbookingapi.Version Description = flightbookingapi.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) AwaitDecision ¶
func (svc *Mock) AwaitDecision(ctx context.Context, flow *workflow.Flow, currentFlight flightbookingapi.Flight, flightIndex int) (accepted bool, flightIndexOut int, err error)
AwaitDecision executes the mock handler.
func (*Mock) BookFlight ¶
BookFlight returns the workflow graph, or a mocked graph if MockBookFlight was called.
func (*Mock) ChooseSeat ¶
func (svc *Mock) ChooseSeat(ctx context.Context, flow *workflow.Flow, seatPreference string, currentFlight flightbookingapi.Flight) (seat string, err error)
ChooseSeat executes the mock handler.
func (*Mock) ChooseSeatAgent ¶
ChooseSeatAgent returns the workflow graph, or a mocked graph if MockChooseSeatAgent was called.
func (*Mock) ConfirmBooking ¶
func (svc *Mock) ConfirmBooking(ctx context.Context, flow *workflow.Flow, currentFlight flightbookingapi.Flight, seat string) (confirmation string, airline string, flightNo string, err error)
ConfirmBooking executes the mock handler.
func (*Mock) MockAwaitDecision ¶
func (svc *Mock) MockAwaitDecision(handler func(ctx context.Context, flow *workflow.Flow, currentFlight flightbookingapi.Flight, flightIndex int) (accepted bool, flightIndexOut int, err error)) *Mock
MockAwaitDecision sets up a mock handler for AwaitDecision.
func (*Mock) MockBookFlight ¶
func (svc *Mock) MockBookFlight(handler func(ctx context.Context, flow *workflow.Flow, origin string, destination string, seatPreference string) (confirmation string, airline string, flightNo string, seat string, err error)) *Mock
MockBookFlight sets up a mock handler for the BookFlight workflow. The handler receives typed inputs from the workflow's state and returns typed outputs. A nil handler clears the mock.
func (*Mock) MockChooseSeat ¶
func (svc *Mock) MockChooseSeat(handler func(ctx context.Context, flow *workflow.Flow, seatPreference string, currentFlight flightbookingapi.Flight) (seat string, err error)) *Mock
MockChooseSeat sets up a mock handler for ChooseSeat.
func (*Mock) MockChooseSeatAgent ¶
func (svc *Mock) MockChooseSeatAgent(handler func(ctx context.Context, flow *workflow.Flow, seatPreference string, availableSeats []string) (seat string, err error)) *Mock
MockChooseSeatAgent sets up a mock handler for the ChooseSeatAgent workflow. The handler receives typed inputs from the workflow's state and returns typed outputs. A nil handler clears the mock.
func (*Mock) MockConfirmBooking ¶
func (svc *Mock) MockConfirmBooking(handler func(ctx context.Context, flow *workflow.Flow, currentFlight flightbookingapi.Flight, seat string) (confirmation string, airline string, flightNo string, err error)) *Mock
MockConfirmBooking sets up a mock handler for ConfirmBooking.
func (*Mock) MockNoFlights ¶
func (svc *Mock) MockNoFlights(handler func(ctx context.Context, flow *workflow.Flow) (confirmation string, err error)) *Mock
MockNoFlights sets up a mock handler for NoFlights.
func (*Mock) MockPickSeat ¶
func (svc *Mock) MockPickSeat(handler func(ctx context.Context, flow *workflow.Flow, seatPreference string, availableSeats []string) (seat string, err error)) *Mock
MockPickSeat sets up a mock handler for PickSeat.
func (*Mock) MockProposeFlight ¶
func (svc *Mock) MockProposeFlight(handler func(ctx context.Context, flow *workflow.Flow, candidates []flightbookingapi.Flight, flightIndex int) (currentFlight flightbookingapi.Flight, exhausted bool, err error)) *Mock
MockProposeFlight sets up a mock handler for ProposeFlight.
func (*Mock) MockSearchFlights ¶
func (svc *Mock) MockSearchFlights(handler func(ctx context.Context, flow *workflow.Flow, origin string, destination string) (candidates []flightbookingapi.Flight, flightIndex int, err error)) *Mock
MockSearchFlights sets up a mock handler for SearchFlights.
func (*Mock) NoFlights ¶
func (svc *Mock) NoFlights(ctx context.Context, flow *workflow.Flow) (confirmation string, err error)
NoFlights executes the mock handler.
func (*Mock) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
func (*Mock) PickSeat ¶
func (svc *Mock) PickSeat(ctx context.Context, flow *workflow.Flow, seatPreference string, availableSeats []string) (seat string, err error)
PickSeat executes the mock handler.
func (*Mock) ProposeFlight ¶
func (svc *Mock) ProposeFlight(ctx context.Context, flow *workflow.Flow, candidates []flightbookingapi.Flight, flightIndex int) (currentFlight flightbookingapi.Flight, exhausted bool, err error)
ProposeFlight executes the mock handler.
type Service ¶
type Service struct {
*Intermediate // IMPORTANT: Do not remove
}
Service implements the flightbooking.example agent. It runs a durable BookFlight workflow that searches a route, proposes candidate flights one at a time, parks on a human accept/keep-searching decision, and on acceptance delegates seat selection to a child LLM workflow before confirming the booking.
func (*Service) AwaitDecision ¶
func (svc *Service) AwaitDecision(ctx context.Context, flow *workflow.Flow, currentFlight flightbookingapi.Flight, flightIndex int) (accepted bool, flightIndexOut int, err error)
AwaitDecision parks the flow on a human accept/keep-searching decision for the proposed flight and advances to the next candidate when the traveler keeps searching.
func (*Service) BookFlight ¶
BookFlight is the top-level agentic workflow. It searches the route, then loops proposing one candidate flight at a time and parking on a human accept/keep-searching decision via Interrupt. On acceptance it invokes the ChooseSeatAgent child workflow as an isolated subgraph to pick a seat, then confirms the booking.
func (*Service) ChooseSeat ¶
func (svc *Service) ChooseSeat(ctx context.Context, flow *workflow.Flow, seatPreference string, currentFlight flightbookingapi.Flight) (seat string, err error)
ChooseSeat delegates seat selection for the accepted flight to the ChooseSeatAgent child workflow.
func (*Service) ChooseSeatAgent ¶
ChooseSeatAgent is a child workflow that selects a single seat from a flight's available seats to match a natural-language preference. It is invoked as an isolated subgraph by the BookFlight workflow's ChooseSeat task.
func (*Service) ConfirmBooking ¶
func (svc *Service) ConfirmBooking(ctx context.Context, flow *workflow.Flow, currentFlight flightbookingapi.Flight, seat string) (confirmation string, airline string, flightNo string, err error)
ConfirmBooking finalizes the booking of the accepted flight and chosen seat into a confirmation.
func (*Service) Demo ¶
Demo serves the human-in-the-loop demo page that drives the BookFlight workflow, presenting each proposed flight and resuming the parked flow with the traveler's accept or keep-searching decision.
func (*Service) NoFlights ¶
func (svc *Service) NoFlights(ctx context.Context, flow *workflow.Flow) (confirmation string, err error)
NoFlights ends the workflow with a not-booked message when no flight is available or every candidate is declined.
func (*Service) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
func (*Service) PickSeat ¶
func (svc *Service) PickSeat(ctx context.Context, flow *workflow.Flow, seatPreference string, availableSeats []string) (seat string, err error)
PickSeat asks the LLM to choose one seat from the available list that best matches the traveler's preference.
func (*Service) ProposeFlight ¶
func (svc *Service) ProposeFlight(ctx context.Context, flow *workflow.Flow, candidates []flightbookingapi.Flight, flightIndex int) (currentFlight flightbookingapi.Flight, exhausted bool, err error)
ProposeFlight selects the candidate at the current index, or marks the search exhausted when the list runs out.
func (*Service) SearchFlights ¶
func (svc *Service) SearchFlights(ctx context.Context, flow *workflow.Flow, origin string, destination string) (candidates []flightbookingapi.Flight, flightIndex int, err error)
SearchFlights looks up the flights serving a route and seeds the candidate list for the workflow to propose.
type ToDo ¶
type ToDo interface {
OnStartup(ctx context.Context) (err error)
OnShutdown(ctx context.Context) (err error)
Demo(w http.ResponseWriter, r *http.Request) (err error) // MARKER: Demo
SearchFlights(ctx context.Context, flow *workflow.Flow, origin string, destination string) (candidates []flightbookingapi.Flight, flightIndex int, err error) // MARKER: SearchFlights
ProposeFlight(ctx context.Context, flow *workflow.Flow, candidates []flightbookingapi.Flight, flightIndex int) (currentFlight flightbookingapi.Flight, exhausted bool, err error) // MARKER: ProposeFlight
AwaitDecision(ctx context.Context, flow *workflow.Flow, currentFlight flightbookingapi.Flight, flightIndex int) (accepted bool, flightIndexOut int, err error) // MARKER: AwaitDecision
ChooseSeat(ctx context.Context, flow *workflow.Flow, seatPreference string, currentFlight flightbookingapi.Flight) (seat string, err error) // MARKER: ChooseSeat
ConfirmBooking(ctx context.Context, flow *workflow.Flow, currentFlight flightbookingapi.Flight, seat string) (confirmation string, airline string, flightNo string, err error) // MARKER: ConfirmBooking
NoFlights(ctx context.Context, flow *workflow.Flow) (confirmation string, err error) // MARKER: NoFlights
PickSeat(ctx context.Context, flow *workflow.Flow, seatPreference string, availableSeats []string) (seat string, err error) // MARKER: PickSeat
BookFlight(ctx context.Context) (graph *workflow.Graph, err error) // MARKER: BookFlight
ChooseSeatAgent(ctx context.Context) (graph *workflow.Graph, err error) // MARKER: ChooseSeatAgent
}
ToDo is implemented by the service or mock. The intermediate delegates handling to this interface.