JoshTest2 / app.py
LittleMonkeyLab's picture
Upload app.py with huggingface_hub
c012653 verified
raw
history blame contribute delete
576 Bytes
import os
import gradio as gr
from openai import OpenAI
client = OpenAI(
base_url="https://router.huggingface.co/v1",
api_key=os.getenv("HF_TOKEN")
)
def chat(message, history):
response = client.chat.completions.create(
model="mistralai/Mistral-7B-Instruct-v0.3",
messages=[{"role": "user", "content": message}],
max_tokens=256
)
return response.choices[0].message.content
demo = gr.ChatInterface(fn=chat, title="Simple Chat")
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860, show_api=False)