Spaces:
Running
Running
Commit ·
6daaf61
1
Parent(s): 55749a1
4.14
Browse files
app.py
CHANGED
|
@@ -335,7 +335,7 @@ def estimate_impact(llm, news_text, entity):
|
|
| 335 |
|
| 336 |
Format your response exactly as:
|
| 337 |
Impact: [category]
|
| 338 |
-
Reasoning: [explanation in 2-3 sentences
|
| 339 |
"""
|
| 340 |
|
| 341 |
prompt = PromptTemplate(template=template, input_variables=["entity", "news"])
|
|
@@ -996,7 +996,8 @@ def process_file(uploaded_file, model_choice, translation_method=None):
|
|
| 996 |
# Process rows
|
| 997 |
total_rows = len(df)
|
| 998 |
processed_rows = 0
|
| 999 |
-
|
|
|
|
| 1000 |
for idx, row in df.iterrows():
|
| 1001 |
if st.session_state.control.is_stopped():
|
| 1002 |
st.warning("Обработку остановили")
|
|
@@ -1064,7 +1065,7 @@ def process_file(uploaded_file, model_choice, translation_method=None):
|
|
| 1064 |
row['Объект']
|
| 1065 |
)
|
| 1066 |
new_row['Impact'] = impact
|
| 1067 |
-
new_row['Reasoning'] = reasoning
|
| 1068 |
except Exception as e:
|
| 1069 |
new_row['Impact'] = "Неопределенный эффект"
|
| 1070 |
new_row['Reasoning'] = "Ошибка анализа"
|
|
@@ -1439,7 +1440,7 @@ def create_output_file(df, uploaded_file):
|
|
| 1439 |
entity_stats['Негативные'] = df[df['Sentiment'] == 'Negative'].groupby('Объект').size().fillna(0).astype(int)
|
| 1440 |
entity_stats['Позитивные'] = df[df['Sentiment'] == 'Positive'].groupby('Объект').size().fillna(0).astype(int)
|
| 1441 |
|
| 1442 |
-
for idx, (entity, row) in enumerate(entity_stats.iterrows()
|
| 1443 |
ws.cell(row=idx, column=5, value=row['Объект'])
|
| 1444 |
ws.cell(row=idx, column=6, value=row['Всего'])
|
| 1445 |
ws.cell(row=idx, column=7, value=row['Негативные'])
|
|
@@ -1503,7 +1504,7 @@ def main():
|
|
| 1503 |
st.set_page_config(layout="wide")
|
| 1504 |
|
| 1505 |
with st.sidebar:
|
| 1506 |
-
st.title("::: AI-анализ мониторинга новостей (v.4.
|
| 1507 |
st.subheader("по материалам СКАН-ИНТЕРФАКС")
|
| 1508 |
|
| 1509 |
model_choice = st.radio(
|
|
|
|
| 335 |
|
| 336 |
Format your response exactly as:
|
| 337 |
Impact: [category]
|
| 338 |
+
Reasoning: [explanation in 2-3 sentences]
|
| 339 |
"""
|
| 340 |
|
| 341 |
prompt = PromptTemplate(template=template, input_variables=["entity", "news"])
|
|
|
|
| 996 |
# Process rows
|
| 997 |
total_rows = len(df)
|
| 998 |
processed_rows = 0
|
| 999 |
+
grlm = init_langchain_llm("Groq (llama-3.1-70b)")
|
| 1000 |
+
|
| 1001 |
for idx, row in df.iterrows():
|
| 1002 |
if st.session_state.control.is_stopped():
|
| 1003 |
st.warning("Обработку остановили")
|
|
|
|
| 1065 |
row['Объект']
|
| 1066 |
)
|
| 1067 |
new_row['Impact'] = impact
|
| 1068 |
+
new_row['Reasoning'] = translate_reasoning_to_russian(grlm, reasoning)
|
| 1069 |
except Exception as e:
|
| 1070 |
new_row['Impact'] = "Неопределенный эффект"
|
| 1071 |
new_row['Reasoning'] = "Ошибка анализа"
|
|
|
|
| 1440 |
entity_stats['Негативные'] = df[df['Sentiment'] == 'Negative'].groupby('Объект').size().fillna(0).astype(int)
|
| 1441 |
entity_stats['Позитивные'] = df[df['Sentiment'] == 'Positive'].groupby('Объект').size().fillna(0).astype(int)
|
| 1442 |
|
| 1443 |
+
for idx, (entity, row) in enumerate(entity_stats.iterrows()):
|
| 1444 |
ws.cell(row=idx, column=5, value=row['Объект'])
|
| 1445 |
ws.cell(row=idx, column=6, value=row['Всего'])
|
| 1446 |
ws.cell(row=idx, column=7, value=row['Негативные'])
|
|
|
|
| 1504 |
st.set_page_config(layout="wide")
|
| 1505 |
|
| 1506 |
with st.sidebar:
|
| 1507 |
+
st.title("::: AI-анализ мониторинга новостей (v.4.14):::")
|
| 1508 |
st.subheader("по материалам СКАН-ИНТЕРФАКС")
|
| 1509 |
|
| 1510 |
model_choice = st.radio(
|