Spaces:
Runtime error
Runtime error
AlbertoFH98
commited on
Commit
·
39e3dea
1
Parent(s):
120298c
Update utils.py
Browse files
utils.py
CHANGED
@@ -13,7 +13,6 @@ from langchain.text_splitter import RecursiveCharacterTextSplitter
|
|
13 |
from langchain.chains import RetrievalQA
|
14 |
from langchain.document_loaders import TextLoader
|
15 |
from langchain.embeddings import HuggingFaceEmbeddings, OpenAIEmbeddings
|
16 |
-
from googletrans import Translator
|
17 |
import streamlit as st
|
18 |
import together
|
19 |
import textwrap
|
@@ -147,11 +146,10 @@ def get_gpt_response(query):
|
|
147 |
)
|
148 |
return rag_chain.invoke(query)
|
149 |
|
150 |
-
# -- Python function to setup basic features:
|
151 |
@st.cache_resource
|
152 |
def setup_app(transcription_path, emb_model, model, _logger):
|
153 |
# -- Setup enviroment and features
|
154 |
-
translator = Translator(service_urls=['translate.googleapis.com'])
|
155 |
nlp = spacy.load('es_core_news_lg')
|
156 |
|
157 |
_logger.info('Setup environment and features...')
|
@@ -199,7 +197,7 @@ def setup_app(transcription_path, emb_model, model, _logger):
|
|
199 |
retriever = vectordb.as_retriever(search_kwargs={"k": 5})
|
200 |
_logger.info('Creating document database - FINISHED!')
|
201 |
_logger.info('Setup finished!')
|
202 |
-
return
|
203 |
|
204 |
# -- Function to get prompt template
|
205 |
def get_prompt(instruction, system_prompt, b_sys, e_sys, b_inst, e_inst, _logger):
|
|
|
13 |
from langchain.chains import RetrievalQA
|
14 |
from langchain.document_loaders import TextLoader
|
15 |
from langchain.embeddings import HuggingFaceEmbeddings, OpenAIEmbeddings
|
|
|
16 |
import streamlit as st
|
17 |
import together
|
18 |
import textwrap
|
|
|
146 |
)
|
147 |
return rag_chain.invoke(query)
|
148 |
|
149 |
+
# -- Python function to setup basic features: SpaCy pipeline and LLM model
|
150 |
@st.cache_resource
|
151 |
def setup_app(transcription_path, emb_model, model, _logger):
|
152 |
# -- Setup enviroment and features
|
|
|
153 |
nlp = spacy.load('es_core_news_lg')
|
154 |
|
155 |
_logger.info('Setup environment and features...')
|
|
|
197 |
retriever = vectordb.as_retriever(search_kwargs={"k": 5})
|
198 |
_logger.info('Creating document database - FINISHED!')
|
199 |
_logger.info('Setup finished!')
|
200 |
+
return nlp, retriever
|
201 |
|
202 |
# -- Function to get prompt template
|
203 |
def get_prompt(instruction, system_prompt, b_sys, e_sys, b_inst, e_inst, _logger):
|