Spaces:
Sleeping
Sleeping
Commit
路
41ceafd
1
Parent(s):
a65994d
app.py
CHANGED
@@ -1,9 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
-
import
|
|
|
|
|
4 |
|
5 |
-
#
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# Instrucciones para mejorar resoluciones judiciales
|
9 |
instructions = """
|
@@ -52,13 +64,13 @@ Como Ministro de la Corte Suprema de Chile, su objetivo es mejorar y finalizar l
|
|
52 |
- Proporcione una respuesta completa, incluyendo correcciones, sugerencias y la resoluci贸n final.
|
53 |
- Aseg煤rese de una presentaci贸n concisa y unificada de toda la informaci贸n.
|
54 |
"""
|
55 |
-
@spaces.GPU(duration=120) #
|
56 |
-
def mejorar_resolucion(message, history):
|
57 |
-
prompt = f"{instructions}\n\n{message}"
|
58 |
-
response = pipe(prompt, max_new_tokens=
|
59 |
return response[0]["generated_text"]
|
60 |
|
61 |
# Configuraci贸n de la interfaz de Gradio
|
62 |
with gr.Blocks() as demo:
|
63 |
chatbot = gr.ChatInterface(fn=mejorar_resolucion, title="Mejora de Resoluciones Judiciales")
|
64 |
-
demo.launch(
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
+
import torch
|
4 |
+
import spaces
|
5 |
+
import time
|
6 |
|
7 |
+
# Funci贸n para verificar y esperar una GPU
|
8 |
+
def wait_for_gpu():
|
9 |
+
while not torch.cuda.is_available():
|
10 |
+
print("Esperando por una GPU...")
|
11 |
+
time.sleep(10) # Espera 10 segundos antes de volver a verificar
|
12 |
+
print("GPU encontrada, continuando con la configuraci贸n.")
|
13 |
+
|
14 |
+
# Espera hasta que una GPU est茅 disponible
|
15 |
+
wait_for_gpu()
|
16 |
+
|
17 |
+
# Configuraci贸n del pipeline con el modelo Meta-Llama usando GPU
|
18 |
+
pipe = pipeline("text-generation", model="meta-llama/Meta-Llama-3.1-405B-Instruct-FP8", device=0)
|
19 |
|
20 |
# Instrucciones para mejorar resoluciones judiciales
|
21 |
instructions = """
|
|
|
64 |
- Proporcione una respuesta completa, incluyendo correcciones, sugerencias y la resoluci贸n final.
|
65 |
- Aseg煤rese de una presentaci贸n concisa y unificada de toda la informaci贸n.
|
66 |
"""
|
67 |
+
@spaces.GPU(duration=120) # Ajusta la duraci贸n seg煤n el tiempo estimado de la tarea
|
68 |
+
def mejorar_resolucion(message, history=None):
|
69 |
+
prompt = f"Analiza profundamente y aplica estas {instructions}\n\n y luego mejora esta resoluci贸n judicial {message}"
|
70 |
+
response = pipe(prompt, max_new_tokens=1000, return_full_text=False, clean_up_tokenization_spaces=True)
|
71 |
return response[0]["generated_text"]
|
72 |
|
73 |
# Configuraci贸n de la interfaz de Gradio
|
74 |
with gr.Blocks() as demo:
|
75 |
chatbot = gr.ChatInterface(fn=mejorar_resolucion, title="Mejora de Resoluciones Judiciales")
|
76 |
+
demo.launch()
|