Code Monkey home page Code Monkey logo

Comments (5)

milesj avatar milesj commented on May 20, 2024 1

Landing some of this here: #1398

from moon.

milesj avatar milesj commented on May 20, 2024

All great ideas. A few comments:

  • Sort prompts - Would an order config for each prompt be enough for this?
  • Conditional prompts - This seems tricky, but maybe doable if other things land first.
  • Internal variables - Easy enough.
  • Dynamic template chain - Would have to look into.
  • Automatic template help - We'll be adding template related commands in the future.
  • Shared mutable memory properties - Would have to look into.
  • Iterate variables - I think you can use __tera_context for this: https://keats.github.io/tera/docs/#variables

from moon.

svallory avatar svallory commented on May 20, 2024

@milesj great to hear there are! I see moon as the tool that will be always there, so the greater its template support the better! 🥳

from moon.

svallory avatar svallory commented on May 20, 2024

Looks like I forgot to actually send the detailed response:

  • Sort prompts - Would an order config for each prompt be enough for this?

For sorting, yes. But if you ever want to support prompt flows, maybe it is better to move it to an array of objects.

  • Conditional prompts - This seems tricky, but maybe doable if other things land first.

There's a way you can add features little by little and get conditional, and a more flexible prompt flow, way better than sorted

  1. Make it an array which allows ordering
  2. Make it a tree by add a prompts property to a prompt. Order moves to a depth-first tree walk
  3. add a guard|when property to the prompt, and only go down the tree if the parent value matches the guard

It could look something like this (I'm sure you'll pick better names):

variables:
  - name: color
    type: 'enum'
    values: ['red', 'green']
    default: 'red'
    prompt: 'Favorite color?'
    
    next: 
      # only one will execute
      # but that can be decided by the tree visitor
      # there's no need to pre-evaluate the flow
      - case: 'red' 
        name: question_1
        type: string
        prompt: 'Name 3 red fruits'

        next: # both will be executed
          # no case here
          - name: question_2
            type: string
            prompt: 'Another red question'

          # neither here
          - name: question_3
            type: string
            prompt: 'Another red question'

      - case: 'green'
        name: question_1
        type: string
        prompt: 'Name 3 mostly green country flags'
        next:
          - ...

I tried but it doesn't work. As they say, it is a magical... I guess it is magical because you can't touch it, only print it lol

from moon.

milesj avatar milesj commented on May 20, 2024

Landed some of these in v1.23.

from moon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.