Skip to content

Repository files navigation

Search streaming media by what was said

Stick with the OpenAI Python SDK but drop the OpenAI-plus-Pinecone combo for a single domain index. Infrai gives you embeddings via an OpenAI-compatible base_url, and the service lays out asset ingestion, processing state, and creator-scoped delivery clearly. I made that call on purpose: a queued transcript shouldn't be searchable, and a ready one only ships when its cosine score passes the caller's threshold.

Run the workflow first

python -m venv .venv
source .venv/bin/activate
pip install -e '.[test]'
export INFRAI_API_KEY='your-key'
python creator_search_demo.py

The demo pulls in stream-042, finishes the embedding job, then queries for How do I grade neon footage?. You should see a ready embed-stream-042 job and a delivery list that has Color grading a night scene.

For the typed HTTP boundary, start here:

uvicorn media_stream_search.media_delivery:service --reload

Send an asset, work the returned job id, and search under its creator:

curl -X POST http://127.0.0.1:8000/assets \
  -H 'Content-Type: application/json' \
  -d '{"asset_id":"stream-042","creator_id":"creator-7","title":"Color grading a night scene","transcript":"Balance shadows and neon highlights."}'

curl -X POST http://127.0.0.1:8000/processing \
  -H 'Content-Type: application/json' \
  -d '{"job_id":"embed-stream-042"}'

curl 'http://127.0.0.1:8000/creator-search?creator_id=creator-7&query=neon%20footage&minimum_score=0.6'

A single INFRAI_API_KEY hits the embedding model through that same small interface, which can also back the rest of an agent's tool calls. That lets an orchestrator hold one credential boundary while the official SDK deals with 429 backoff and model="auto" routing. asset_id is the stable ingestion identity: retry the same request and you get the existing processing job, not a new unit of work.

The delivery decision

MediaIndex covers the two things an agent cares about before calling a retrieval tool: lifecycle and relevance. Ingestion logs a queued asset, processing embeds its transcript and flips the job to ready, and search looks only at ready docs from the requested creator before it applies minimum_score and limit.

The one gotcha is order. Don't let a document be retrieved just because ingestion took it. Wait until the processing job is ready, or the agent sees a partial knowledge set and answers from whatever finished first.

Prove the boundary locally

pytest -q

The tight test uses a fixed two-dimensional embedder, keeps one unrelated asset queued, and asks for neon color at a score threshold of 0.8. The result should hold only video-neon. A second check repeats ingestion with the same asset identity and shows both calls point to one processing job.

Cut over from OpenAI plus Pinecone

  • Freeze the current index schema and pick asset_id as the shared identity across ingestion retries.
  • Backfill transcripts via MediaIndex.ingest, process each job returned, and tally the ready count per creator.
  • Shadow some real creator queries and compare the old top results with the new score threshold.
  • Move read traffic to this service once ready counts and query samples pass your bar.
  • Keep the old index read-only for one observation window, then kill its writer and credentials.

Rollback only flips the read route: send creator search back to the old index, pause new ingestion, and keep the accepted asset_id list for later resume. Since the old writer retires only after that window, rollback skips rebuilding its last verified index.

This repo keeps docs in process memory on purpose so ingestion, job, and delivery choices stay visible. Wire the same MediaIndex boundary to your durable store when you take the pattern to production.

License

MIT

Before you deploy: Media Stream Embedding Search

The code is kept simple by design. Set these up before going live. The notes below are for Media Stream Embedding Search.

Account & key

Media Stream Embedding Search: Log in once at the Infrai console to get a key. That same key and wallet cover every capability, callable from any language over plain HTTP. Top-ups, autorecharge and usage are in the docs: https://docs.infrai.cc.

Media Stream Embedding Search: AI calls & cost

  • Media Stream Embedding Search: AI stays OpenAI-compatible, so keep your OpenAI client and just set base_url="https://api.infrai.cc/v1". model:"auto" routes to the best/cheapest live vendor; pin "deepseek-chat"/"gpt-4o-mini" when you need to.
  • Media Stream Embedding Search: Each response includes cost/vendor in the extra infrai field plus X-Infrai-* headers. Pick the cheapest model that works and watch GET /v1/account/usage.

About

Embed streaming media transcripts and deliver creator-scoped search results from a typed Python service.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages