Spaces:
Configuration error
Configuration error
aasherkamal216
commited on
Update groq_models.py
Browse files- groq_models.py +16 -12
groq_models.py
CHANGED
|
@@ -109,19 +109,23 @@ def summarizer_model(model_params, api_key, url):
|
|
| 109 |
temperature=model_params["temperature"],
|
| 110 |
max_tokens=model_params['max_tokens']
|
| 111 |
)
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
|
|
|
|
|
|
| 117 |
|
| 118 |
-
|
| 119 |
|
| 120 |
-
|
| 121 |
-
|
| 122 |
|
| 123 |
-
|
| 124 |
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
| 109 |
temperature=model_params["temperature"],
|
| 110 |
max_tokens=model_params['max_tokens']
|
| 111 |
)
|
| 112 |
+
try:
|
| 113 |
+
if "youtube.com" in url or "youtu.be" in url:
|
| 114 |
+
video_id = YoutubeLoader.extract_video_id(url)
|
| 115 |
+
|
| 116 |
+
loader = YoutubeLoader.from_youtube_url("https://www.youtube.com/watch?v=" + video_id, add_video_info=True)
|
| 117 |
+
else:
|
| 118 |
+
loader = WebBaseLoader(web_path=url)
|
| 119 |
|
| 120 |
+
data = loader.load()
|
| 121 |
|
| 122 |
+
prompt_template = """Provide a summary of the following content in proper markdown:
|
| 123 |
+
Content:\n{text}"""
|
| 124 |
|
| 125 |
+
prompt = PromptTemplate(input_variables=["text"], template=prompt_template)
|
| 126 |
|
| 127 |
+
chain = load_summarize_chain(llm=llm, chain_type="stuff", prompt=prompt)
|
| 128 |
+
output = chain.run(data)
|
| 129 |
+
return output
|
| 130 |
+
except Exception:
|
| 131 |
+
st.error(f"An error occurred:An error occurred: Could not retrieve a transcript for the video", icon="❌")
|