Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,36 @@
|
|
1 |
|
2 |
-
# Primero, aseg煤rate de tener instalada la librer铆a sentence-splitter
|
3 |
-
# Puedes instalarla usando: pip install sentence-splitter
|
4 |
|
5 |
import subprocess
|
6 |
-
subprocess.run('pip install
|
7 |
-
|
8 |
-
from sentence_splitter import SentenceSplitter, split_text_into_sentences
|
9 |
-
|
10 |
-
# El texto que deseas dividir en oraciones
|
11 |
-
texto = "La Resoluci贸 de l'Alcaldia Presid猫ncia n煤mero 2.442, de 3 d'agost de 2000. La Resoluci贸 de l'Alcaldia Presid猫ncia n煤mero 2.442, de 3 d'agost de 2000."
|
12 |
-
|
13 |
-
# Crear una instancia del divisor de oraciones para el idioma espa帽ol
|
14 |
-
splitter = SentenceSplitter(language='es')
|
15 |
-
|
16 |
-
# Dividir el texto en oraciones
|
17 |
-
oraciones = splitter.split(texto)
|
18 |
-
|
19 |
|
20 |
import streamlit as st
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
|
28 |
|
|
|
1 |
|
|
|
|
|
2 |
|
3 |
import subprocess
|
4 |
+
subprocess.run('pip install transformers --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
import streamlit as st
|
7 |
+
from transformers import pipeline
|
8 |
+
|
9 |
+
# Configurar el modelo
|
10 |
+
pipe = pipeline("text-generation", model="gplsi/Aitana-6.3B")
|
11 |
+
|
12 |
+
# Funci贸n para generar respuesta del modelo
|
13 |
+
def generate_response(input_text):
|
14 |
+
return pipe(input_text, max_length=50, do_sample=True, temperature=0.7)[0]['generated_text']
|
15 |
+
|
16 |
+
# Configuraci贸n de la aplicaci贸n Streamlit
|
17 |
+
def main():
|
18 |
+
st.title("Chat con Aitana")
|
19 |
+
st.write("隆Bienvenido al chat con Aitana! Escribe algo para comenzar la conversaci贸n.")
|
20 |
+
|
21 |
+
# 脕rea de entrada de texto
|
22 |
+
user_input = st.text_area("T煤:")
|
23 |
+
|
24 |
+
# Bot贸n para enviar mensaje
|
25 |
+
if st.button("Enviar"):
|
26 |
+
if user_input.strip() != "":
|
27 |
+
# Generar respuesta
|
28 |
+
response = generate_response(user_input)
|
29 |
+
# Mostrar respuesta
|
30 |
+
st.text_area("Aitana:", value=response, height=200, max_chars=None, key=None)
|
31 |
+
|
32 |
+
if __name__ == "__main__":
|
33 |
+
main()
|
34 |
|
35 |
|
36 |
|