Shopify / Shopify/liquid

Is it possible to implement something like Microsoft Guidance with Liquid template?

Open
#1,723 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
11.9k
Forks
1.5k
Avg merge
17h 55m
Merged PRs (30d)
3

Description

Hello,
I've one question: I've found a python library made from microsoft: https://github.com/microsoft/guidance
In this library they have a prompt that's interleaved by "methods" that make the prompt built progressively.

Let see an example from their home page:

# connect to a chat model like GPT-4 or Vicuna
gpt4 = guidance.llms.OpenAI("gpt-4")
# vicuna = guidance.llms.transformers.Vicuna("your_path/vicuna_13B", device_map="auto")

experts = guidance('''
{{#system~}}
You are a helpful and terse assistant.
{{~/system}}

{{#user~}}
I want a response to the following question:
{{query}}
Name 3 world-class experts (past or present) who would be great at answering this?
Don't answer the question yet.
{{~/user}}

{{#assistant~}}
{{gen 'expert_names' temperature=0 max_tokens=300}}
{{~/assistant}}

{{#user~}}
Great, now please answer the question as if these experts had collaborated in writing a joint anonymous answer.
{{~/user}}

{{#assistant~}}
{{gen 'answer' temperature=0 max_tokens=500}}
{{~/assistant}}
''', llm=gpt4)

experts(query='How can I be more productive?')

they surround some text with a tag system

{{#system~}}
You are a helpful and terse assistant.
{{~/system}}

(this is possible, so move one)

Then they have another tag that specify the user prompt

{{#user~}}
I want a response to the following question:
{{query}}
Name 3 world-class experts (past or present) who would be great at answering this?
Don't answer the question yet.
{{~/user}}

Then they have an assistant block and within it there is a call to their gen method

{{#assistant~}}
{{gen 'expert_names' temperature=0 max_tokens=300}}
{{~/assistant}}

From my understanding, that library builds the text generated in the prompt so far, and use it as a LLM prompt to a specific model (this is just a technical details, what I mean is that they build the prompt up to that gen function call), then they place the result of that gen call and place it within the assistant tag, and keep build up to the next gen call, if any.

This is a very effective way to build a prompt for LLM and I was trying to understand if Liquid allows this kind of behavior out of the box, or where I should look into to implement this kind of feature.

Thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are mentioned. Start by reviewing Liquid's existing tag and rendering behavior alongside the cited Microsoft Guidance examples, then clarify the intended execution model, API, and completion criteria before estimating an implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, ruby
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.