Skip to content

Commit 15a526c

Browse files
authored
Update config.json.tpl to support more parameters (#856)
* Update config.json.tpl to support more parameters * update tests and ci * Update config.json.tpl * Update RELEASE_NOTES for version 0.1.2 Updated release notes for version 0.1.2 with new features.
1 parent 220b445 commit 15a526c

File tree

5 files changed

+86
-4
lines changed

5 files changed

+86
-4
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Chat Demo Tests (Python)
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths:
7+
- 'samples/ai/chat-demo/**'
8+
pull_request:
9+
branches: [ "main" ]
10+
paths:
11+
- 'samples/ai/chat-demo/**'
12+
workflow_dispatch: {}
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
python-version: [ '3.11' ]
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
cache: 'pip'
29+
30+
- name: Install dependencies
31+
working-directory: samples/ai/chat-demo
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install -r requirements.txt
35+
pip install -r requirements-dev.txt
36+
37+
- name: Run unit tests (chat-demo)
38+
working-directory: samples/ai/chat-demo
39+
run: |
40+
pytest -q tests python_server/tests
41+

samples/ai/chat-demo/RELEASE_NOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
Plain-language updates focused on what demo users can try. Non-customer internal details intentionally omitted.
44

5+
## [0.1.2] - (2025-11-26)
6+
7+
### Added
8+
- `config.json.tpl` to support more parameters.
9+
510
## [0.1.1] - 2025-10-30 (Preview)
611

712
### Added
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
{
22
"model": {
33
"name": "openai/gpt-5",
4-
"api_version": "2024-08-01-preview"
4+
"api_version": "2024-08-01-preview",
5+
"system_prompt": {
6+
"role": "developer",
7+
"content": "You are an adaptive poetic assistant. Your primary mission: respond to the user with a poem that matches their request’s topic, mood, and any specified form. If they don’t specify a form, choose an appropriate one (free verse, rhymed quatrain, haiku, blank verse, or short lyrical). Contract: 1. Default output is only the poem (no prefacing explanations) unless user asks for discussion. 2. Keep it 4–14 lines unless a longer form is requested. 3. If user explicitly wants prose or analysis, comply—but you may append a short optional poetic epilogue only if welcomed. Adaptation rules: Mirror emotional tone (hopeful, wistful, playful, solemn). Follow explicit constraints (meter, rhyme scheme, syllable count) when they give them. Refusal: For disallowed or unsafe content, respond with a brief, neutral refusal and, if suitable, offer a harmless poetic alternative. Formatting: No trailing commentary. No numbered lines unless asked. Avoid repetition, clichés, and excessive adjective stacking. Self-check before finalizing: vivid imagery, concrete nouns, fresh metaphors, consistent voice, clean line breaks."
8+
},
9+
"parameters": {
10+
"reasoning_effort": "medium"
11+
}
512
}
613
}
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
{
22
"model": {
3-
"name": "{{model_name}}",
4-
"api_version": "{{api_version}}"
3+
{{#systemWithQuote}}
4+
"system_prompt": {
5+
{{#o1}}
6+
"role": "developer",
7+
{{/o1}}
8+
{{^o1}}
9+
"role": "system",
10+
{{/o1}}
11+
"content": {{{systemWithQuote}}}
12+
},
13+
{{/systemWithQuote}}
14+
{{#parameters_json}}
15+
"parameters": {{{parameters_json}}},
16+
{{/parameters_json}}
17+
"api_version": "{{api_version}}",
18+
"name": "{{model_name}}"
519
}
620
}

samples/ai/chat-demo/tests/test_config_template.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def _build_context(
2424
parameters: Dict[str, Any] | None = None,
2525
response_format: Optional[Dict[str, Any]] = None,
2626
o1: bool = False,
27+
include_parameters: bool = True,
2728
) -> Dict[str, Any]:
2829
params = dict(parameters or {})
2930
param_dict: Dict[str, Any] = {}
@@ -43,11 +44,12 @@ def _build_context(
4344
context: Dict[str, Any] = {
4445
"model_name": model_name,
4546
"api_version": api_version,
46-
"parameters_json": json.dumps(param_dict),
4747
}
4848

4949
if system_prompt is not None:
5050
context["systemWithQuote"] = json.dumps(system_prompt)
51+
if include_parameters:
52+
context["parameters_json"] = json.dumps(param_dict)
5153
if o1:
5254
context["o1"] = True
5355
return context
@@ -190,3 +192,16 @@ def test_template_omits_system_prompt_when_not_provided():
190192
payload = json.loads(_render(context))
191193
assert "system_prompt" not in payload["model"]
192194
assert payload["model"]["parameters"] == {"temperature": 0.6}
195+
196+
197+
def test_template_omits_parameters_when_not_supplied():
198+
context = _build_context(
199+
model_name="gpt-raw",
200+
api_version="2024-08-01-preview",
201+
system_prompt="Be neutral.",
202+
include_parameters=False,
203+
)
204+
205+
payload = json.loads(_render(context))
206+
assert payload["model"]["system_prompt"]["content"] == "Be neutral."
207+
assert "parameters" not in payload["model"]

0 commit comments

Comments
 (0)