ThunderPhone 2.0 अब लाइव है।सेल्फ़-सर्व, 2¢ प्रति मिनट से शुरू।घोषणा पढ़ें

Connect tools & data

LiveKit Agents से ThunderPhone का उपयोग करें

LiveKit Agents सेशन के रियलटाइम (स्पीच-टू-स्पीच) मॉडल के रूप में ThunderPhone वॉइस एजेंट चलाएं, जिसके आसपास LiveKit रूम, SIP और टेलीफोनी हों।

LiveKit Agents LiveKit रूम्स के ऊपर रियलटाइम वॉइस एजेंट्स के लिए एक ओपन-सोर्स फ्रेमवर्क है। ThunderPhone रियलटाइम मॉडल के रूप में प्लग इन होता है: फ्रेमवर्क प्रतिभागी का ऑडियो भेजता है, ThunderPhone एजेंट की आवाज़, ट्रांसक्रिप्ट्स और फंक्शन कॉल्स लौटाता है, और LiveKit का रूम, SIP ट्रंक्स और टेलीफोनी ऑडियो को कैरी करते हैं। स्पीच रिकग्निशन, लैंग्वेज मॉडल, आवाज़, टर्न-टेकिंग, 47 भाषाएं और टूल्स, सभी ThunderPhone पर चलते हैं।

इस तरह की गई कॉल्स कॉल हिस्ट्री में दिखाई देती हैं और किसी भी अन्य रियलटाइम कॉल की तरह आपके प्रोडक्ट की प्रति-मिनट दर पर बिल की जाती हैं। इसमें कोई सब्सक्रिप्शन या ThunderPhone फोन नंबर शामिल नहीं होता।

इंस्टॉल करें

pip install livekit-plugins-thunderphone
export THUNDERPHONE_API_KEY=sk_live_...   # a secret API key

प्लगइन LiveKit के OpenAI Realtime मॉडल को रैप करता है, क्योंकि ThunderPhone का Realtime WebSocket वही प्रोटोकॉल बोलता है। इसके लिए livekit-agents 1.8 या नया वर्जन चाहिए।

सेव किया गया एजेंट चलाएं

एजेंट जो कुछ भी करता है (प्रॉम्प्ट, आवाज़, इंजन, भाषाएं, टूल्स, ग्रीटिंग, साइलेंस चेक-इन्स), वह ThunderPhone पर कॉन्फ़िगर होता है। सेशन केवल ऑडियो भेजता है।

from livekit.agents import Agent, AgentSession, JobContext, WorkerOptions, cli
from livekit.plugins import thunderphone
 
 
async def entrypoint(ctx: JobContext):
    session = AgentSession(llm=thunderphone.RealtimeModel(agent_id=12))
    await session.start(agent=Agent(instructions=""), room=ctx.room)
 
 
if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))

एक सेव किया गया एजेंट ThunderPhone पर ग्रीट करता है और अपने टूल्स चलाता है; LiveKit Agent के निर्देश और टूल्स नहीं भेजे जाते। ThunderPhone एजेंट के कॉल समाप्त करने पर कॉल समाप्त होती है, और सेशन उसके साथ बंद हो जाता है।

सेशन को इनलाइन कॉन्फ़िगर करें

agent_id के बिना, निर्देश और टूल्स LiveKit Agent से आते हैं, उसी तरह जैसे वे OpenAI के लिए आते हैं। product इंजन चुनता है और voice ThunderPhone की आवाज़ चुनता है।

from livekit.agents import Agent, AgentSession, RunContext, function_tool
from livekit.plugins import thunderphone
 
 
class Receptionist(Agent):
    def __init__(self):
        super().__init__(instructions="You are Acme Dental's receptionist. Be brief.")
 
    @function_tool
    async def check_availability(self, context: RunContext, date: str) -> dict:
        """Free appointment slots on a date."""
        return {"slots": await calendar.free_slots(date)}
 
 
async def entrypoint(ctx: JobContext):
    session = AgentSession(
        llm=thunderphone.RealtimeModel(product="bolt", voice="olivia", language="es"),
    )
    await session.start(agent=Receptionist(), room=ctx.room)
    await session.generate_reply()   # the agent speaks first

ThunderPhone कॉल शुरू होने पर निर्देशों और टूल्स को फ्रीज़ कर देता है, इसलिए उन्हें बदलने वाले update_instructions, update_tools और एजेंट हैंड-ऑफ्स कॉल के दौरान समर्थित नहीं हैं। इनलाइन सेशंस क्लाइंट-नियंत्रित होते हैं: एजेंट तब बोलता है जब आप generate_reply() कॉल करते हैं या जब प्रतिभागी अपना टर्न पूरा करता है।

विकल्प

आर्ग्युमेंटअर्थ
api_keyसीक्रेट की (sk_live_...)। डिफ़ॉल्ट रूप से THUNDERPHONE_API_KEY
agent_idसेव किया गया एजेंट चलाएँ। product और voice के साथ परस्पर अनन्य।
productइनलाइन सेशंस के लिए इंजन: spark, bolt या storm
voiceइनलाइन सेशंस के लिए ThunderPhone वॉइस नाम।
languageइनलाइन सेशंस के लिए प्राथमिक भाषा संकेत, उदाहरण के लिए es
from_number, to_numberजब रूम किसी फ़ोन लाइन के सामने हो, तो कॉल पर रिकॉर्ड किए जाने वाले नंबर।
live_transcriptsउच्चारण के दौरान कॉलर ट्रांसक्रिप्ट फ़्रैगमेंट स्ट्रीम करें (अतिरिक्त बिलिंग)।
base_urlएंडपॉइंट ओवरराइड, डिफ़ॉल्ट wss://api.thunderphone.com/v1/realtime

इवेंट्स

ThunderPhone रियलटाइम प्रोटोकॉल के ऊपर प्लेटफ़ॉर्म इवेंट्स जोड़ता है। सेशन इन्हें एमिट करता है:

@session.llm.session.on("thunderphone_call_ended")  # or on the RealtimeSession you hold
def on_call_ended(event):
    print("call ended:", event["reason"])

सेशन लाइव होने पर RealtimeSession, call_id एक्सपोज़ करता है। कॉल के बाद रिकॉर्डिंग, ट्रांसक्रिप्ट और ग्रेड प्राप्त करने के लिए इसका उपयोग GET /v1/calls/{call_id} के साथ करें। हर अन्य call.* इवेंट (ट्रांसफ़र, कीपैड, स्पीच इग्नोर्ड) thunderphone_call_event के रूप में आता है।

सीमाएँ

  • टर्न डिटेक्शन सर्वर-साइड है और हमेशा चालू रहता है; फ़्रेमवर्क-साइड टर्न डिटेक्शन (AgentSession पर turn_detection) को अनदेखा किया जाता है।
  • कॉल शुरू होने के बाद इंस्ट्रक्शंस और टूल्स बदले नहीं जा सकते।
  • ऑडियो दोनों दिशाओं में 24 kHz पर 16-बिट मोनो PCM है।
  • वीडियो फ़्रेम्स को अनदेखा किया जाता है।