Spaces:
Runtime error
Runtime error
AlbertoFH98
commited on
Commit
·
24bbdf7
1
Parent(s):
66216e0
Update app.py
Browse files
app.py
CHANGED
@@ -15,11 +15,10 @@ import spacy
|
|
15 |
import time
|
16 |
import os
|
17 |
import re
|
|
|
18 |
|
19 |
@st.cache
|
20 |
def get_args():
|
21 |
-
st.set_page_config(layout="wide")
|
22 |
-
|
23 |
# -- 1. Setup arguments
|
24 |
parser = argparse.ArgumentParser()
|
25 |
parser.add_argument('--DEFAULT_SYSTEM_PROMPT_LINK', type=str, default="https://raw.githubusercontent.com/AlbertoUAH/Castena/main/prompts/default_system_prompt.txt", help='Valor para DEFAULT_SYSTEM_PROMPT_LINK')
|
@@ -43,25 +42,12 @@ def get_podcast_data(transcription_path):
|
|
43 |
together.Models.start(MODEL)
|
44 |
podcast_url_video_df = pd.read_csv(PODCAST_URL_VIDEO_PATH, sep=';')
|
45 |
return podcast_url_video_df
|
46 |
-
|
47 |
-
def main():
|
48 |
-
args = get_args()
|
49 |
-
B_INST, E_INST = "[INST]", "[/INST]"
|
50 |
-
B_SYS, E_SYS = "<<SYS>>\n", "\n<</SYS>>\n\n"
|
51 |
-
|
52 |
-
# -- 4. Get parameters
|
53 |
-
PODCAST_URL_VIDEO_PATH = args.PODCAST_URL_VIDEO_PATH
|
54 |
-
DEFAULT_SYSTEM_PROMPT_LINK = args.DEFAULT_SYSTEM_PROMPT_LINK
|
55 |
-
TRANSCRIPTION = args.TRANSCRIPTION
|
56 |
-
TRANSCRIPTION_PATH = '{}_transcription.txt'.format(TRANSCRIPTION)
|
57 |
-
MODEL = args.MODEL
|
58 |
-
EMB_MODEL = args.EMB_MODEL
|
59 |
-
|
60 |
-
podcast_url_video_df = get_podcast_data(TRANSCRIPTION_PATH)
|
61 |
|
62 |
-
|
|
|
|
|
63 |
icon = Image.open(r.raw)
|
64 |
-
icon = icon.resize((
|
65 |
st.sidebar.image(icon)
|
66 |
video_option = st.sidebar.selectbox(
|
67 |
"Seleccione el podcast",
|
@@ -72,11 +58,30 @@ def main():
|
|
72 |
youtube_video_url = list(podcast_url_video_df[podcast_url_video_df['podcast_name'].str.contains(video_option_joined)]['youtube_video_url'])[0].replace("\'", "")
|
73 |
|
74 |
# -- 4. Setup request for system prompt
|
75 |
-
f = urllib.request.urlopen(
|
76 |
DEFAULT_SYSTEM_PROMPT = str(f.read(), 'UTF-8')
|
77 |
|
78 |
# -- 5. Setup app
|
79 |
-
translator, nlp, retriever = utils.setup_app(video_option_joined_path,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
|
82 |
# -- 6. Setup prompt template + llm chain
|
|
|
15 |
import time
|
16 |
import os
|
17 |
import re
|
18 |
+
st.set_page_config(layout="wide")
|
19 |
|
20 |
@st.cache
|
21 |
def get_args():
|
|
|
|
|
22 |
# -- 1. Setup arguments
|
23 |
parser = argparse.ArgumentParser()
|
24 |
parser.add_argument('--DEFAULT_SYSTEM_PROMPT_LINK', type=str, default="https://raw.githubusercontent.com/AlbertoUAH/Castena/main/prompts/default_system_prompt.txt", help='Valor para DEFAULT_SYSTEM_PROMPT_LINK')
|
|
|
42 |
together.Models.start(MODEL)
|
43 |
podcast_url_video_df = pd.read_csv(PODCAST_URL_VIDEO_PATH, sep=';')
|
44 |
return podcast_url_video_df
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
+
@st.cache
|
47 |
+
def setup_basics_comp(emb_model, model, default_system_prompt_link, logger, podcast_url_video_df, img_size=100):
|
48 |
+
r = requests.get("https://raw.githubusercontent.com/AlbertoUAH/Castena/main/media/castena-animated-icon.gif", stream=True)
|
49 |
icon = Image.open(r.raw)
|
50 |
+
icon = icon.resize((img_size, img_size))
|
51 |
st.sidebar.image(icon)
|
52 |
video_option = st.sidebar.selectbox(
|
53 |
"Seleccione el podcast",
|
|
|
58 |
youtube_video_url = list(podcast_url_video_df[podcast_url_video_df['podcast_name'].str.contains(video_option_joined)]['youtube_video_url'])[0].replace("\'", "")
|
59 |
|
60 |
# -- 4. Setup request for system prompt
|
61 |
+
f = urllib.request.urlopen(default_system_prompt_link)
|
62 |
DEFAULT_SYSTEM_PROMPT = str(f.read(), 'UTF-8')
|
63 |
|
64 |
# -- 5. Setup app
|
65 |
+
translator, nlp, retriever = utils.setup_app(video_option_joined_path, emb_model, model, logger)
|
66 |
+
return translator, nlp, retriever, video_option, video_option_joined_path
|
67 |
+
|
68 |
+
def main():
|
69 |
+
args = get_args()
|
70 |
+
B_INST, E_INST = "[INST]", "[/INST]"
|
71 |
+
B_SYS, E_SYS = "<<SYS>>\n", "\n<</SYS>>\n\n"
|
72 |
+
|
73 |
+
PODCAST_URL_VIDEO_PATH = args.PODCAST_URL_VIDEO_PATH
|
74 |
+
DEFAULT_SYSTEM_PROMPT_LINK = args.DEFAULT_SYSTEM_PROMPT_LINK
|
75 |
+
TRANSCRIPTION = args.TRANSCRIPTION
|
76 |
+
TRANSCRIPTION_PATH = '{}_transcription.txt'.format(TRANSCRIPTION)
|
77 |
+
MODEL = args.MODEL
|
78 |
+
EMB_MODEL = args.EMB_MODEL
|
79 |
+
|
80 |
+
podcast_url_video_df = get_podcast_data(TRANSCRIPTION_PATH)
|
81 |
+
|
82 |
+
translator, nlp, retriever, video_option, video_option_joined_path = setup_basics_comp(EMB_MODEL, MODEL,
|
83 |
+
DEFAULT_SYSTEM_PROMPT_LINK, logger,
|
84 |
+
podcast_url_video_df, img_size=100)
|
85 |
|
86 |
|
87 |
# -- 6. Setup prompt template + llm chain
|