Spaces:
Running
Running
雷娃
commited on
Commit
·
b3dfe3c
1
Parent(s):
291372b
modify output length
Browse files- app.py +3 -3
- app_api.py +7 -5
app.py
CHANGED
@@ -12,7 +12,7 @@ client = OpenAI(
|
|
12 |
)
|
13 |
|
14 |
# define chat function
|
15 |
-
def chat(user_input,
|
16 |
# chat history
|
17 |
messages_template = [
|
18 |
# {"role": "system", "content": "You are Ling, an assistant created by inclusionAI"},
|
@@ -22,7 +22,7 @@ def chat(user_input, max_new_tokens=20480):
|
|
22 |
response = client.chat.completions.create(
|
23 |
model="Ling-lite-1.5-250604",
|
24 |
messages=messages_template,
|
25 |
-
max_tokens=
|
26 |
temperature=0.01,
|
27 |
top_p=1,
|
28 |
)
|
@@ -47,7 +47,7 @@ with gr.Blocks(css="""
|
|
47 |
)
|
48 |
|
49 |
with gr.Row():
|
50 |
-
max_tokens_slider = gr.Slider(minimum=
|
51 |
|
52 |
# output_box = gr.Textbox(lines=10, label="Response")
|
53 |
output_box = gr.Markdown(label="Response", elem_id="markdown-output")
|
|
|
12 |
)
|
13 |
|
14 |
# define chat function
|
15 |
+
def chat(user_input, max_tokens=11264):
|
16 |
# chat history
|
17 |
messages_template = [
|
18 |
# {"role": "system", "content": "You are Ling, an assistant created by inclusionAI"},
|
|
|
22 |
response = client.chat.completions.create(
|
23 |
model="Ling-lite-1.5-250604",
|
24 |
messages=messages_template,
|
25 |
+
max_tokens=max_tokens,
|
26 |
temperature=0.01,
|
27 |
top_p=1,
|
28 |
)
|
|
|
47 |
)
|
48 |
|
49 |
with gr.Row():
|
50 |
+
max_tokens_slider = gr.Slider(minimum=100, maximum=10000, step=100, label="Generated length")
|
51 |
|
52 |
# output_box = gr.Textbox(lines=10, label="Response")
|
53 |
output_box = gr.Markdown(label="Response", elem_id="markdown-output")
|
app_api.py
CHANGED
@@ -12,21 +12,23 @@ client = OpenAI(
|
|
12 |
)
|
13 |
|
14 |
# define chat function
|
15 |
-
def chat(user_input,
|
16 |
# chat history
|
17 |
messages_template = [
|
18 |
-
|
19 |
{"role": "user", "content": user_input}
|
20 |
]
|
21 |
|
22 |
response = client.chat.completions.create(
|
23 |
model="Ling-lite-1.5-250604",
|
24 |
messages=messages_template,
|
25 |
-
max_tokens=
|
26 |
temperature=0.01,
|
27 |
top_p=1,
|
28 |
)
|
29 |
-
|
|
|
|
|
30 |
|
31 |
|
32 |
|
@@ -45,7 +47,7 @@ with gr.Blocks(css="""
|
|
45 |
)
|
46 |
|
47 |
with gr.Row():
|
48 |
-
max_tokens_slider = gr.Slider(minimum=
|
49 |
|
50 |
# output_box = gr.Textbox(lines=10, label="Response")
|
51 |
output_box = gr.Markdown(label="Response", elem_id="markdown-output")
|
|
|
12 |
)
|
13 |
|
14 |
# define chat function
|
15 |
+
def chat(user_input, max_tokens=11264):
|
16 |
# chat history
|
17 |
messages_template = [
|
18 |
+
# {"role": "system", "content": "You are Ling, an assistant created by inclusionAI"},
|
19 |
{"role": "user", "content": user_input}
|
20 |
]
|
21 |
|
22 |
response = client.chat.completions.create(
|
23 |
model="Ling-lite-1.5-250604",
|
24 |
messages=messages_template,
|
25 |
+
max_tokens=max_tokens,
|
26 |
temperature=0.01,
|
27 |
top_p=1,
|
28 |
)
|
29 |
+
resp_text = response.choices[0].message.content
|
30 |
+
print(resp_text)
|
31 |
+
yield resp_text
|
32 |
|
33 |
|
34 |
|
|
|
47 |
)
|
48 |
|
49 |
with gr.Row():
|
50 |
+
max_tokens_slider = gr.Slider(minimum=100, maximum=10000, step=100, label="Generated length")
|
51 |
|
52 |
# output_box = gr.Textbox(lines=10, label="Response")
|
53 |
output_box = gr.Markdown(label="Response", elem_id="markdown-output")
|