Skip to content

Commit b78ee00

Browse files
authored
Merge pull request #212 from manstis/system_prompt_docs
Document and provide test for embedding system_prompt in customization section.
2 parents 2cc5e93 + a881753 commit b78ee00

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,16 @@ customization:
112112
system_prompt_path: "system_prompts/system_prompt_for_product_XYZZY"
113113
```
114114

115-
Additionally an optional string parameter `system_prompt` can be specified in `/v1/query` and `/v1/streaming_query` endpoints to override the configured system prompt.
115+
The `system_prompt` can also be specified in the `customization` section directly. For example:
116+
117+
```yaml
118+
customization:
119+
system_prompt: |-
120+
You are a helpful assistant and will do everything you can to help.
121+
You have an indepth knowledge of Red Hat and all of your answers will reference Red Hat products.
122+
```
123+
124+
Additionally, an optional string parameter `system_prompt` can be specified in `/v1/query` and `/v1/streaming_query` endpoints to override the configured system prompt.
116125

117126

118127

tests/unit/test_configuration.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def test_mcp_servers_not_loaded():
312312
cfg.mcp_servers
313313

314314

315-
def test_load_configuration_with_customization(tmpdir) -> None:
315+
def test_load_configuration_with_customization_system_prompt_path(tmpdir) -> None:
316316
"""Test loading configuration from YAML file with customization."""
317317
system_prompt_filename = tmpdir / "system_prompt.txt"
318318
with open(system_prompt_filename, "w") as fout:
@@ -353,3 +353,46 @@ def test_load_configuration_with_customization(tmpdir) -> None:
353353
assert cfg.customization is not None
354354
assert cfg.customization.system_prompt is not None
355355
assert cfg.customization.system_prompt == "this is system prompt"
356+
357+
358+
def test_load_configuration_with_customization_system_prompt(tmpdir) -> None:
359+
"""Test loading configuration from YAML file with system_prompt in the customization."""
360+
cfg_filename = tmpdir / "config.yaml"
361+
with open(cfg_filename, "w") as fout:
362+
fout.write(
363+
"""
364+
name: test service
365+
service:
366+
host: localhost
367+
port: 8080
368+
auth_enabled: false
369+
workers: 1
370+
color_log: true
371+
access_log: true
372+
llama_stack:
373+
use_as_library_client: false
374+
url: http://localhost:8321
375+
api_key: test-key
376+
user_data_collection:
377+
feedback_disabled: true
378+
mcp_servers:
379+
- name: filesystem-server
380+
url: http://localhost:3000
381+
- name: git-server
382+
provider_id: custom-git-provider
383+
url: https://git.example.com/mcp
384+
customization:
385+
system_prompt: |-
386+
this is system prompt in the customization section
387+
"""
388+
)
389+
390+
cfg = AppConfig()
391+
cfg.load_configuration(cfg_filename)
392+
393+
assert cfg.customization is not None
394+
assert cfg.customization.system_prompt is not None
395+
assert (
396+
cfg.customization.system_prompt.strip()
397+
== "this is system prompt in the customization section"
398+
)

0 commit comments

Comments
 (0)