Hi There how can I specify code in th prompt that can be used by llm_classify ? I am unable to escape the code using {{ My prompt looks xomething like:
lorem ipsum
ruby script:
'''ruby
'''
typescript script:
'''typescript
'''It seems likely that you are trying to include code snippets within a prompt using Mustache formatting, which uses {{ and }} for placeholders. To escape these characters, you can use triple braces {{{ and }}} or escape them with a backslash. However, the specific method for escaping may depend on the context in which you are using the prompt.If you are using Phoenix, you can format your prompt using Mustache or F-string formats. For Mustache, you can escape variables by using triple braces or by adding a backslash before the braces. For example, to include a code snippet, you might use: LBKS{{{code_snippet}}}LBKSWould you like more details on how to implement this in your specific use case?Sources:
- Prompt Format
馃挕聽Hint: Mention RunLLM in the thread for followups.
Tried the following: Prompt:
lorem ipsum
ruby script:
{{{ruby}}}
typescript script:
{{{typescript}}}Where
ruby = """
'''ruby
code
'''
"""
typescript = """
'''typescript
code
'''
"""
prompt.replace("{ruby}", ruby).replace("{typescript}", typescript)Does not help
Can you use single braces?
Like:
lorem ipsum
ruby script:
{ruby}
typescript script:
{typescript}Does not work hitting the same issue as before:
Retries exhausted after 1 attempts: Missing template variable: ' report 'This I believe is caused due to this line in typescript code:
import { report } from 'mylib';This is inelegant, but can you try escaping braces inside your TS code. So
import {{ report }} from 'mylib';The other thing you can try is the template parameter to llm_classify takes in a delimiters argument. You can pass custom delimiters such as ("{{{", "}}}")
Will passing the prompt as a markdown work?
The problem with {{ approach is it becomes unwieldy dealing with nested code blocks
I hear you. Can you try to custom delimiters?
Like so?
logic_eval = llm_classify(
dataframe = code_gen_df,
template = LOGIC_LLM_JUDGE_PROMPT.replace("{ruby}", ruby).replace("{typescript}", typescript),
rails = ['logically_correct', 'logically_correct'],
model=LiteLLMModel(model="ollama/llama3.2:latest"),
provide_explanation=True,
delimiters = ("{{{", "}}}"),
)llm_classify does not like it:
TypeError: got an unexpected keyword argument 'delimitersIt's actually an argument on the template parameter. So you could do something like LOGIC_LLM_JUDGE_PROMPT.delimiters = ...
Or pass the delimiters when you define that template
