zjasper666's picture
Update app.py
9dcfd7a verified
raw
history blame contribute delete
591 Bytes
import gradio as gr
from openai import OpenAI
client = OpenAI(
base_url="http://soggy-sage-goat-8000.1.cricket.hyperbolic.xyz:30000/v1/",
api_key="hyperbolic"
)
def predict(message, history):
history.append({"role": "user", "content": message})
stream = client.chat.completions.create(messages=history, model="meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", stream=True)
chunks = []
for chunk in stream:
chunks.append(chunk.choices[0].delta.content or "")
yield "".join(chunks)
demo = gr.ChatInterface(predict, type="messages")
demo.launch()