ThunderPhone 2.0 ਹੁਣ ਲਾਈਵ ਹੈ।ਖੁਦ ਸੈਟਅੱਪ ਕਰੋ—2¢/ਮਿੰਟ ਤੋਂ।ਐਲਾਨ ਪੜ੍ਹੋ

Connect tools & data

Pipecat ਤੋਂ ThunderPhone ਵਰਤੋ

ਆਪਣੇ ਟ੍ਰਾਂਸਪੋਰਟ ਅਤੇ ਟੈਲੀਫੋਨੀ ਨਾਲ Pipecat ਪਾਈਪਲਾਈਨ ਦੇ ਅੰਦਰ ਸਪੀਚ-ਟੂ-ਸਪੀਚ ਸੇਵਾ ਵਜੋਂ ThunderPhone ਵੌਇਸ ਏਜੰਟ ਚਲਾਓ।

Pipecat ਕੰਪੋਜ਼ ਹੋਣਯੋਗ ਸੇਵਾਵਾਂ ਤੋਂ ਵੌਇਸ ਏਜੰਟ ਬਣਾਉਣ ਲਈ ਇੱਕ ਓਪਨ-ਸੋਰਸ ਫਰੇਮਵਰਕ ਹੈ। ThunderPhone ਇੱਕ ਬੋਲੀ-ਤੋਂ-ਬੋਲੀ LLM ਸੇਵਾ ਵਜੋਂ ਪਲੱਗ ਇਨ ਹੁੰਦਾ ਹੈ: Pipecat ਕਾਲਰ ਦਾ ਆਡੀਓ ਭੇਜਦਾ ਹੈ, ThunderPhone ਏਜੰਟ ਦੀ ਆਵਾਜ਼, ਟ੍ਰਾਂਸਕ੍ਰਿਪਟ ਅਤੇ ਫੰਕਸ਼ਨ ਕਾਲਾਂ ਵਾਪਸ ਕਰਦਾ ਹੈ, ਅਤੇ Pipecat ਦਾ ਟ੍ਰਾਂਸਪੋਰਟ (Daily, LiveKit, Twilio, WebRTC, ਇੱਕ ਲੋਕਲ ਮਾਈਕ੍ਰੋਫੋਨ) ਆਡੀਓ ਲਿਜਾਂਦਾ ਹੈ। ਸਪੀਚ ਪਛਾਣ, ਲੈਂਗਵੇਜ ਮਾਡਲ, ਆਵਾਜ਼, ਵਾਰੀ ਲੈਣਾ, 47 ਭਾਸ਼ਾਵਾਂ ਅਤੇ ਟੂਲ ਸਾਰੇ ThunderPhone ਉੱਤੇ ਚੱਲਦੇ ਹਨ।

ਇਸ ਤਰੀਕੇ ਨਾਲ ਕੀਤੀਆਂ ਕਾਲਾਂ ਕਾਲ ਇਤਿਹਾਸ ਵਿੱਚ ਦਿਖਾਈ ਦਿੰਦੀਆਂ ਹਨ ਅਤੇ ਕਿਸੇ ਹੋਰ ਰੀਅਲਟਾਈਮ ਕਾਲ ਵਾਂਗ ਤੁਹਾਡੇ ਉਤਪਾਦ ਦੀ ਪ੍ਰਤੀ-ਮਿੰਟ ਦਰ 'ਤੇ ਬਿਲ ਕੀਤੀਆਂ ਜਾਂਦੀਆਂ ਹਨ। ਇਸ ਵਿੱਚ ਕੋਈ ਸਬਸਕ੍ਰਿਪਸ਼ਨ ਜਾਂ ThunderPhone ਫੋਨ ਨੰਬਰ ਸ਼ਾਮਲ ਨਹੀਂ ਹੁੰਦਾ।

ਇੰਸਟਾਲ ਕਰੋ

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

ਪੈਕੇਜ Pipecat ਦੀ OpenAI Realtime ਸੇਵਾ ਨੂੰ ਰੈਪ ਕਰਦਾ ਹੈ, ਕਿਉਂਕਿ ThunderPhone ਦਾ Realtime WebSocket ਉਹੀ ਪ੍ਰੋਟੋਕੋਲ ਬੋਲਦਾ ਹੈ। ਇਸ ਲਈ pipecat-ai 1.8 ਜਾਂ ਇਸ ਤੋਂ ਨਵਾਂ ਵਰਜਨ ਚਾਹੀਦਾ ਹੈ।

