File size: 3,250 Bytes
f74b040
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
---
license: llama3.1
datasets:
- proj-persona/PersonaHub
metrics:
- chrf
tags:
- finance
---
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Gemini</title>
  <script src="ReporteDatoslaboralesNomina.json"></script>
<script>
  // Aquí procesarás los datos del JSON
  fetch('ReporteDatoslaboralesNomina.json')
  .then(response => response.json())
  .then(data => {
    // Hacer algo con los datos, por ejemplo, mostrarlos en un elemento HTML
    document.getElementById('miDiv').textContent = data.mensaje;
  });
</script>
  <style>
/* Estilos generales */
body {
  font-family: Arial, sans-serif;
  line-height: 1.5rem;
  margin: 0;
  padding: 0;
}

/* Contenedor principal */
.contenedor {
  max-width: 600px;
  padding: 30px;
  margin: 0 auto;
}

/* Título */
h1 {
  font-size: 1.5rem;
  margin-bottom: 30px;
  text-align: center;
}

/* Consulta */
#consulta {
  width: 100%;
  height: 200px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
}

/* Botón de consulta */
#botonConsulta {
  display: block;
  margin: 30px auto 0 auto;
  padding: 10px 20px;
  border: 1px solid #000;
  border-radius: 5px;
  background-color: #000;
  color: #fff;
  cursor: pointer;
}

/* Resultados de la consulta */
#resultadoConsulta {
  background-color: #eee;
  padding: 10px;
  margin-top: 30px;
  font-family: monospace;
}

/* Cargando... */
.loading {
  color: #666;
  font-size: 1.2rem;
  text-align: center;
}
  </style>
</head>

<body>
  <div class="contenedor">
    <h1>Formulario de Consulta a GEMINI</h1>
    <div>
      <textarea id="consulta"></textarea>
    </div>
    <button type="button" id="botonConsulta">Consultar</button>
    <pre id="resultadoConsulta"></pre>
  </div>

  <script type="importmap">
    {
      "imports": {
        "@google/generative-ai": "https://esm.run/@google/generative-ai"
      }
    }
  </script>

  <script type="module">
    import { GoogleGenerativeAI } from "@google/generative-ai"
    const clave = "AIzaSyCCrYXob4qnWmqvhjBnF7UUmbKb99rApeQ"  // copiar su clave
    
    const genAI = new GoogleGenerativeAI(clave)
    const model = genAI.getGenerativeModel({ model: "gemini-pro" })

    document.querySelector("#botonConsulta").addEventListener("click", async () => {
      desactivarBoton()
      const consulta = document.querySelector("#consulta").value
      const resultadoConsulta = document.querySelector("#resultadoConsulta")
      try {
        const result = await model.generateContent(consulta)
        const response = await result.response
        const text = response.text()
        resultadoConsulta.innerHTML = text
      } catch (error) {
        resultadoConsulta.innerHTML = 'Problemas en la consulta'
      }
      activarBoton()
    })

    function desactivarBoton() {
      const botonConsulta = document.querySelector("#botonConsulta")
      botonConsulta.disabled = true
      botonConsulta.innerText = "Consultando..."
    }

    function activarBoton() {
      const botonConsulta = document.querySelector("#botonConsulta")
      botonConsulta.disabled = false
      botonConsulta.innerText = "Consultar"
    }
  </script>
</body>

</html>
---
license: llama3.1
---