Build natural language search interfaces that combine Gracenote metadata with LLM understanding. This kind of application is good for streaming platforms, content discovery apps, voice assistants, chatbots, search interfaces, etc. This example shows how to:
Accept natural language queries ("best horror movies from the 1980s")
Return ranked, relevant results with metadata
Show "where to watch" availability
Handle complex multi-criteria searches
Streamlit Search Prototype
Build a working search app in 15 minutes with zero frontend code.
.env configured with your Cognito credentials and at least one LLM API key
mcp_utils.py copied into your project directory
Create Search App
Create streamlit_app.py:
Code
import streamlit as stimport asyncioimport jsonimport osimport sysfrom dotenv import load_dotenvfrom litellm import completion# Add shared folder to pathsys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'shared'))from mcp_utils import GracenoteClientload_dotenv()st.set_page_config(page_title="Entertainment Search", page_icon="🎬", layout="wide")SYSTEM_PROMPT = """You are an entertainment search assistant powered by Gracenote.Your role:- Help users find movies and TV shows with precise, relevant results- Provide "where to watch" information when available- Rank results by relevance to the user's query- Be conversational and helpfulRules:1. Always use resolve_entities to identify content2. Use get_availability for "where to watch" queries3. Include title, year, brief description, and availability4. Rank results by relevance to the query"""async def search(query, model_name): """Search for content using MCP + LiteLLM.""" async with GracenoteClient() as client: tools = await client.tools_for_litellm() messages = [ {"role": "system", "content": SYSTEM_PROMPT}, {"role": "user", "content": query} ] response = completion(model=model_name, messages=messages, tools=tools, max_tokens=2048) response_message = response.choices[0].message while response_message.get("tool_calls"): messages.append(response_message.model_dump()) for tool_call in response_message.tool_calls: tool_args = json.loads(tool_call.function.arguments) result = await client.call_tool(tool_call.function.name, tool_args) messages.append({ "role": "tool", "tool_call_id": tool_call.id, "name": tool_call.function.name, "content": str(result.content) }) response = completion(model=model_name, messages=messages, tools=tools, max_tokens=2048) response_message = response.choices[0].message return response_message.content or "No results found"# Streamlit UIst.title("🔍 Search & Discovery")st.caption("Find movies and TV shows using natural language queries")st.markdown("---")# Sidebarwith st.sidebar: st.header("Settings") selected_model = st.selectbox( "Choose AI Model", options=["claude-sonnet-4-6", "gpt-4o", "gemini/gemini-2.5-flash"], index=0 ) st.markdown("---") st.header("About This Example") st.markdown(""" **Search & Discovery** demonstrates how to build natural language search interfaces. **Technology:** - **Gracenote MCP Server** for metadata - **LiteLLM** for universal AI model routing - **Streamlit** for rapid prototyping **Try these queries:** - "Best horror movies from the 1980s" - "Where can I watch The Office?" - "Sci-fi movies with time travel" - "Shows similar to Breaking Bad" """)# Search inputquery = st.text_input( "Search for movies or TV shows", placeholder="What are the best horror movies from the 1980s?", key="search_input")# Example queriesst.markdown("**Try these:**")col1, col2, col3 = st.columns(3)with col1: if st.button("Best sci-fi movies"): query = "What are the best sci-fi movies of all time?"with col2: if st.button("Where to watch Friends"): query = "Where can I watch Friends?"with col3: if st.button("Tom Hanks movies"): query = "What are the most popular Tom Hanks movies?"# Searchif query: with st.spinner(f"Searching using {selected_model}..."): result = asyncio.run(search(query, selected_model)) st.markdown(result)
Run It
Code
streamlit run streamlit_app.py # Opens at http://localhost:8501
Note: First queries may take 10-30 seconds as the system authenticates and connects.