Spaces:
Build error
Build error
雷娃
commited on
Commit
·
9f21eff
1
Parent(s):
41993f0
modify the layout of input and output
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
16 |
).eval()
|
17 |
|
18 |
# define chat function
|
19 |
-
def chat(user_input, max_new_tokens=
|
20 |
# chat history
|
21 |
messages = [
|
22 |
{"role": "system", "content": "You are Ling, an assistant created by inclusionAI"},
|
@@ -44,23 +44,56 @@ def chat(user_input, max_new_tokens=102400):
|
|
44 |
|
45 |
thread.join()
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
# Construct Gradio Interface
|
48 |
-
interface = gr.Interface(
|
49 |
-
fn=chat,
|
50 |
-
inputs=[
|
51 |
-
gr.Textbox(lines=8, label="输入你的问题"),
|
52 |
-
gr.Slider(minimum=100, maximum=102400, step=50, label="生成长度")
|
53 |
-
],
|
54 |
-
outputs=[
|
55 |
-
gr.Textbox(lines=8, label="模型回复")
|
56 |
-
],
|
57 |
-
title="Ling-lite-1.5 AI助手",
|
58 |
-
description="基于 [inclusionAI/Ling-lite-1.5](https://huggingface.co/inclusionAI/Ling-lite-1.5) 的对话式文本生成演示。",
|
59 |
-
examples=[
|
60 |
-
["介绍大型语言模型的基本概念"],
|
61 |
-
["如何解决数学问题中的长上下文依赖?"]
|
62 |
-
]
|
63 |
-
)
|
64 |
|
65 |
# launch Gradion Service
|
66 |
-
interface.launch()
|
|
|
16 |
).eval()
|
17 |
|
18 |
# define chat function
|
19 |
+
def chat(user_input, max_new_tokens=2048):
|
20 |
# chat history
|
21 |
messages = [
|
22 |
{"role": "system", "content": "You are Ling, an assistant created by inclusionAI"},
|
|
|
44 |
|
45 |
thread.join()
|
46 |
|
47 |
+
# Create a custom layout using Blocks
|
48 |
+
with gr.Blocks() as demo:
|
49 |
+
gr.Markdown(
|
50 |
+
"## Ling-lite-1.5 AI助手\n"
|
51 |
+
"基于 [inclusionAI/Ling-lite-1.5](https://huggingface.co/inclusionAI/Ling-lite-1.5) 的对话式文本生成演示。"
|
52 |
+
)
|
53 |
+
|
54 |
+
with gr.Row():
|
55 |
+
max_tokens_slider = gr.Slider(minimum=100, maximum=2048, step=50, label="生成长度")
|
56 |
+
|
57 |
+
output_box = gr.Textbox(lines=10, label="模型回复")
|
58 |
+
|
59 |
+
input_box = gr.Textbox(lines=8, label="输入你的问题")
|
60 |
+
|
61 |
+
examples = gr.Examples(
|
62 |
+
examples=[
|
63 |
+
["介绍大型语言模型的基本概念"],
|
64 |
+
["如何解决数学问题中的长上下文依赖?"]
|
65 |
+
],
|
66 |
+
inputs=input_box
|
67 |
+
)
|
68 |
+
|
69 |
+
interface = gr.Interface(
|
70 |
+
fn=chat,
|
71 |
+
inputs=[input_box, max_tokens_slider],
|
72 |
+
outputs=output_box,
|
73 |
+
live=False # disable auto-triggering on input change
|
74 |
+
)
|
75 |
+
|
76 |
+
# launch Gradio Service
|
77 |
+
demo.queue()
|
78 |
+
demo.launch()
|
79 |
+
|
80 |
# Construct Gradio Interface
|
81 |
+
#interface = gr.Interface(
|
82 |
+
# fn=chat,
|
83 |
+
# inputs=[
|
84 |
+
# gr.Textbox(lines=8, label="输入你的问题"),
|
85 |
+
# gr.Slider(minimum=100, maximum=102400, step=50, label="生成长度")
|
86 |
+
# ],
|
87 |
+
# outputs=[
|
88 |
+
# gr.Textbox(lines=8, label="模型回复")
|
89 |
+
# ],
|
90 |
+
# title="Ling-lite-1.5 AI助手",
|
91 |
+
# description="基于 [inclusionAI/Ling-lite-1.5](https://huggingface.co/inclusionAI/Ling-lite-1.5) 的对话式文本生成演示。",
|
92 |
+
# examples=[
|
93 |
+
# ["介绍大型语言模型的基本概念"],
|
94 |
+
# ["如何解决数学问题中的长上下文依赖?"]
|
95 |
+
# ]
|
96 |
+
#)
|
97 |
|
98 |
# launch Gradion Service
|
99 |
+
#interface.launch()
|