thanglekdi commited on
Commit
34ef4bd
·
1 Parent(s): 0619df4

test deepseek

Browse files
Files changed (1) hide show
  1. app.py +18 -24
app.py CHANGED
@@ -1,29 +1,23 @@
1
  import gradio as gr
2
  import call_api
3
 
4
- # Hàm format và respond giữ nguyên như trước
5
- def format_reply(raw_reply: str) -> str:
6
- lines = raw_reply.splitlines()
7
- out_lines = []
8
- for line in lines:
9
- line = line.strip()
10
- if not line:
11
- continue
12
- if line.startswith("Bước"):
13
- out_lines.append(f"**{line}**")
14
- else:
15
- out_lines.append(line)
16
- return "\n\n".join(out_lines)
17
-
18
- def respond(
19
- message, history, system_message, max_tokens, temperature, top_p,
20
- file_upload=None, image_upload=None
21
- ):
22
- raw = call_api.call_deepseek(
23
- message, history, system_message, max_tokens, temperature, top_p,
24
- file_upload=file_upload, image_upload=image_upload
25
- )
26
- return format_reply(raw)
27
 
28
  with gr.Blocks() as demo: # Bắt đầu Blocks
29
  # Thành phần hiển thị lịch sử chat
@@ -58,4 +52,4 @@ with gr.Blocks() as demo: # Bắt đầu Blocks
58
 
59
  # Chạy app
60
  if __name__ == "__main__":
61
- demo.launch()
 
1
  import gradio as gr
2
  import call_api
3
 
4
+ chat = gr.ChatInterface(
5
+ call_api.respond, #chat
6
+ title="Trợ lý Học Tập AI",
7
+ description="Nhập câu hỏi của bạn về Toán, Lý, Hóa, Văn… và nhận giải đáp chi tiết ngay lập tức!",
8
+ additional_inputs=[
9
+ gr.Textbox("Bạn là một chatbot tiếng Việt thân thiện.", label="System message"),
10
+ gr.Slider(1, 2048, value=200, step=1, label="Max new tokens"),
11
+ gr.Slider(0.1, 4.0, value=0.7, step=0.1, label="Temperature"),
12
+ gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
13
+ gr.Image(type="pil", label="Attach an image (optional)"),
14
+ gr.File(label="Upload a file (optional)"),
15
+ ],
16
+ # examples=[
17
+ # # Mỗi item: [message, system_message, max_tokens, temperature, top_p]
18
+ # ["tích phân của x^2 từ 0 đến 2 là gì? vui lòng lập luận từng bước, và đặt kết quả cuối cùng trong \boxed{}", "bạn là nhà toán học", 100, 0.7, 0.95],
19
+ # ],
20
+ )
 
 
 
 
 
 
21
 
22
  with gr.Blocks() as demo: # Bắt đầu Blocks
23
  # Thành phần hiển thị lịch sử chat
 
52
 
53
  # Chạy app
54
  if __name__ == "__main__":
55
+ chat.launch()