Hi we are using azure open ai realtime llm and our Agent Session configuration is:
return AgentSession(
llm=openai.realtime.RealtimeModel.with_azure(
azure_deployment=os.getenv(“ARE”),
azure_endpoint=os.getenv(“ARD”),
api_key=os.getenv(“KEY”),
api_version=os.getenv(“API”),
input_audio_transcription=InputAudioTranscription(
model=os.getenv(“TM”),
language=“en”,
),
),
userdata=userdata,
vad=vad,
tts=tts,
user_away_timeout=user_away_timeout,
turn_detection=turn_detection,
max_endpointing_delay=max_endpointing_delay,
preemptive_generation=preemptive_generation,
)
We call update_chat_ctx on every agent switch and before we call this we manually add some system instructions to the chat ctx using
chat_ctx.add_message(
role=“system”,
content=(
“TEST”
),
)
We are facing two errors
- On calling update_chat_ctx for first time we get
type=‘error’
error=RealtimeModelError(type='rea…
timestamp=1773645063.741534,
label='livekit.plugins.openai.real…
error=APIError(‘OpenAI Realtime API
returned an error’,
body=Error(message=“Missing
required parameter: ‘item.type’.”,
type=‘invalid_request_error’,
code=‘missing_required_parameter’,
event_id='chat_ctx_create_0304ac1b…
param=‘item.type’),
retryable=True), recoverable=True)
source=<livekit.plugins.openai.rea…
object at 0x7f50b0694c20>
created_at=1773645063.74164
- On subsequent calls to update_chat_ctx we get
type=‘error’ error=RealtimeModelError(type=‘realtime_model_error’, timestamp=1773645063.7664914, label=‘livekit.plugins.openai.realtime.realtime_model_beta.RealtimeModelBeta’, error=APIError(‘OpenAI Realtime API returned an error’, body=Error(message=“Error adding item: the previous item with id ‘item_d4fc3f27baf6’ does not exist.”, type=‘invalid_request_error’, code=‘item_create_invalid_previous_item_id’, event_id=‘chat_ctx_create_e307d32c164d’, param=None), retryable=True), recoverable=True) source=<livekit.plugins.openai.realtime.realtime_model_beta.RealtimeModelBeta object at 0x7f50b0694c20>