Spaces:
Sleeping
Sleeping
Commit
·
5e79494
1
Parent(s):
ecb38ea
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ def format_prompt(message, history):
|
|
14 |
return prompt
|
15 |
|
16 |
def generate(
|
17 |
-
prompt, history, system_prompt, temperature=0.9, max_new_tokens=2048, top_p=0.95, repetition_penalty=1.0,
|
18 |
):
|
19 |
global system_prompt_set
|
20 |
|
@@ -36,27 +36,22 @@ def generate(
|
|
36 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=True)
|
37 |
output = ""
|
38 |
|
39 |
-
if not system_prompt_set:
|
40 |
-
additional_inputs[0].value = system_prompt
|
41 |
-
system_prompt_set = True
|
42 |
-
|
43 |
for response in stream:
|
44 |
output += response.token.text
|
45 |
yield output
|
46 |
return output
|
47 |
|
48 |
-
additional_inputs = [
|
49 |
-
gr.Radio(
|
50 |
-
label="System Prompt",
|
51 |
-
choices=["MAESTRO", "MEDICO", "TERAPEUTA", "NUTRIOLOGO", "FILOSOFO", "PROGRAMADOR"],
|
52 |
-
)
|
53 |
-
]
|
54 |
-
|
55 |
chat_interface = gr.ChatInterface(
|
56 |
fn=generate,
|
57 |
-
chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
|
58 |
additional_inputs=additional_inputs,
|
59 |
-
concurrency_limit=
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
)
|
61 |
|
62 |
chat_interface.launch(show_api=False)
|
|
|
14 |
return prompt
|
15 |
|
16 |
def generate(
|
17 |
+
prompt, history, system_prompt="Soy Maya 3.0 tu asistente experto: abogado, historiador, economista, médico, terapeuta, nutriologo, filosofo o programador", temperature=0.9, max_new_tokens=2048, top_p=0.95, repetition_penalty=1.0,
|
18 |
):
|
19 |
global system_prompt_set
|
20 |
|
|
|
36 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=True)
|
37 |
output = ""
|
38 |
|
|
|
|
|
|
|
|
|
39 |
for response in stream:
|
40 |
output += response.token.text
|
41 |
yield output
|
42 |
return output
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
chat_interface = gr.ChatInterface(
|
45 |
fn=generate,
|
46 |
+
chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel", height=600),
|
47 |
additional_inputs=additional_inputs,
|
48 |
+
concurrency_limit=2,
|
49 |
+
theme="soft",
|
50 |
+
retry_btn=None,
|
51 |
+
undo_btn=None,
|
52 |
+
clear_btn=None,
|
53 |
+
additional_inputs_accordion=None,
|
54 |
+
submit_btn="Enviar",
|
55 |
)
|
56 |
|
57 |
chat_interface.launch(show_api=False)
|