Spaces:
Sleeping
Sleeping
Refactoriza la función `respond` en `app.py` para establecer valores predeterminados para `system_message`, `max_tokens`, `temperature` y `top_p`. Elimina los inputs adicionales en la interfaz de chat y habilita el modo de depuración en el lanzamiento de la aplicación.
Browse files
app.py
CHANGED
|
@@ -5,15 +5,17 @@ from huggingface_hub import InferenceClient
|
|
| 5 |
def respond(
|
| 6 |
message,
|
| 7 |
history: list[dict[str, str]],
|
| 8 |
-
system_message,
|
| 9 |
-
max_tokens,
|
| 10 |
-
temperature,
|
| 11 |
-
top_p,
|
| 12 |
hf_token: gr.OAuthToken,
|
| 13 |
):
|
| 14 |
"""
|
| 15 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 16 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
client = InferenceClient(token=hf_token.token, model="openbmb/MiniCPM-V-4_5")
|
| 18 |
|
| 19 |
messages = [{"role": "system", "content": system_message}]
|
|
@@ -46,18 +48,6 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
| 46 |
chatbot = gr.ChatInterface(
|
| 47 |
respond,
|
| 48 |
type="messages",
|
| 49 |
-
additional_inputs=[
|
| 50 |
-
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 51 |
-
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 52 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 53 |
-
gr.Slider(
|
| 54 |
-
minimum=0.1,
|
| 55 |
-
maximum=1.0,
|
| 56 |
-
value=0.95,
|
| 57 |
-
step=0.05,
|
| 58 |
-
label="Top-p (nucleus sampling)",
|
| 59 |
-
),
|
| 60 |
-
],
|
| 61 |
)
|
| 62 |
|
| 63 |
with gr.Blocks() as demo:
|
|
@@ -67,4 +57,6 @@ with gr.Blocks() as demo:
|
|
| 67 |
|
| 68 |
|
| 69 |
if __name__ == "__main__":
|
| 70 |
-
demo.launch(
|
|
|
|
|
|
|
|
|
| 5 |
def respond(
|
| 6 |
message,
|
| 7 |
history: list[dict[str, str]],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
hf_token: gr.OAuthToken,
|
| 9 |
):
|
| 10 |
"""
|
| 11 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 12 |
"""
|
| 13 |
+
# Configuración por defecto
|
| 14 |
+
system_message = "You are a friendly Chatbot."
|
| 15 |
+
max_tokens = 512
|
| 16 |
+
temperature = 0.7
|
| 17 |
+
top_p = 0.95
|
| 18 |
+
|
| 19 |
client = InferenceClient(token=hf_token.token, model="openbmb/MiniCPM-V-4_5")
|
| 20 |
|
| 21 |
messages = [{"role": "system", "content": system_message}]
|
|
|
|
| 48 |
chatbot = gr.ChatInterface(
|
| 49 |
respond,
|
| 50 |
type="messages",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
)
|
| 52 |
|
| 53 |
with gr.Blocks() as demo:
|
|
|
|
| 57 |
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
| 60 |
+
demo.launch(
|
| 61 |
+
debug=True, # Habilita recarga automática y debugging
|
| 62 |
+
)
|