sublayerapp / sublayer

A model-agnostic Ruby Generative AI DSL and framework. Provides base classes for building Generators, Actions, Tasks, and Agents that can be used to build AI powered applications in Ruby.
https://docs.sublayer.com
MIT License
98 stars 1 forks source link

DSL for prompt #75

Open swerner opened 3 weeks ago

swerner commented 3 weeks ago

I know its easy to get started with just a string prompt, but I've been thinking an easier to use DSL for prompting might make it possible to do more complicated techniques without writing a long paragraph.

This could also make it easier to do things like RAG, attaching files, audio, video, etc, run different models, insert randomness (Oblique Strategies) into the prompt, or enable essentially a "Prompt Currying" workflow. It also allows us to bake in techniques/deprecate outdated techniques, target techniques to certain models, etc.

In my mind I'm thinking something very similar to what activerecord has with being able to chain methods together that all return the self, but only generate the final result once its needed.

Rough sketch, but something like:

def prompt
  role("Expert programmer in #{@technologies.join(", ")}").
  instructions("write code using #{@technologies.join(", ")}").
  task(@task_description).
  examples(retrieve_task_examples(@task_description)).
  validate_response_with(@task_validator).
  compare_responses_between(:gpt-4o, :claude-3.5, :gemini-1.5-flash).
  use_chain_of_thought
end
mdeering commented 3 weeks ago

I'm looking at liquid and its Context for this.
https://www.rubydoc.info/gems/liquid/Liquid/Context

Powers Shopify's theme system for theirs store fronts.

swerner commented 3 weeks ago

Oh interesting! I'm not super familiar with Liquid, I'll look into this, thanks!