Spaces:
Running
Running
Commit
·
2541d3c
1
Parent(s):
e3ebc5a
progress more (3.13)
Browse files
app.py
CHANGED
@@ -153,21 +153,49 @@ def fuzzy_deduplicate(df, column, threshold=65):
|
|
153 |
|
154 |
def init_langchain_llm():
|
155 |
try:
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
st.stop()
|
161 |
-
|
162 |
-
llm = ChatOpenAI(
|
163 |
-
base_url="https://api.groq.com/openai/v1",
|
164 |
-
model="llama-3.1-70b-versatile",
|
165 |
-
openai_api_key=groq_api_key, # Updated parameter name
|
166 |
-
temperature=0.0
|
167 |
)
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
except Exception as e:
|
170 |
-
st.error(f"Error initializing the
|
171 |
st.stop()
|
172 |
|
173 |
def estimate_impact(llm, news_text, entity):
|
@@ -434,9 +462,8 @@ def create_output_file(df, uploaded_file, llm):
|
|
434 |
return output
|
435 |
|
436 |
def main():
|
437 |
-
|
438 |
with st.sidebar:
|
439 |
-
st.title("::: AI-анализ мониторинга новостей (v.3.
|
440 |
st.subheader("по материалам СКАН-ИНТЕРФАКС ")
|
441 |
st.markdown(
|
442 |
"""
|
@@ -447,13 +474,16 @@ def main():
|
|
447 |
""",
|
448 |
unsafe_allow_html=True)
|
449 |
|
450 |
-
|
451 |
with st.expander("ℹ️ Инструкция"):
|
452 |
st.markdown("""
|
453 |
-
1.
|
454 |
-
2.
|
455 |
-
3.
|
|
|
456 |
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
457 |
|
458 |
st.markdown(
|
459 |
"""
|
|
|
153 |
|
154 |
def init_langchain_llm():
|
155 |
try:
|
156 |
+
# Get model selection from sidebar
|
157 |
+
model_choice = st.sidebar.radio(
|
158 |
+
"Выберите модель для анализа:",
|
159 |
+
["Groq (llama-3.1-70b)", "ChatGPT-4-mini", "NVIDIA Nemotron-70B"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
)
|
161 |
+
|
162 |
+
if model_choice == "Groq (llama-3.1-70b)":
|
163 |
+
if 'groq_key' not in st.secrets:
|
164 |
+
st.error("Groq API key not found in secrets. Please add it with the key 'groq_key'.")
|
165 |
+
st.stop()
|
166 |
+
|
167 |
+
return ChatOpenAI(
|
168 |
+
base_url="https://api.groq.com/openai/v1",
|
169 |
+
model="llama-3.1-70b-versatile",
|
170 |
+
openai_api_key=st.secrets['groq_key'],
|
171 |
+
temperature=0.0
|
172 |
+
)
|
173 |
+
|
174 |
+
elif model_choice == "ChatGPT-4-mini":
|
175 |
+
if 'groq_key' not in st.secrets:
|
176 |
+
st.error("OpenAI API key not found in secrets. Please add it with the key 'groq_key'.")
|
177 |
+
st.stop()
|
178 |
+
|
179 |
+
return ChatOpenAI(
|
180 |
+
model="gpt-4o",
|
181 |
+
openai_api_key=st.secrets['groq_key'],
|
182 |
+
temperature=0.0
|
183 |
+
)
|
184 |
+
|
185 |
+
else: # NVIDIA Nemotron-70B
|
186 |
+
if 'nvapi' not in st.secrets:
|
187 |
+
st.error("NVIDIA API key not found in secrets. Please add it with the key 'nvapi'.")
|
188 |
+
st.stop()
|
189 |
+
|
190 |
+
return ChatOpenAI(
|
191 |
+
base_url="https://integrate.api.nvidia.com/v1",
|
192 |
+
model="nvidia/llama-3.1-nemotron-70b-instruct",
|
193 |
+
openai_api_key=st.secrets['nvapi'],
|
194 |
+
temperature=0.0
|
195 |
+
)
|
196 |
+
|
197 |
except Exception as e:
|
198 |
+
st.error(f"Error initializing the LLM: {str(e)}")
|
199 |
st.stop()
|
200 |
|
201 |
def estimate_impact(llm, news_text, entity):
|
|
|
462 |
return output
|
463 |
|
464 |
def main():
|
|
|
465 |
with st.sidebar:
|
466 |
+
st.title("::: AI-анализ мониторинга новостей (v.3.13):::")
|
467 |
st.subheader("по материалам СКАН-ИНТЕРФАКС ")
|
468 |
st.markdown(
|
469 |
"""
|
|
|
474 |
""",
|
475 |
unsafe_allow_html=True)
|
476 |
|
|
|
477 |
with st.expander("ℹ️ Инструкция"):
|
478 |
st.markdown("""
|
479 |
+
1. Выберите модель для анализа
|
480 |
+
2. Загрузите Excel файл с новостями <br/>
|
481 |
+
3. Дождитесь завершения анализа <br/>
|
482 |
+
4. Скачайте результаты анализа в формате Excel <br/>
|
483 |
""", unsafe_allow_html=True)
|
484 |
+
|
485 |
+
uploaded_file = st.file_uploader("Выбирайте Excel-файл", type="xlsx")
|
486 |
+
|
487 |
|
488 |
st.markdown(
|
489 |
"""
|