ThunderPhone 2.0 હવે લાઇવ છે.સેલ્ફ-સર્વ, 2¢/મિનિટથી.જાહેરાત વાંચો

Connect tools & data

LiveKit Agentsમાંથી ThunderPhone નો ઉપયોગ કરો

LiveKit રૂમ્સ, SIP અને ટેલિફોની સાથે, LiveKit Agents સેશનના રીઅલટાઇમ (સ્પીચ-ટુ-સ્પીચ) મોડેલ તરીકે ThunderPhone વૉઇસ એજન્ટ ચલાવો.

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 રીઅલટાઇમ મોડેલને રૅપ કરે છે, કારણ કે ThunderPhoneનું Realtime WebSocket એ જ પ્રોટોકોલનો ઉપયોગ કરે છે. તેને livekit-agents 1.8 અથવા નવી આવૃત્તિની જરૂર છે.

સાચવેલ એજન્ટ ચલાવો

એજન્ટ જે બધું કરે છે (prompt, અવાજ, એન્જિન, ભાષાઓ, ટૂલ્સ, અભિવાદન, મૌન ચેક-ઇન્સ) તે 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 વિના, સૂચનાઓ અને ટૂલ્સ OpenAI માટેની જેમ LiveKit Agentમાંથી આવે છે. 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 છે.
  • વિડિયો ફ્રેમ્સ અવગણવામાં આવે છે.