Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions docs/howto/multilingual.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

# Multilingual output (how-to)

**Version:** `gdm-concordia >= 2.1.0`

Concordia agents don’t have a global “language” toggle. The recommended way to constrain output language is to **modify the agent’s prompt**. You can do this either by:
- injecting a language directive into the agent’s params (e.g., `goal`), or
- wrapping/templating the prompt used by your prefab.

Below is a minimal example that sets one agent to Spanish and another to French.
## Scope note (user-facing vs internal prompts)

This pattern is intended to control **user-facing outputs** (e.g., agent dialog/actions). Intermediate/internal prompts may not automatically inherit the language directive if only `goal` is modified, since only prompt components that include `goal` in their prefix will see the directive. If you need internal prompts in the target language too, apply the directive across all relevant prompt components or enforce it via a prefab-level prompt template.

```python
from concordia.utils import prefab_lib

LANGUAGE_DIRECTIVE = "Always respond in {lang}. Do not switch languages."

instances = [
prefab_lib.InstanceConfig(
prefab="basic__Entity",
role=prefab_lib.Role.ENTITY,
params={
"name": "Oliver Cromwell",
"goal": "become lord protector. " + LANGUAGE_DIRECTIVE.format(lang="Spanish"),
},
),
prefab_lib.InstanceConfig(
prefab="basic__Entity",
role=prefab_lib.Role.ENTITY,
params={
"name": "King Charles I",
"goal": "avoid execution for treason. " + LANGUAGE_DIRECTIVE.format(lang="French"),
},
),
prefab_lib.InstanceConfig(
prefab="generic__GameMaster",
role=prefab_lib.Role.GAME_MASTER,
params={
"name": "default rules",
# Comma-separated list of thought chain steps.
"extra_event_resolution_steps": "",
},
),
prefab_lib.InstanceConfig(
prefab="formative_memories_initializer__GameMaster",
role=prefab_lib.Role.INITIALIZER,
params={
"name": "initial setup rules",
"next_game_master_name": "default rules",
"shared_memories": [
"The king was captured by Parliamentary forces in 1646.",
"Charles I was tried for treason and found guilty.",
],
},
),
]

config = prefab_lib.Config(
default_premise="Today is January 29, 1649.",
default_max_steps=5,
instances=instances,
)