githubEdit

robotLLM Guide: Creating vCon Adapters

This guide provides essential information for Large Language Models tasked with generating vCon adapter code. Follow these patterns and requirements when creating adapters that convert conversation da

Core Requirements

Essential Imports

Always include these imports in vCon adapter code:

from abc import ABC, abstractmethod
from typing import Dict, List, Any, Optional, Union
from vcon import Vcon, Party, Dialog
from datetime import datetime, timezone
import json
import base64
import logging

Base Adapter Pattern

Use this as the foundation for all adapters:

class BaseVconAdapter(ABC):
    """Base class for all vCon adapters."""
    
    def __init__(self, config: Dict[str, Any]):
        self.config = config
        self.validation_errors = []
        self.logger = logging.getLogger(self.__class__.__name__)
    
    @abstractmethod
    def extract_data(self, source: Any) -> Dict[str, Any]:
        """Extract raw data from the source system."""
        pass
    
    @abstractmethod
    def transform_to_vcon(self, raw_data: Dict[str, Any]) -> Vcon:
        """Transform raw data into a vCon object."""
        pass
    
    def validate_vcon(self, vcon: Vcon) -> bool:
        """Validate the generated vCon."""
        is_valid, errors = vcon.is_valid()
        self.validation_errors = errors
        return is_valid
    
    def process(self, source: Any) -> Vcon:
        """Main processing pipeline."""
        raw_data = self.extract_data(source)
        vcon = self.transform_to_vcon(raw_data)
        
        if not self.validate_vcon(vcon):
            raise ValueError(f"Invalid vCon generated: {self.validation_errors}")
        
        return vcon

Key Patterns to Follow

1. vCon Creation

Always start with:

2. Party Processing

Create a mapping between source participants and vCon parties:

3. Dialog Processing

Handle different dialog types:

4. Timestamp Handling

Always convert timestamps to ISO format:

Media Handling Patterns

Audio/Video Content

Handle media files properly:

Transfer Dialogs

Handle call transfers:

Incomplete Dialogs

Handle failed conversations:

Error Handling Requirements

Robust Data Extraction

Always handle missing or malformed data:

Validation and Fallbacks

Provide fallbacks for missing required data:

Common Adapter Templates

Chat System Adapter

Call Center Adapter

Critical Requirements

1. Always Validate

2. Handle All Dialog Types

Support these dialog types based on source data:

  • "text" - Text messages, chat, transcripts

  • "recording" - Audio recordings

  • "video" - Video calls/recordings

  • "transfer" - Call transfers

  • "incomplete" - Failed/incomplete calls

3. Use Proper MIME Types

Use these MIME types:

  • Text: "text/plain"

  • Audio: "audio/wav", "audio/mp3", "audio/x-wav", "audio/x-mp3"

  • Video: "video/mp4", "video/webm", "video/x-mp4"

  • Email: "message/rfc822"

4. Include Extensions and Must-Support (vCon 0.3.0)

Testing Pattern

Always include this test structure:

Key Considerations for LLMs

  1. Always use the base adapter pattern - don't create adapters from scratch

  2. Handle missing data gracefully - provide defaults and fallbacks

  3. Validate all timestamps - convert to ISO 8601 format

  4. Map participant IDs correctly - maintain consistent party references

  5. Include proper error handling - log errors and provide meaningful messages

  6. Use appropriate dialog types - match the source content type

  7. Add relevant metadata - use tags and extensions appropriately

  8. Test the generated vCon - always validate before returning

When generating adapter code, focus on the specific source system requirements while following these patterns and ensuring compliance with the vCon specification.

Last updated

Was this helpful?