mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-01 08:59:46 +02:00
Fix realtime initial greeting handling (#481)
This commit is contained in:
parent
d9800fddd6
commit
090d042a78
20 changed files with 714 additions and 70 deletions
38
api/tests/test_template_renderer.py
Normal file
38
api/tests/test_template_renderer.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
from api.utils.template_renderer import render_template
|
||||
|
||||
|
||||
def test_initial_context_prefix_resolves_against_flat_context():
|
||||
context = {
|
||||
"first_name": "Abhishek",
|
||||
"runtime_configuration": {
|
||||
"realtime_model": "gpt-realtime-2",
|
||||
},
|
||||
}
|
||||
|
||||
assert (
|
||||
render_template("Hi {{initial_context.first_name | there}}", context)
|
||||
== "Hi Abhishek"
|
||||
)
|
||||
assert (
|
||||
render_template(
|
||||
"Model {{initial_context.runtime_configuration.realtime_model}}", context
|
||||
)
|
||||
== "Model gpt-realtime-2"
|
||||
)
|
||||
|
||||
|
||||
def test_initial_context_prefix_prefers_explicit_initial_context():
|
||||
context = {
|
||||
"first_name": "Flat",
|
||||
"initial_context": {
|
||||
"first_name": "Nested",
|
||||
},
|
||||
}
|
||||
|
||||
assert render_template("Hi {{initial_context.first_name}}", context) == "Hi Nested"
|
||||
|
||||
|
||||
def test_initial_context_prefix_uses_fallback_when_missing_from_both_contexts():
|
||||
assert (
|
||||
render_template("Hi {{initial_context.first_name | there}}", {}) == "Hi there"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue