Spaces:
Running
Running
JaphetHernandez
commited on
Commit
•
a3bc7ec
1
Parent(s):
3d477e1
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ import streamlit as st
|
|
3 |
from huggingface_hub import login
|
4 |
import pandas as pd
|
5 |
|
6 |
-
|
7 |
# Token Secret of Hugging Face
|
8 |
huggingface_token = st.secrets["HUGGINGFACEHUB_API_TOKEN"]
|
9 |
login(huggingface_token)
|
@@ -19,14 +18,24 @@ tokenizer.pad_token = tokenizer.eos_token
|
|
19 |
# Upload CSV file
|
20 |
uploaded_file = st.file_uploader("Upload a CSV file", type=["csv"])
|
21 |
|
22 |
-
|
23 |
-
job_titles = df['job_title'].tolist()
|
24 |
-
query="aspiring human resources specialist"
|
25 |
-
|
26 |
if uploaded_file is not None:
|
27 |
df = pd.read_csv(uploaded_file)
|
28 |
-
st.write(df.head())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
|
|
|
|
30 |
st.write("Query:", query)
|
31 |
|
32 |
# Texto de entrada para la generación
|
@@ -46,21 +55,4 @@ input_text = (
|
|
46 |
f"Job Titles: {job_titles}\n"
|
47 |
)
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
# Establecer el id del token de padding
|
52 |
-
pad_token_id = tokenizer.pad_token_id
|
53 |
-
|
54 |
-
# Establecer la generación con máscara de atención
|
55 |
-
outputs = model.generate(
|
56 |
-
inputs['input_ids'],
|
57 |
-
attention_mask=inputs['attention_mask'],
|
58 |
-
max_length=100,
|
59 |
-
pad_token_id=pad_token_id,
|
60 |
-
do_sample=True,
|
61 |
-
temperature=0.7
|
62 |
-
)
|
63 |
-
|
64 |
-
# Decodificar el texto generado
|
65 |
-
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
66 |
-
print(generated_text)
|
|
|
3 |
from huggingface_hub import login
|
4 |
import pandas as pd
|
5 |
|
|
|
6 |
# Token Secret of Hugging Face
|
7 |
huggingface_token = st.secrets["HUGGINGFACEHUB_API_TOKEN"]
|
8 |
login(huggingface_token)
|
|
|
18 |
# Upload CSV file
|
19 |
uploaded_file = st.file_uploader("Upload a CSV file", type=["csv"])
|
20 |
|
21 |
+
# Leer el archivo CSV si se ha subido
|
|
|
|
|
|
|
22 |
if uploaded_file is not None:
|
23 |
df = pd.read_csv(uploaded_file)
|
24 |
+
st.write(df.head()) # Mostrar las primeras filas del dataframe
|
25 |
+
|
26 |
+
# Verificar si la columna 'job_title' está en el dataframe
|
27 |
+
if 'job_title' in df.columns:
|
28 |
+
job_titles = df['job_title'].tolist()
|
29 |
+
else:
|
30 |
+
st.error("La columna 'job_title' no se encuentra en el archivo CSV.")
|
31 |
+
job_titles = [] # Asignar una lista vacía si la columna no existe
|
32 |
+
|
33 |
+
else:
|
34 |
+
st.warning("Por favor, sube un archivo CSV.")
|
35 |
+
job_titles = [] # Asignar una lista vacía si no se ha subido un archivo
|
36 |
|
37 |
+
# Definir la consulta
|
38 |
+
query = "aspiring human resources specialist"
|
39 |
st.write("Query:", query)
|
40 |
|
41 |
# Texto de entrada para la generación
|
|
|
55 |
f"Job Titles: {job_titles}\n"
|
56 |
)
|
57 |
|
58 |
+
st.write("Texto de entrada para la generación:", input_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|