LOCKIntegration
Gradio + Meridian chat interface
Embed Meridian's inference engine inside a Gradio Blocks app using the OpenAI-compatible client. One gr.ChatInterface call, zero boilerplate.
app.py
import gradio as gr
from openai import OpenAI
client = OpenAI(
base_url="https://api.meridian.sh/v1",
api_key="mrdn_sk_..."
)
def predict(message, history):
msgs = [{"role": "system", "content": "You are Meridian."}]
for h in history:
msgs.append({"role": "user", "content": h[0]})
msgs.append({"role": "assistant", "content": h[1]})
msgs.append({"role": "user", "content": message})
stream = client.chat.completions.create(
model="meridian-4",
messages=msgs,
stream=True,
)
partial = ""
for chunk in stream:
if chunk.choices[0].delta.content:
partial += chunk.choices[0].delta.content
yield partial
demo = gr.ChatInterface(
fn=predict,
title="Meridian Chat",
description="Powered by Meridian API",
)
demo.launch()- 1Install
gradioandopenaivia pip. - 2Set
base_urlto your Meridian endpoint and paste your API key. - 3Wrap the streaming predict function in
gr.ChatInterfaceand call.launch().