Class: CallRecordAnalysisAgent

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

Overview

RubyLLM Agent for comprehensive call analysis.

Generates summary, action items, call phases, customer satisfaction, and
agent performance scores from a call transcript via Anthropic directly,
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.

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").

Examples:

Running call analysis

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