|
import gradio as gr |
|
|
|
|
|
interface = gr.load("models/Mixtral-8x7B-Instruct-v0.1") |
|
|
|
DEFAULT_SYSTEM_PROMPT = """ |
|
You are a helpful assistant in normal conversation. |
|
When given a problem to solve, you are an expert problem-solving assistant. |
|
Your task is to provide a detailed, step-by-step solution to a given question. |
|
""" |
|
|
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown("# Custom Chat Interface with AI") |
|
|
|
system_prompt = gr.Textbox(value=DEFAULT_SYSTEM_PROMPT, lines=5, label="System Prompt") |
|
chatbot = gr.Chatbot(label="Chat") |
|
|
|
|
|
def chat(message): |
|
|
|
chat_history = [(message, "user")] |
|
|
|
response = interface([system_prompt.value, message]) |
|
chat_history.append((response, "assistant")) |
|
return chat_history |
|
|
|
msg = gr.Textbox(label="Type your message here...", placeholder="Enter your message...") |
|
msg.submit(chat, inputs=msg, outputs=chatbot) |
|
|
|
demo.launch() |
|
|