ਸੇਵ ਕੀਤਾ ਏਜੰਟ ਚਲਾਓ

ਏਜੰਟ ਜੋ ਕੁਝ ਵੀ ਕਰਦਾ ਹੈ (prompt, ਆਵਾਜ਼, ਇੰਜਣ, ਭਾਸ਼ਾਵਾਂ, ਟੂਲ, ਸਵਾਗਤ, ਚੁੱਪ ਦੀ ਜਾਂਚ) ThunderPhone ਉੱਤੇ ਕੌਂਫਿਗਰ ਹੁੰਦਾ ਹੈ। ਪਾਈਪਲਾਈਨ ਸਿਰਫ਼ ਆਡੀਓ ਭੇਜਦੀ ਹੈ।

from pipecat.pipeline.pipeline import Pipeline
from pipecat.pipeline.worker import PipelineParams, PipelineWorker
from pipecat.processors.aggregators.llm_context import LLMContext
from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair
from pipecat_thunderphone import ThunderPhoneRealtimeLLMService
 
llm = ThunderPhoneRealtimeLLMService(agent_id=12)
 
context = LLMContext()
aggregators = LLMContextAggregatorPair(context)
pipeline = Pipeline([
    transport.input(),
    aggregators.user(),
    llm,
    aggregators.assistant(),
    transport.output(),
])
worker = PipelineWorker(pipeline, params=PipelineParams(allow_interruptions=True))

ਸੇਵ ਕੀਤਾ ਏਜੰਟ ਕਾਲ ਨੂੰ ਆਪਣੇ ਨਿਰਧਾਰਤ ਤਰੀਕੇ ਨਾਲ ਸ਼ੁਰੂ ਕਰਦਾ ਹੈ, ਇਸ ਲਈ ਸੇਵਾ Pipecat ਤੋਂ ਸ਼ੁਰੂਆਤੀ ਜਵਾਬ ਦੀ ਬੇਨਤੀ ਨਹੀਂ ਕਰਦੀ। ਜੇ ਤੁਸੀਂ ਫਿਰ ਵੀ ਇੱਕ ਚਾਹੁੰਦੇ ਹੋ ਤਾਂ greet_on_connect=True ਪਾਸ ਕਰੋ।

ਸੈਸ਼ਨ ਨੂੰ ਇਨਲਾਈਨ ਕੌਂਫਿਗਰ ਕਰੋ

agent_id ਤੋਂ ਬਿਨਾਂ, ਹਦਾਇਤਾਂ ਅਤੇ ਟੂਲ Pipecat ਕੌਂਟੈਕਸਟ ਤੋਂ ਆਉਂਦੇ ਹਨ, ਬਿਲਕੁਲ ਉਸੇ ਤਰ੍ਹਾਂ ਜਿਵੇਂ OpenAI ਲਈ ਆਉਂਦੇ ਹਨ। product ਇੰਜਣ ਚੁਣਦਾ ਹੈ ਅਤੇ voice ThunderPhone ਦੀ ਆਵਾਜ਼ ਚੁਣਦਾ ਹੈ।

from pipecat.adapters.schemas.function_schema import FunctionSchema
from pipecat.adapters.schemas.tools_schema import ToolsSchema
from pipecat.services.llm_service import FunctionCallParams
 
llm = ThunderPhoneRealtimeLLMService(product="bolt", voice="olivia", language="es")
 
async def check_availability(params: FunctionCallParams):
    slots = await calendar.free_slots(params.arguments["date"])
    await params.result_callback({"slots": slots})
 
llm.register_function("check_availability", check_availability)
 
context = LLMContext(
    messages=[{"role": "system", "content": "You are Acme Dental's receptionist."}],
    tools=ToolsSchema(standard_tools=[
        FunctionSchema(
            name="check_availability",
            description="Free appointment slots on a date",
            properties={"date": {"type": "string"}},
            required=["date"],
        )
    ]),
)

