-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatualização do vue
133 lines (119 loc) · 2.8 KB
/
atualização do vue
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
<template>
<div id="a">
<input type="text" v-model="form.meuInput" cols="30" rows="10">
<input type="button" value="Enviar" @click="run">
<div v-html="form.resposta"></div>
<!-- <textarea v-model="form.resposta" cols="30" rows="10"></textarea> -->
</div>
</template>
<script>
import { GoogleGenerativeAI } from "@google/generative-ai";
export default {
name: 'HelloWorld',
data() {
return {
form: {
meuInput: "",
resposta: ""
},
genAI: null,
model: null,
generationConfig: {
temperature: 1,
topP: 0.95,
topK: 64,
maxOutputTokens: 8192,
responseMimeType: "text/plain",
}
};
},
methods: {
async run() {
const apiKey = "AIzaSyA2IguhcKunUYQToJRvahkhLqrIU2X1Kig";
this.genAI = new GoogleGenerativeAI(apiKey);
this.model = this.genAI.getGenerativeModel({model: "gemini-1.5-flash"});
const chatSession = this.model.startChat({
generationConfig: this.generationConfig,
history: [
{ role: "user", parts: [{ text: "hi" }] },
{ role: "model", parts: [{ text: "hi \n" }] }
]
});
const result = await chatSession.sendMessage(this.form.meuInput);
this.form.resposta = result.response.text();
console.log(result.response.text());
}
}
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
/* styles.css */
/* styles.css */
#a {
font-family: Arial, sans-serif;
margin: 0;
/* Removendo margem padrão */
padding: 20px;
/* Adicionando preenchimento */
align-items: center;
/* Centraliza verticalmente */
min-height: 100vh;
/* Garante que a página ocupe toda a altura da viewport */
background-color: #f0f0f0;
}
div {
width: 100%;
padding: 10px;
margin-bottom: 10px;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 4px;
resize: vertical;
}
input[type="text"] {
padding: 10px 20px;
border: none;
border-radius: 25px;
cursor: pointer;
font-size: 16px;
font-weight: bold;
text-transform: uppercase;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
transition: background-color 0.3s, transform 0.2s ease-out;
}
input[type="button"] {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 25px;
cursor: pointer;
font-size: 16px;
font-weight: bold;
text-transform: uppercase;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
transition: background-color 0.3s, transform 0.2s ease-out;
}
input[type="button"]:hover {
background-color: #ff008c;
transform: scale(1.5);
}
input[type="button"]:active {
transform: scale(0.5);
}
</style>