Spaces:
Sleeping
Sleeping
Nitzantry1
commited on
Commit
โข
53a67f8
1
Parent(s):
4da81f8
Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,23 @@
|
|
1 |
-
import
|
2 |
import gradio as gr
|
3 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
4 |
-
import torch
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
-
model = AutoModelForCausalLM.from_pretrained('dicta-il/dictalm-7b-instruct', trust_remote_code=True)
|
9 |
|
10 |
-
# ืืืืจืช ืืคืื ืงืฆืื ืืฆ'ืื ืขื ืืืืื
|
11 |
def chat_with_model(prompt):
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
top_k=50,
|
18 |
-
top_p=0.95,
|
19 |
-
temperature=0.5, # ืืืจืืช ืืืืคืจืืืจื ืืืงืื ืช ืืืงืจืืืืช
|
20 |
-
max_length=50, # ืืงืื ืช ืืืงืกืืืื ืืืกืคืจ ืงืื ืืืชืจ
|
21 |
-
min_new_tokens=5
|
22 |
-
)
|
23 |
-
output = model.generate(**kwargs)
|
24 |
-
response_text = tokenizer.batch_decode(output, skip_special_tokens=True)[0]
|
25 |
-
return response_text
|
26 |
|
27 |
-
# ืืฆืืจืช ืืืฉืง ืขื Gradio
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from gradio_client import Client
|
2 |
import gradio as gr
|
|
|
|
|
3 |
|
4 |
+
# ืืืืืจ ื-Space ืขื ืืืืื ื-Hugging Face
|
5 |
+
client = Client("dicta-il/dictalm2.0-instruct-demo")
|
|
|
6 |
|
|
|
7 |
def chat_with_model(prompt):
|
8 |
+
result = client.predict(
|
9 |
+
message=prompt,
|
10 |
+
api_name="/chat"
|
11 |
+
)
|
12 |
+
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
+
# ืืฆืืจืช ืืืฉืง ืืชืงืื ืขื Gradio
|
15 |
+
with gr.Blocks() as demo:
|
16 |
+
gr.Markdown("# Chat with DictaLM Model")
|
17 |
+
with gr.Row():
|
18 |
+
input_text = gr.Textbox(label="Enter your prompt here", lines=3)
|
19 |
+
output_text = gr.Textbox(label="Model's response", lines=5)
|
20 |
+
submit_btn = gr.Button("Submit")
|
21 |
+
submit_btn.click(chat_with_model, inputs=input_text, outputs=output_text)
|
22 |
+
|
23 |
+
demo.launch()
|