try3 / app.py
Nitzantry1's picture
Update app.py
4cc2167 verified
raw
history blame
1.06 kB
from gradio_client import Client
import gradio as gr
# ื—ื™ื‘ื•ืจ ืœ-Space ืขื ื”ืžื•ื“ืœ ื‘-Hugging Face
client = Client("dicta-il/dictalm2.0-instruct-demo")
def chat_with_model(history):
prompt = history[-1]["user"]
result = client.predict(
message=prompt,
api_name="/chat"
)
return history + [{"user": prompt, "bot": result}]
# ื™ืฆื™ืจืช ืžืžืฉืง ืžืชืงื“ื ืขื Gradio ื‘ืฆื•ืจืช ืฆ'ื˜-ื‘ื•ื˜
with gr.Blocks(theme="default") as demo:
gr.Markdown("# ืฆ'ืื˜ ืขื ืžื•ื“ืœ DictaLM", elem_id="title")
chatbot = gr.Chatbot(label="ืฆ'ืื˜ ืขื ืžื•ื“ืœ DictaLM")
with gr.Row():
user_input = gr.Textbox(placeholder="ื”ื›ื ืก ืืช ื”ื”ื•ื“ืขื” ืฉืœืš ื›ืืŸ...", label="", lines=1)
send_button = gr.Button("ืฉืœื—")
def user_chat(history, message):
return history + [{"user": message}], ""
send_button.click(user_chat, inputs=[chatbot, user_input], outputs=[chatbot, user_input], queue=False)
send_button.click(chat_with_model, inputs=chatbot, outputs=chatbot)
demo.launch()