1 line
2.0 KiB
JSON
1 line
2.0 KiB
JSON
{"repo": "akdeb/pipecat-test", "files": {"grok_route.py": {"f7c9068d48c1a3e0d4d9baa45112f79c86b3530c": {"t": 1785674570.3851085, "n": 1839, "h": "96b34495b78356df", "c": "\"\"\"Grok Realtime native speech-to-speech pipeline builder.\"\"\"\n\nfrom __future__ import annotations\n\nimport os\n\nfrom character_prompt import LANGUAGE_LEARNING_PAL_PROMPT\nfrom pipecat.processors.aggregators.llm_context import LLMContext\nfrom pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair\n\n\ndef build_grok_route(input_processor, context: LLMContext):\n try:\n from pipecat.services.xai.realtime.events import (\n AudioConfiguration,\n AudioInput,\n AudioOutput,\n PCMAudioFormat,\n SessionProperties,\n TurnDetection,\n )\n from pipecat.services.xai.realtime.llm import GrokRealtimeLLMService\n except Exception as exc:\n raise RuntimeError(\n \"Grok route requires pipecat-ai[grok]. Add the grok extra and redeploy.\"\n ) from exc\n\n api_key = os.getenv(\"XAI_API_KEY\")\n if not api_key:\n raise RuntimeError(\"Grok route requires XAI_API_KEY.\")\n\n voice = os.getenv(\"GROK_VOICE\", \"Ara\")\n\n llm = GrokRealtimeLLMService(\n api_key=api_key,\n settings=GrokRealtimeLLMService.Settings(\n session_properties=SessionProperties(\n instructions=(\n LANGUAGE_LEARNING_PAL_PROMPT\n ),\n voice=voice,\n turn_detection=TurnDetection(type=\"server_vad\"),\n audio=AudioConfiguration(\n input=AudioInput(format=PCMAudioFormat(rate=16000)),\n output=AudioOutput(format=PCMAudioFormat(rate=24000)),\n ),\n ),\n ),\n )\n\n user_aggregator, assistant_aggregator = LLMContextAggregatorPair(context)\n processors = [\n input_processor,\n user_aggregator,\n llm,\n ]\n\n return processors, assistant_aggregator\n"}}}} |