Patrones

Patrón: Encadenado y secuenciación de acciones

Garantizar el orden de varios pasos sin confiar en la memoria del modelo.

Fuente: patterns/ascript-patterns-action-chaining.md
Sequential Actions
reasoning:
  instructions: ->
    run @actions.lookup_current_order
      with member_email=@variables.member_email
      set @variables.order_summary=@outputs.order_summary

    run @actions.lookup_current_user
      with member_email=@variables.member_email
      set @variables.user_profile=@outputs.profile

    | Show the user their order summary and welcome them by name.

Acción encadenada a una tool

Cuando el LLM llame a my_action, el agente ejecutará other_action a continuación, siempre.

Chained Actions
actions:
  my_action: @actions.my_action
    with foo=@variables.Foo
    set @variables.status = @outputs.status
    run @actions.other_action
      set @variables.some_other_result=@outputs.data

Cadena condicional

Conditional Action Chain
reasoning:
  instructions: ->
    run @actions.check_eligibility
      with user_id=@variables.user_id
      set @variables.is_eligible=@outputs.eligible

    if @variables.is_eligible == True:
      run @actions.fetch_offer_details
        with user_id=@variables.user_id
        set @variables.offer=@outputs.offer
      | Present the offer: {!@variables.offer}
    else:
      | Explain that the user is not eligible for this offer.
Temas relacionados