ਇਨਲਾਈਨ ਸੈਸ਼ਨ ਕਲਾਇੰਟ-ਨਿਯੰਤਰਿਤ ਹੁੰਦੇ ਹਨ: ਏਜੰਟ ਪਹਿਲਾਂ ਬੋਲਦਾ ਹੈ ਕਿਉਂਕਿ Pipecat ਕੌਂਟੈਕਸਟ ਆਉਣ 'ਤੇ ਜਵਾਬ ਦੀ ਬੇਨਤੀ ਕਰਦਾ ਹੈ, ਅਤੇ ਚੁੱਪ ਦੌਰਾਨ ਉਦੋਂ ਤੱਕ ਚੁੱਪ ਰਹਿੰਦਾ ਹੈ ਜਦੋਂ ਤੱਕ ਤੁਸੀਂ ਕੋਈ ਸੁਨੇਹਾ ਨਹੀਂ ਜੋੜਦੇ ਜਾਂ ਕਿਸੇ ਹੋਰ ਜਵਾਬ ਦੀ ਬੇਨਤੀ ਨਹੀਂ ਕਰਦੇ।

ਵਿਕਲਪ

ਆਰਗੂਮੈਂਟਅਰਥ
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ਬੋਲਣ ਦੌਰਾਨ ਕਾਲਰ ਦੇ ਟ੍ਰਾਂਸਕ੍ਰਿਪਟ ਹਿੱਸੇ ਸਟ੍ਰੀਮ ਕਰੋ (ਵਾਧੂ ਬਿਲ ਕੀਤਾ ਜਾਂਦਾ ਹੈ)।
greet_on_connectਸੈਸ਼ਨ ਤਿਆਰ ਹੁੰਦੇ ਹੀ ਪਹਿਲਾ ਜਵਾਬ ਮੰਗੋ।
end_task_on_call_endedਜਦੋਂ ThunderPhone ਕਾਲ ਸਮਾਪਤ ਕਰਦਾ ਹੈ ਤਾਂ EndWorkerFrame ਪੁਸ਼ ਕਰੋ (ਡਿਫਾਲਟ ਰੂਪ ਵਿੱਚ ਚਾਲੂ)।

ਘਟਨਾਵਾਂ

ThunderPhone ਰੀਅਲਟਾਈਮ ਪ੍ਰੋਟੋਕੋਲ ਦੇ ਉੱਪਰ ਪਲੇਟਫਾਰਮ ਘਟਨਾਵਾਂ ਜੋੜਦਾ ਹੈ। ਸੇਵਾ ਉਹਨਾਂ ਨੂੰ ਹੈਂਡਲਰਾਂ ਤੱਕ ਪਹੁੰਚਾਉਂਦੀ ਹੈ:

@llm.event_handler("on_call_ended")
async def on_call_ended(service, event):
    print("call ended:", event["reason"], "call id:", service.call_id)

ਸੈਸ਼ਨ ਲਾਈਵ ਹੋਣ ਤੋਂ ਬਾਅਦ service.call_id ਸੈੱਟ ਹੁੰਦਾ ਹੈ। ਕਾਲ ਤੋਂ ਬਾਅਦ ਰਿਕਾਰਡਿੰਗ, ਟ੍ਰਾਂਸਕ੍ਰਿਪਟ ਅਤੇ ਗਰੇਡ ਪ੍ਰਾਪਤ ਕਰਨ ਲਈ ਇਸਨੂੰ GET /v1/calls/{call_id} ਨਾਲ ਵਰਤੋ।

ਸੀਮਾਵਾਂ

  • ਟਰਨ ਡਿਟੈਕਸ਼ਨ ਸਰਵਰ-ਸਾਈਡ ਹੈ ਅਤੇ ਹਮੇਸ਼ਾ ਚਾਲੂ ਰਹਿੰਦਾ ਹੈ; Pipecat ਦੁਆਰਾ ਚਲਾਏ ਟਰਨ (turn_detection=False) ਸਮਰਥਿਤ ਨਹੀਂ ਹਨ।
  • ਸੇਵਾ 'ਤੇ ਰਜਿਸਟਰ ਕੀਤੇ ਫੰਕਸ਼ਨ ਸਿਰਫ਼ ਇਨਲਾਈਨ ਸੈਸ਼ਨਾਂ ਲਈ ਚੱਲਦੇ ਹਨ। ਸੇਵ ਕੀਤਾ ਏਜੰਟ ThunderPhone 'ਤੇ ਆਪਣੇ ਟੂਲ ਚਲਾਉਂਦਾ ਹੈ।
  • ਦੋਵੇਂ ਦਿਸ਼ਾਵਾਂ ਵਿੱਚ ਆਡੀਓ 24 kHz 'ਤੇ 16-ਬਿੱਟ ਮੋਨੋ PCM ਹੈ।
  • ਵੀਡੀਓ ਫਰੇਮ ਅਣਡਿੱਠੇ ਕੀਤੇ ਜਾਂਦੇ ਹਨ।