Skip to content

Commit a990206

Browse files
committed
change prompt profile placeholder syntax to {var} (similar to agent syntax)
1 parent 493769a commit a990206

3 files changed

Lines changed: 38 additions & 38 deletions

File tree

docs/src/content/docs/guides/prompt-profiles.mdx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ BEGIN
5252
l_profile_id := uc_ai_prompt_profiles_api.create_prompt_profile(
5353
p_code => 'SUMMARIZE_TEXT',
5454
p_description => 'Summarizes text content in a specified style',
55-
p_system_prompt_template => 'You are a #style# assistant that creates concise summaries.',
56-
p_user_prompt_template => 'Summarize the following text: #text#',
55+
p_system_prompt_template => 'You are a {style} assistant that creates concise summaries.',
56+
p_user_prompt_template => 'Summarize the following text: {text}',
5757
p_provider => uc_ai.c_provider_openai,
5858
p_model => uc_ai_openai.c_model_gpt_4o_mini,
5959
p_version => 1,
@@ -69,7 +69,7 @@ END;
6969

7070
- `p_code`: Unique identifier for the profile
7171
- `p_description`: Human-readable description
72-
- `p_system_prompt_template`: System prompt with placeholders (`#placeholder#`)
72+
- `p_system_prompt_template`: System prompt with placeholders (`{placeholder}`)
7373
- `p_user_prompt_template`: User prompt with placeholders
7474
- `p_provider`: AI provider (e.g., `uc_ai.c_provider_openai`)
7575
- `p_model`: Model identifier (e.g., `uc_ai_openai.c_model_gpt_4o_mini`)
@@ -86,12 +86,12 @@ END;
8686

8787
## Using placeholders
8888

89-
Placeholders allow you to create dynamic prompts. Use `#placeholder_name#` syntax in your templates:
89+
Placeholders allow you to create dynamic prompts. Use `{placeholder_name}` syntax in your templates:
9090

9191
```sql
9292
-- Template with placeholders
93-
p_system_prompt_template => 'You are a #role# assistant.',
94-
p_user_prompt_template => 'What is the capital of #country#?'
93+
p_system_prompt_template => 'You are a {role} assistant.',
94+
p_user_prompt_template => 'What is the capital of {country}?'
9595
```
9696

9797
When executing the profile, provide values for the placeholders:
@@ -115,7 +115,7 @@ END;
115115
```
116116

117117
<Aside type="note">
118-
Placeholder matching is case-insensitive. Both `#Country#` and `#country#`
118+
Placeholder matching is case-insensitive. Both `{Country}` and `{country}`
119119
will match a parameter named 'country'.
120120
</Aside>
121121

@@ -124,10 +124,10 @@ END;
124124
UC AI validates that all placeholders in your templates have corresponding parameters. If a placeholder is missing, you'll get a clear error:
125125

126126
```
127-
Missing parameter for placeholder: #text#
127+
Missing parameter for placeholder: {text}
128128
```
129129

130-
Only alphanumeric characters and underscores are allowed in placeholder names: `#valid_name_123#`
130+
Only alphanumeric characters and underscores are allowed in placeholder names: `{valid_name_123}`
131131

132132
## Executing a profile
133133

@@ -194,7 +194,7 @@ BEGIN
194194
p_code => 'COMPLEX_ANALYSIS',
195195
p_description => 'Analyzes complex scenarios with reasoning',
196196
p_system_prompt_template => 'You are an analytical assistant.',
197-
p_user_prompt_template => 'Analyze: #scenario#',
197+
p_user_prompt_template => 'Analyze: {scenario}',
198198
p_provider => uc_ai.c_provider_openai,
199199
p_model => uc_ai_openai.c_model_gpt_o4,
200200
p_model_config_json => l_config
@@ -301,7 +301,7 @@ BEGIN
301301
p_code => 'ANALYZE_TEXT',
302302
p_description => 'Analyzes text with structured output',
303303
p_system_prompt_template => 'Analyze text and provide structured results.',
304-
p_user_prompt_template => 'Analyze: #text#',
304+
p_user_prompt_template => 'Analyze: {text}',
305305
p_provider => uc_ai.c_provider_openai,
306306
p_model => uc_ai_openai.c_model_gpt_4o_mini,
307307
p_response_schema => l_schema
@@ -417,8 +417,8 @@ BEGIN
417417
uc_ai_prompt_profiles_api.update_prompt_profile(
418418
p_id => 42,
419419
p_description => 'Updated description',
420-
p_system_prompt_template => 'New system prompt with #param#',
421-
p_user_prompt_template => 'New user prompt: #input#',
420+
p_system_prompt_template => 'New system prompt with {param}',
421+
p_user_prompt_template => 'New user prompt: {input}',
422422
p_provider => uc_ai.c_provider_anthropic,
423423
p_model => uc_ai_anthropic.c_model_claude_3_5_sonnet
424424
);
@@ -502,7 +502,7 @@ BEGIN
502502
p_code => 'USER_LOOKUP',
503503
p_description => 'Looks up user information',
504504
p_system_prompt_template => 'You are an assistant with access to user data.',
505-
p_user_prompt_template => 'What is the email of #user_name#?',
505+
p_user_prompt_template => 'What is the email of {user_name}?',
506506
p_provider => uc_ai.c_provider_openai,
507507
p_model => uc_ai_openai.c_model_gpt_4o_mini,
508508
p_model_config_json => l_config
@@ -643,7 +643,7 @@ BEGIN
643643
p_code => 'CLASSIFY_ISSUE',
644644
p_description => 'Classifies customer support issues',
645645
p_system_prompt_template => 'You are a support ticket classifier. Analyze issues and categorize them accurately.',
646-
p_user_prompt_template => 'Classify this issue: #issue_text#',
646+
p_user_prompt_template => 'Classify this issue: {issue_text}',
647647
p_provider => uc_ai.c_provider_openai,
648648
p_model => uc_ai_openai.c_model_gpt_4o_mini,
649649
p_response_schema => l_schema,

src/packages/uc_ai_prompt_profiles_api.pkb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ create or replace package body uc_ai_prompt_profiles_api as
404404

405405

406406
/*
407-
* Replaces placeholders (#placeholder#) in a template with values from parameters JSON
407+
* Replaces placeholders ({placeholder}) in a template with values from parameters JSON
408408
* Case-insensitive replacement
409409
*/
410410
function replace_placeholders(
@@ -442,7 +442,7 @@ create or replace package body uc_ai_prompt_profiles_api as
442442
-- Replace placeholder (case-insensitive)
443443
l_result := regexp_replace(
444444
l_result,
445-
'#' || l_key || '#',
445+
'\{' || l_key || '\}',
446446
l_value,
447447
1, 0, 'i'
448448
);
@@ -479,10 +479,10 @@ create or replace package body uc_ai_prompt_profiles_api as
479479
-- Find all placeholders in templates (only alphanumeric and underscore allowed)
480480
<<placeholder_loop>>
481481
loop
482-
l_placeholder := regexp_substr(l_combined_template, '#[A-Za-z0-9_]+#', l_position);
482+
l_placeholder := regexp_substr(l_combined_template, '\{[A-Za-z0-9_]+\}', l_position);
483483
exit placeholder_loop when l_placeholder is null;
484484

485-
-- Extract placeholder name (without the # symbols)
485+
-- Extract placeholder name (without the { } symbols)
486486
l_placeholder_name := substr(l_placeholder, 2, length(l_placeholder) - 2);
487487

488488
-- Check if parameter exists (case-insensitive)
@@ -499,12 +499,12 @@ create or replace package body uc_ai_prompt_profiles_api as
499499
end if;
500500

501501
if not l_found then
502-
uc_ai_logger.log_error('Missing parameter for placeholder: ' || l_placeholder, l_scope);
502+
uc_ai_logger.log_error('Missing parameter for placeholder: ' || l_placeholder, l_scope, p_parameters.to_clob);
503503
raise_application_error(-20003, 'Missing parameter for placeholder: ' || l_placeholder);
504504
end if;
505505

506506
-- Move to next placeholder
507-
l_position := regexp_instr(l_combined_template, '#[A-Za-z0-9_]+#', l_position) + length(l_placeholder);
507+
l_position := regexp_instr(l_combined_template, '\{[A-Za-z0-9_]+\}', l_position) + length(l_placeholder);
508508
end loop placeholder_loop;
509509
end validate_parameters;
510510

test/test_uc_ai_prompt_profiles_api.pkb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
2929
p_code => gc_test_code,
3030
p_description => 'Test profile for basic creation',
3131
p_system_prompt_template => 'You are a helpful assistant.',
32-
p_user_prompt_template => 'Answer this question: #question#',
32+
p_user_prompt_template => 'Answer this question: {question}',
3333
p_provider => uc_ai.c_provider_openai,
3434
p_model => uc_ai_openai.c_model_gpt_4o_mini,
3535
p_version => 1,
@@ -78,7 +78,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
7878
p_code => gc_test_code || '_CONFIG',
7979
p_description => 'Test profile with configuration',
8080
p_system_prompt_template => 'You are a helpful assistant.',
81-
p_user_prompt_template => 'Answer: #question#',
81+
p_user_prompt_template => 'Answer: {question}',
8282
p_provider => uc_ai.c_provider_openai,
8383
p_model => uc_ai_openai.c_model_gpt_4o_mini,
8484
p_model_config_json => l_config,
@@ -106,7 +106,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
106106
p_code => gc_test_code || '_UPDATE',
107107
p_description => 'Original description',
108108
p_system_prompt_template => 'You are a helpful assistant.',
109-
p_user_prompt_template => 'Question: #question#',
109+
p_user_prompt_template => 'Question: {question}',
110110
p_provider => uc_ai.c_provider_openai,
111111
p_model => uc_ai_openai.c_model_gpt_4o_mini
112112
);
@@ -116,7 +116,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
116116
p_id => l_id,
117117
p_description => l_new_description,
118118
p_system_prompt_template => 'You are a very helpful assistant.',
119-
p_user_prompt_template => 'Please answer: #question#',
119+
p_user_prompt_template => 'Please answer: {question}',
120120
p_provider => uc_ai.c_provider_openai,
121121
p_model => uc_ai_openai.c_model_gpt_4o
122122
);
@@ -142,7 +142,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
142142
p_code => gc_test_code || '_UPDATE2',
143143
p_description => 'Original description',
144144
p_system_prompt_template => 'You are a helpful assistant.',
145-
p_user_prompt_template => 'Question: #question#',
145+
p_user_prompt_template => 'Question: {question}',
146146
p_provider => uc_ai.c_provider_openai,
147147
p_model => uc_ai_openai.c_model_gpt_4o_mini,
148148
p_version => 1
@@ -154,7 +154,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
154154
p_version => 1,
155155
p_description => l_new_description,
156156
p_system_prompt_template => 'You are a very helpful assistant.',
157-
p_user_prompt_template => 'Please answer: #question#',
157+
p_user_prompt_template => 'Please answer: {question}',
158158
p_provider => uc_ai.c_provider_openai,
159159
p_model => uc_ai_openai.c_model_gpt_4o
160160
);
@@ -182,7 +182,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
182182
p_code => gc_test_code || '_DELETE',
183183
p_description => 'Profile to delete',
184184
p_system_prompt_template => 'You are a helpful assistant.',
185-
p_user_prompt_template => 'Question: #question#',
185+
p_user_prompt_template => 'Question: {question}',
186186
p_provider => uc_ai.c_provider_openai,
187187
p_model => uc_ai_openai.c_model_gpt_4o_mini
188188
);
@@ -213,7 +213,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
213213
p_code => gc_test_code || '_DELETE2',
214214
p_description => 'Profile to delete',
215215
p_system_prompt_template => 'You are a helpful assistant.',
216-
p_user_prompt_template => 'Question: #question#',
216+
p_user_prompt_template => 'Question: {question}',
217217
p_provider => uc_ai.c_provider_openai,
218218
p_model => uc_ai_openai.c_model_gpt_4o_mini,
219219
p_version => 1
@@ -251,7 +251,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
251251
p_code => gc_test_code || '_STATUS',
252252
p_description => 'Status test profile',
253253
p_system_prompt_template => 'You are a helpful assistant.',
254-
p_user_prompt_template => 'Question: #question#',
254+
p_user_prompt_template => 'Question: {question}',
255255
p_provider => uc_ai.c_provider_openai,
256256
p_model => uc_ai_openai.c_model_gpt_4o_mini,
257257
p_status => 'draft'
@@ -291,7 +291,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
291291
p_code => gc_test_code || '_VERSION',
292292
p_description => 'Version 1',
293293
p_system_prompt_template => 'You are a helpful assistant.',
294-
p_user_prompt_template => 'Question: #question#',
294+
p_user_prompt_template => 'Question: {question}',
295295
p_provider => uc_ai.c_provider_openai,
296296
p_model => uc_ai_openai.c_model_gpt_4o_mini,
297297
p_version => 1,
@@ -333,7 +333,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
333333
p_code => gc_test_code || '_GET',
334334
p_description => 'Get test profile',
335335
p_system_prompt_template => 'You are a helpful assistant.',
336-
p_user_prompt_template => 'Question: #question#',
336+
p_user_prompt_template => 'Question: {question}',
337337
p_provider => uc_ai.c_provider_openai,
338338
p_model => uc_ai_openai.c_model_gpt_4o_mini
339339
);
@@ -359,7 +359,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
359359
p_code => gc_test_code || '_LATEST',
360360
p_description => 'Version 1',
361361
p_system_prompt_template => 'You are a helpful assistant v1.',
362-
p_user_prompt_template => 'Question: #question#',
362+
p_user_prompt_template => 'Question: {question}',
363363
p_provider => uc_ai.c_provider_openai,
364364
p_model => uc_ai_openai.c_model_gpt_4o_mini,
365365
p_version => 1,
@@ -370,7 +370,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
370370
p_code => gc_test_code || '_LATEST',
371371
p_description => 'Version 2',
372372
p_system_prompt_template => 'You are a helpful assistant v2.',
373-
p_user_prompt_template => 'Question: #question#',
373+
p_user_prompt_template => 'Question: {question}',
374374
p_provider => uc_ai.c_provider_openai,
375375
p_model => uc_ai_openai.c_model_gpt_4o_mini,
376376
p_version => 2,
@@ -381,7 +381,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
381381
p_code => gc_test_code || '_LATEST',
382382
p_description => 'Version 3',
383383
p_system_prompt_template => 'You are a helpful assistant v3.',
384-
p_user_prompt_template => 'Question: #question#',
384+
p_user_prompt_template => 'Question: {question}',
385385
p_provider => uc_ai.c_provider_openai,
386386
p_model => uc_ai_openai.c_model_gpt_4o_mini,
387387
p_version => 3,
@@ -455,8 +455,8 @@ create or replace package body test_uc_ai_prompt_profiles_api as
455455
l_id := uc_ai_prompt_profiles_api.create_prompt_profile(
456456
p_code => gc_test_code || '_PLACEHOLDERS',
457457
p_description => 'Profile with placeholders',
458-
p_system_prompt_template => 'You are a #role# assistant.',
459-
p_user_prompt_template => 'What is the capital of #country#?',
458+
p_system_prompt_template => 'You are a {role} assistant.',
459+
p_user_prompt_template => 'What is the capital of {country}?',
460460
p_provider => uc_ai.c_provider_openai,
461461
p_model => uc_ai_openai.c_model_gpt_4o_mini,
462462
p_status => 'active'
@@ -660,7 +660,7 @@ create or replace package body test_uc_ai_prompt_profiles_api as
660660
p_code => gc_test_code || '_TOOLS',
661661
p_description => 'Profile with tool usage',
662662
p_system_prompt_template => 'You are an assistant with access to user information. Answer concisely.',
663-
p_user_prompt_template => 'What is the email of #user_name#?',
663+
p_user_prompt_template => 'What is the email of {user_name}?',
664664
p_provider => uc_ai.c_provider_openai,
665665
p_model => uc_ai_openai.c_model_gpt_4o_mini,
666666
p_status => 'active',

0 commit comments

Comments
 (0)