Replies: 2 comments
-
|
Hey there @mrochon! Quick clarifying question: are you asking whether you can include a variable in the system prompt that gets dynamically updated at runtime in your production app, or whether you can dynamically swap out variable values while editing and evaluating the prompt in our UI? If it's the former, yes, absolutely! You can use variables in the system prompt and feed in real-time data at runtime. Here's a demo video: field.demo.mp4And here's a sample .prompt.yml file that demonstrates this, with some placeholder testData you can play around with in the prompt editor or evaluator: messages:
- role: system
content: >-
You are a helpful assistant that writes oData filter expressions. Use the
following field names: {{field_names}}
- role: user
content: |
Please create oData filters using those fields for a basic query.
model: openai/gpt-4o
testData:
- field_names: 'Age, name'
- field_names: 'Age, name, height'
evaluators: []In your app, you’d use this prompt and dynamically inject the value for field_names based on your context. But if you’re asking about pulling in live data (e.g. calling an API) to populate the variable while editing the prompt in our UI, that’s not supported yet! Variables need to be filled in with test data (either uploaded via CSV, saved in your .prompt.yml, or input manually) when testing via the UI. |
Beta Was this translation helpful? Give feedback.
-
|
Great question! Currently, most YAML-based prompt configuration systems—including those used in GitHub Actions and many LLM integration tools—do not natively support variable interpolation within the system prompt using syntax like Workarounds and Best Practices
Example (Manual Replacement)messages:
- role: system
content: >-
Create oData filter expressions using [[FIELD_NAMES]]...
# Your code:
system_prompt = yaml_content.replace('[[FIELD_NAMES]]', ', '.join(field_names))Summary: If you’re using a specific tool or GitHub Action that claims to support this feature, please share its name—there may be tool-specific solutions or workarounds! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Question
Body
Is there any way to use a variable, e.g. {{myField}} in the system prompt in the yml file? I would like to test and compare my prompts using the comparer functionality but at run-time my code needs to dynamically replace certain values in the system prompt. I can obviously have my code look and replace a fixed value used in the yaml prompt but that make for somewhat in-elegant code. Here is what I would ideally like to do:
Beta Was this translation helpful? Give feedback.
All reactions