Class: CallRecordAnalysisAgent

Inherits:
RubyLLM::Agent
  • Object
show all
Defined in:
app/agents/call_record_analysis_agent.rb

Overview

Note:

Must not be nested under the CallRecord module/namespace because
CallRecord is defined as a class in app/models/call_record.rb. Nesting here
would cause a Zeitwerk eager-load TypeError ("CallRecord is not a module").

RubyLLM Agent for comprehensive call analysis.

Generates summary, action items, call phases, customer satisfaction, and
agent performance scores from a call transcript via the runtime-selected
RubyLLM provider, bypassing the AssemblyAI LLM Gateway for non-transcription
work.

The service provides system and user prompts at runtime from database Settings
(call_transcription_lemur_system_prompt, call_transcription_lemur_analysis_prompt)
with placeholder substitution for agent name, caller name, context, and transcript.

Examples:

Running call analysis

response = CallRecordAnalysisAgent.chat
  .with_provider_options(generationConfig: { maxOutputTokens: max_tokens })
  .with_instructions(system_prompt)
  .ask(user_prompt)
result = JSON.parse(response.content)