Spaces:
Sleeping
Sleeping
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() |