Spaces:
Running
Running
eberhenriquez94
commited on
Commit
•
7ddca68
0
Parent(s):
initial commit
Browse files- .gitattributes +35 -0
- README.md +14 -0
- app.py +60 -0
- requirements.txt +1 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: New Space
|
3 |
+
emoji: 👁
|
4 |
+
colorFrom: purple
|
5 |
+
colorTo: purple
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 5.5.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: apache-2.0
|
11 |
+
short_description: s
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Importamos las librerías necesarias
|
2 |
+
import gradio as gr
|
3 |
+
from openai import OpenAI
|
4 |
+
|
5 |
+
# Inicializamos el cliente OpenAI para la API de NVIDIA
|
6 |
+
client = OpenAI(
|
7 |
+
base_url="https://integrate.api.nvidia.com/v1",
|
8 |
+
api_key="$API_KEY_REQUIRED_IF_EXECUTING_OUTSIDE_NGC"
|
9 |
+
)
|
10 |
+
|
11 |
+
def llama_response(message, history):
|
12 |
+
# Definimos el mensaje del sistema para que el modelo actúe como Ministro de la Corte Suprema de Chile
|
13 |
+
system_message = {
|
14 |
+
"role": "system",
|
15 |
+
"content": (
|
16 |
+
"Asume el rol de Ministro de la Corte Suprema de Chile especializado en Derecho de Familia. Tu propósito es mejorar, "
|
17 |
+
"perfeccionar y llevar al más alto nivel de redacción jurídica el borrador de una resolución judicial, siguiendo principios "
|
18 |
+
"de estilo que aseguren claridad, precisión, concisión y formalidad sin modificar la sustancia, fundamentos ni contenido esencial "
|
19 |
+
"de la decisión. Mantén un tono formal, técnico, imparcial y riguroso, propio de la Corte Suprema. "
|
20 |
+
"Identidad y Propósito: Eres un asistente de IA que opera como un Ministro de la Corte Suprema de Chile, especializado en Derecho "
|
21 |
+
"de Familia. Actúas con la autoridad y formalidad judicial necesarias para revisar y perfeccionar borradores de resoluciones judiciales. "
|
22 |
+
"Cada fase del flujo debe cumplir con los estándares de claridad, precisión, concisión y formalidad del lenguaje judicial chileno sin "
|
23 |
+
"alterar la esencia ni los fundamentos de las decisiones."
|
24 |
+
)
|
25 |
+
}
|
26 |
+
|
27 |
+
# Creamos el mensaje del usuario
|
28 |
+
user_message = {"role": "user", "content": message}
|
29 |
+
|
30 |
+
# Generamos la respuesta usando el cliente
|
31 |
+
completion = client.chat.completions.create(
|
32 |
+
model="meta/llama-3.1-405b-instruct",
|
33 |
+
messages=[system_message, user_message],
|
34 |
+
temperature=0.2,
|
35 |
+
top_p=0.7,
|
36 |
+
max_tokens=1024,
|
37 |
+
stream=False
|
38 |
+
)
|
39 |
+
|
40 |
+
# Procesamos la respuesta y la devolvemos como texto
|
41 |
+
response_text = ""
|
42 |
+
for chunk in completion:
|
43 |
+
if chunk.choices[0].delta.content is not None:
|
44 |
+
response_text += chunk.choices[0].delta.content
|
45 |
+
return response_text
|
46 |
+
|
47 |
+
# Creamos la interfaz con Gradio utilizando ChatInterface
|
48 |
+
description = (
|
49 |
+
"Este Space permite interactuar con el modelo llama3.1-405b actuando como Ministro de la Corte Suprema de Chile especializado en Derecho de Familia. "
|
50 |
+
"El propósito es perfeccionar la redacción de resoluciones judiciales manteniendo los estándares del lenguaje judicial chileno."
|
51 |
+
)
|
52 |
+
interface = gr.ChatInterface(
|
53 |
+
fn=llama_response,
|
54 |
+
type="messages",
|
55 |
+
title="Ministro IA de la Corte Suprema - Derecho de Familia",
|
56 |
+
description=description
|
57 |
+
)
|
58 |
+
|
59 |
+
# Ejecutamos la aplicación
|
60 |
+
interface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
openai
|