feat: Version in api
This commit is contained in:
parent
811a7e9213
commit
aaad0dc7c2
16
main.py
16
main.py
|
@ -23,7 +23,8 @@ from unidecode import unidecode
|
||||||
from nltk.corpus import stopwords
|
from nltk.corpus import stopwords
|
||||||
#from cleantext import clean
|
#from cleantext import clean
|
||||||
import re
|
import re
|
||||||
|
model="embeddings/all-mpnet-base-v2"
|
||||||
|
entrenamiento="V0.0"
|
||||||
class CustomEmbedding(Embeddings, BaseModel,):
|
class CustomEmbedding(Embeddings, BaseModel,):
|
||||||
"""embedding model with preprocessing"""
|
"""embedding model with preprocessing"""
|
||||||
def _get_embedding(self,text) -> List[float]:
|
def _get_embedding(self,text) -> List[float]:
|
||||||
|
@ -123,7 +124,7 @@ def makeFaissdb(documents,folder_path,embedding):
|
||||||
return db
|
return db
|
||||||
|
|
||||||
#llm,emb=loadModels()
|
#llm,emb=loadModels()
|
||||||
model="embeddings/all-mpnet-base-v2"
|
|
||||||
documents,documents2=loadCopysAndData()
|
documents,documents2=loadCopysAndData()
|
||||||
emb=loadmodelEmb(model_name = model)
|
emb=loadmodelEmb(model_name = model)
|
||||||
emb2=CustomEmbedding()
|
emb2=CustomEmbedding()
|
||||||
|
@ -160,7 +161,7 @@ def FinderDbs(query,dbs,filtred=False,th=1.2):
|
||||||
def QARequest(Pregunta,filtred=False):
|
def QARequest(Pregunta,filtred=False):
|
||||||
query = Pregunta
|
query = Pregunta
|
||||||
AllData=FinderDbs(query,[db2],filtred)
|
AllData=FinderDbs(query,[db2],filtred)
|
||||||
|
versionL="_".join([model,entrenamiento])
|
||||||
if AllData:
|
if AllData:
|
||||||
import markdown
|
import markdown
|
||||||
AllData = list(AllData)
|
AllData = list(AllData)
|
||||||
|
@ -180,8 +181,9 @@ def QARequest(Pregunta,filtred=False):
|
||||||
#lista = lista + '</div>'
|
#lista = lista + '</div>'
|
||||||
|
|
||||||
AllData[0] = lista
|
AllData[0] = lista
|
||||||
|
|
||||||
|
|
||||||
return id, dis
|
return id, dis,versionL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,8 +200,8 @@ with gr.Blocks() as demo:
|
||||||
Respuesta = gr.Textbox(label="Respuesta")
|
Respuesta = gr.Textbox(label="Respuesta")
|
||||||
id = gr.Textbox(label="id")
|
id = gr.Textbox(label="id")
|
||||||
metrica=gr.Textbox(label="metrica")
|
metrica=gr.Textbox(label="metrica")
|
||||||
# gr.Markdown("Respuestas para orca desde los names")
|
|
||||||
# Respuesta2 = gr.Textbox(label="Respuesta2")
|
version = gr.Textbox(label="version")
|
||||||
# id2 = gr.Textbox(label="id2")
|
# id2 = gr.Textbox(label="id2")
|
||||||
# metrica2=gr.Textbox(label="metrica2")
|
# metrica2=gr.Textbox(label="metrica2")
|
||||||
# gr.Markdown("Respuestas para hf desde los names")
|
# gr.Markdown("Respuestas para hf desde los names")
|
||||||
|
@ -208,7 +210,7 @@ with gr.Blocks() as demo:
|
||||||
# metrica3=gr.Textbox(label="metrica3")
|
# metrica3=gr.Textbox(label="metrica3")
|
||||||
Enviar_btn = gr.Button("Responder")
|
Enviar_btn = gr.Button("Responder")
|
||||||
|
|
||||||
Enviar_btn.click(fn=QARequest, inputs=[Pregunta,filtred], outputs=[id,metrica], api_name="api_angela") #
|
Enviar_btn.click(fn=QARequest, inputs=[Pregunta,filtred], outputs=[id,metrica,version], api_name="api_angela") #
|
||||||
|
|
||||||
#demo.launch(root_path="angela") #
|
#demo.launch(root_path="angela") #
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue