AI Parameters

View as Markdown

AI Parameters

Tune conversation behavior with parameters for speech detection, timeouts, barge control, and AI model settings. For a complete parameter reference, see AI Parameters Reference.

Parameter Categories

CategoryKey ParametersPurpose
Speech Detectionend_of_speech_timeout, energy_levelControl when speech ends
Timeoutsattention_timeout, inactivity_timeoutHandle silence and idle callers
Barge Controlbarge_match_string, transparent_bargeManage interruptions
AI Modeltemperature, top_p, max_tokensTune response generation

Setting Parameters

1from signalwire_agents import AgentBase
2
3
4class MyAgent(AgentBase):
5 def __init__(self):
6 super().__init__(name="my-agent")
7 self.add_language("English", "en-US", "rime.spore")
8
9 # Set multiple parameters at once
10 self.set_params({
11 "end_of_speech_timeout": 600,
12 "attention_timeout": 15000,
13 "inactivity_timeout": 45000,
14 "temperature": 0.5
15 })

Essential Parameters

Speech Detection

ParameterTypeDefaultDescription
end_of_speech_timeoutint700Milliseconds of silence before speech is complete
energy_levelint52Minimum audio level in dB (0-100)
1## Fast response - shorter silence detection
2self.set_params({"end_of_speech_timeout": 400})
3
4## Patient agent - longer silence tolerance
5self.set_params({"end_of_speech_timeout": 1000})

Timeouts

ParameterTypeDefaultDescription
attention_timeoutint5000Milliseconds before prompting idle caller
inactivity_timeoutint600000Milliseconds before ending call (10 min default)
1## Quick service - prompt quickly if silent
2self.set_params({
3 "attention_timeout": 5000, # "Are you there?" after 5 seconds
4 "inactivity_timeout": 30000 # End call after 30 seconds
5})
6
7## Patient service - give caller time to think
8self.set_params({
9 "attention_timeout": 20000, # Wait 20 seconds before prompting
10 "inactivity_timeout": 60000 # Wait full minute before ending
11})

Barge Control

Barge-in allows callers to interrupt the AI while it’s speaking.

ParameterTypeDefaultDescription
barge_match_stringstr-Phrase required to trigger barge
transparent_bargebooltrueEnable transparent barge mode
1## Require specific phrase to interrupt
2self.set_params({
3 "barge_match_string": "excuse me"
4})

AI Model

ParameterTypeDefaultDescription
temperaturefloat0.3Randomness (0-2, higher = more creative)
top_pfloat1.0Nucleus sampling threshold
max_tokensint256Maximum response length
frequency_penaltyfloat0.1Reduce repetitive phrases
1## Consistent responses (FAQ bot)
2self.set_params({"temperature": 0.2})
3
4## Creative responses (entertainment)
5self.set_params({"temperature": 0.9})
6
7## Balanced for customer service
8self.set_params({
9 "temperature": 0.5,
10 "frequency_penalty": 0.3
11})

Use Case Presets

Customer Service

1self.set_params({
2 "end_of_speech_timeout": 600,
3 "attention_timeout": 12000,
4 "inactivity_timeout": 45000,
5 "temperature": 0.5
6})

Technical Support

1self.set_params({
2 "end_of_speech_timeout": 800, # Patient for complex explanations
3 "attention_timeout": 20000,
4 "inactivity_timeout": 60000,
5 "temperature": 0.3 # Precise responses
6})

IVR Menu

1self.set_params({
2 "end_of_speech_timeout": 400, # Quick response
3 "attention_timeout": 8000,
4 "inactivity_timeout": 20000,
5 "temperature": 0.2 # Very consistent
6})

Tuning Guide

If callers are…

ProblemSolution
Being cut off mid-sentenceIncrease end_of_speech_timeout
Waiting too long for responseDecrease end_of_speech_timeout
Not hearing “Are you there?”Decrease attention_timeout
Getting hung up on too fastIncrease inactivity_timeout

If responses are…

ProblemSolution
Too repetitiveIncrease frequency_penalty
Too random/inconsistentDecrease temperature
Too predictableIncrease temperature
Too longDecrease max_tokens

Complete Example

1#!/usr/bin/env python3
2## configured_agent.py - Agent with AI parameters configured
3from signalwire_agents import AgentBase
4
5
6class ConfiguredAgent(AgentBase):
7 def __init__(self):
8 super().__init__(name="configured-agent")
9 self.add_language("English", "en-US", "rime.spore")
10
11 self.set_params({
12 # Speech detection
13 "end_of_speech_timeout": 600,
14
15 # Timeouts
16 "attention_timeout": 15000,
17 "inactivity_timeout": 45000,
18
19 # AI model
20 "temperature": 0.5,
21 "frequency_penalty": 0.2
22 })
23
24 self.prompt_add_section(
25 "Role",
26 "You are a helpful customer service agent."
27 )
28
29
30if __name__ == "__main__":
31 agent = ConfiguredAgent()
32 agent.run()

More Parameters

For the complete list of all available parameters including:

  • ASR configuration (diarization, smart formatting)
  • Audio settings (volume, background music, hold music)
  • Video parameters
  • Advanced behavior controls
  • SWAIG control parameters

See the AI Parameters Reference in the Appendix.