JaphetHernandez commited on
Commit
9e12e9c
verified
1 Parent(s): 7e97ebd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -6,6 +6,7 @@ from transformers import LlamaForCausalLM, AutoTokenizer
6
  from huggingface_hub import login
7
  import streamlit as st
8
  import sys
 
9
 
10
  # Inicializaci贸n de Hugging Face con el token de la API desde los secretos de Streamlit
11
  huggingface_token = st.secrets["SECRET"]
@@ -38,7 +39,7 @@ if uploaded_file:
38
  input_variables=["query", "texto"],
39
  template=(
40
  "Calcular el cosine similarity score entre '{query}' y '{texto}'. "
41
- "Responde con el score como un valor num茅rico entre 0 y 1."
42
  )
43
  )
44
 
@@ -51,7 +52,7 @@ if uploaded_file:
51
  resultado = chain.run(prompt)
52
 
53
  # Usar expresiones regulares para extraer el puntaje de similitud
54
- match = re.search(r"(\d+\.\d+)", resultado)
55
  if match:
56
  score = float(match.group(1))
57
  return score
@@ -69,7 +70,6 @@ else:
69
 
70
 
71
 
72
-
73
  '''
74
  import pandas as pd
75
  from langchain.chains import LLMChain
 
6
  from huggingface_hub import login
7
  import streamlit as st
8
  import sys
9
+ import re
10
 
11
  # Inicializaci贸n de Hugging Face con el token de la API desde los secretos de Streamlit
12
  huggingface_token = st.secrets["SECRET"]
 
39
  input_variables=["query", "texto"],
40
  template=(
41
  "Calcular el cosine similarity score entre '{query}' y '{texto}'. "
42
+ "Responde solo con un n煤mero entre 0 y 1, sin texto adicional."
43
  )
44
  )
45
 
 
52
  resultado = chain.run(prompt)
53
 
54
  # Usar expresiones regulares para extraer el puntaje de similitud
55
+ match = re.search(r"\b(0\.\d+|1\.0)\b", resultado) # Solo n煤meros entre 0.0 y 1.0
56
  if match:
57
  score = float(match.group(1))
58
  return score
 
70
 
71
 
72
 
 
73
  '''
74
  import pandas as pd
75
  from langchain.chains import LLMChain