prefactor_livekit package
prefactor_livekit package
Section titled “prefactor_livekit package”Prefactor LiveKit integration package.
class prefactor_livekit.LiveKitToolSchemaConfig(span_type: str, input_schema: dict[str, ~typing.Any], result_schema: dict[str, ~typing.Any] = )
Section titled “class prefactor_livekit.LiveKitToolSchemaConfig(span_type: str, input_schema: dict[str, ~typing.Any], result_schema: dict[str, ~typing.Any] = )”Bases: object
Configuration for a tool-specific LiveKit span schema.
input_schema : dict[str, Any]
Section titled “input_schema : dict[str, Any]”result_schema : dict[str, Any]
Section titled “result_schema : dict[str, Any]”span_type : str
Section titled “span_type : str”class prefactor_livekit.PrefactorLiveKitSession(client: PrefactorCoreClient | None = None, agent_id: str | None = None, agent_name: str | None = None, instance: AgentInstanceHandle | None = None, tool_schemas: Mapping[str, LiveKitToolSchemaConfig | Mapping[str, Any]] | None = None)
Section titled “class prefactor_livekit.PrefactorLiveKitSession(client: PrefactorCoreClient | None = None, agent_id: str | None = None, agent_name: str | None = None, instance: AgentInstanceHandle | None = None, tool_schemas: Mapping[str, LiveKitToolSchemaConfig | Mapping[str, Any]] | None = None)”Bases: object
High-level LiveKit session wrapper for Prefactor tracing.
async attach(session: AgentSession[Any]) → AgentInstanceHandle
Section titled “async attach(session: AgentSession[Any]) → AgentInstanceHandle”Attach to an existing LiveKit session.
async close() → None
Section titled “async close() → None”Flush pending tasks and release wrapper-owned resources.
static create_client(config: PrefactorCoreConfig) → PrefactorCoreClient
Section titled “static create_client(config: PrefactorCoreConfig) → PrefactorCoreClient”Create a PrefactorCoreClient configured for use with this adaptor.
Use this when you need to manage the client and instance lifecycle
yourself (e.g. to share a client between the session wrapper and
other code) instead of letting from_config() manage them for you.
- Parameters: config – Core configuration for the client.
- Returns:
A PrefactorCoreClient ready for
await client.initialize().
Example
Section titled “Example”config = PrefactorCoreConfig(http_config=…) client = PrefactorLiveKitSession.create_client(config) await client.initialize()
instance = await client.create_agent_instance( : agent_id=”my-agent”, agent_version={“name”: “My Agent”}, agent_schema_version=…,
) session = PrefactorLiveKitSession(instance=instance)
async ensure_initialized() → AgentInstanceHandle
Section titled “async ensure_initialized() → AgentInstanceHandle”Initialize and return the active Prefactor instance.
classmethod from_config(api_url: str, api_token: str, agent_id: str | None = None, agent_name: str | None = None, schema_registry: SchemaRegistry | None = None, include_livekit_schemas: bool = True, tool_schemas: Mapping[str, LiveKitToolSchemaConfig | Mapping[str, Any]] | None = None) → PrefactorLiveKitSession
Section titled “classmethod from_config(api_url: str, api_token: str, agent_id: str | None = None, agent_name: str | None = None, schema_registry: SchemaRegistry | None = None, include_livekit_schemas: bool = True, tool_schemas: Mapping[str, LiveKitToolSchemaConfig | Mapping[str, Any]] | None = None) → PrefactorLiveKitSession”Create a wrapper from raw configuration.
async start(session: AgentSession[Any], agent: Agent, **kwargs: Any) → Any
Section titled “async start(session: AgentSession[Any], agent: Agent, **kwargs: Any) → Any”Attach and delegate to AgentSession.start().
prefactor_livekit.compile_livekit_agent_schema(tool_schemas: Mapping[str, LiveKitToolSchemaConfig | Mapping[str, Any]] | None = None) → tuple[dict[str, Any], dict[str, str]]
Section titled “prefactor_livekit.compile_livekit_agent_schema(tool_schemas: Mapping[str, LiveKitToolSchemaConfig | Mapping[str, Any]] | None = None) → tuple[dict[str, Any], dict[str, str]]”Compile built-in and tool-specific LiveKit schemas.
prefactor_livekit.register_livekit_schemas(registry: SchemaRegistry, tool_schemas: Mapping[str, LiveKitToolSchemaConfig | Mapping[str, Any]] | None = None) → dict[str, str]
Section titled “prefactor_livekit.register_livekit_schemas(registry: SchemaRegistry, tool_schemas: Mapping[str, LiveKitToolSchemaConfig | Mapping[str, Any]] | None = None) → dict[str, str]”Register LiveKit schemas in a schema registry.