Spaces:
Running
Running
app.py
CHANGED
|
@@ -3,10 +3,10 @@ import asyncio
|
|
| 3 |
import google.generativeai as genai
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
-
# Configuración de
|
| 7 |
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
|
| 8 |
if not GEMINI_API_KEY:
|
| 9 |
-
raise ValueError("La clave
|
| 10 |
genai.configure(api_key=GEMINI_API_KEY)
|
| 11 |
|
| 12 |
# Instrucciones del sistema por defecto
|
|
@@ -16,9 +16,29 @@ Como Ministro de la Corte Suprema de Chile, especializado en Derecho de Familia,
|
|
| 16 |
El objetivo es elevar el texto a un estándar de excelencia en redacción jurídica, asegurando la máxima claridad, precisión, concisión y formalidad. **No debes modificar la estructura del borrador, tampoco agregar fundamentación o hechos. La mejora solo es gramatical, redaccional y estética lingüística jurídica.**
|
| 17 |
"""
|
| 18 |
|
| 19 |
-
# Configuración
|
| 20 |
-
google_gemini_model = genai.GenerativeModel(
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
async def generate_content(client, model_name, system_instruction, borrador):
|
| 24 |
try:
|
|
@@ -53,4 +73,4 @@ with gr.Blocks() as demo:
|
|
| 53 |
submit_btn.click(fn=predict, inputs=borrador, outputs=output)
|
| 54 |
|
| 55 |
if __name__ == "__main__":
|
| 56 |
-
demo.launch()
|
|
|
|
| 3 |
import google.generativeai as genai
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
+
# Configuración de la clave de API
|
| 7 |
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
|
| 8 |
if not GEMINI_API_KEY:
|
| 9 |
+
raise ValueError("La clave GEMINI_API_KEY no está configurada correctamente.")
|
| 10 |
genai.configure(api_key=GEMINI_API_KEY)
|
| 11 |
|
| 12 |
# Instrucciones del sistema por defecto
|
|
|
|
| 16 |
El objetivo es elevar el texto a un estándar de excelencia en redacción jurídica, asegurando la máxima claridad, precisión, concisión y formalidad. **No debes modificar la estructura del borrador, tampoco agregar fundamentación o hechos. La mejora solo es gramatical, redaccional y estética lingüística jurídica.**
|
| 17 |
"""
|
| 18 |
|
| 19 |
+
# Configuración del modelo de Google Gemini
|
| 20 |
+
google_gemini_model = genai.GenerativeModel(
|
| 21 |
+
"gemini-exp-1121",
|
| 22 |
+
generation_config={
|
| 23 |
+
"temperature": 0.5,
|
| 24 |
+
"top_p": 0.9,
|
| 25 |
+
"top_k": 40,
|
| 26 |
+
"max_output_tokens": 5000,
|
| 27 |
+
"response_mime_type": "text/plain",
|
| 28 |
+
},
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
# Configuración del modelo de Google LearnLM
|
| 32 |
+
google_learnlm_model = genai.GenerativeModel(
|
| 33 |
+
"learnlm-1.5-pro-experimental",
|
| 34 |
+
generation_config={
|
| 35 |
+
"temperature": 0.5,
|
| 36 |
+
"top_p": 0.9,
|
| 37 |
+
"top_k": 40,
|
| 38 |
+
"max_output_tokens": 5000,
|
| 39 |
+
"response_mime_type": "text/plain",
|
| 40 |
+
},
|
| 41 |
+
)
|
| 42 |
|
| 43 |
async def generate_content(client, model_name, system_instruction, borrador):
|
| 44 |
try:
|
|
|
|
| 73 |
submit_btn.click(fn=predict, inputs=borrador, outputs=output)
|
| 74 |
|
| 75 |
if __name__ == "__main__":
|
| 76 |
+
demo.queue(concurrency_count=2, max_size=10).launch(timeout_seconds=3600)
|