Spaces:
Running
Running
Commit ·
367d42f
1
Parent(s): 1e0ed97
progress more 61
Browse files
app.py
CHANGED
|
@@ -18,6 +18,7 @@ import transformers
|
|
| 18 |
from langchain_community.llms import HuggingFacePipeline
|
| 19 |
from langchain.prompts import PromptTemplate
|
| 20 |
from langchain.chains import LLMChain
|
|
|
|
| 21 |
from huggingface_hub import login
|
| 22 |
from accelerate import init_empty_weights
|
| 23 |
import logging
|
|
@@ -54,7 +55,7 @@ def batch_translate(texts, batch_size=32):
|
|
| 54 |
# Update progress
|
| 55 |
progress = (i + len(batch)) / len(texts)
|
| 56 |
st.progress(progress)
|
| 57 |
-
st.text(f"П
|
| 58 |
|
| 59 |
return translated_texts
|
| 60 |
|
|
@@ -147,14 +148,14 @@ def estimate_impact(llm, news_text, entity):
|
|
| 147 |
Reasoning: [Your reasoning]
|
| 148 |
"""
|
| 149 |
prompt = PromptTemplate(template=template, input_variables=["entity", "news"])
|
| 150 |
-
chain =
|
| 151 |
-
response = chain.
|
| 152 |
|
| 153 |
# Parse the response
|
| 154 |
impact = "Неопределенный эффект"
|
| 155 |
reasoning = "Не удалось получить обоснование"
|
| 156 |
|
| 157 |
-
if "Estimated Impact:" in response and "Reasoning:" in response:
|
| 158 |
impact_part, reasoning_part = response.split("Reasoning:")
|
| 159 |
impact = impact_part.split("Estimated Impact:")[1].strip()
|
| 160 |
reasoning = reasoning_part.strip()
|
|
@@ -504,7 +505,7 @@ def create_output_file(df, uploaded_file, analysis_df):
|
|
| 504 |
return output
|
| 505 |
|
| 506 |
def main():
|
| 507 |
-
st.title("... приступим к анализу... версия
|
| 508 |
|
| 509 |
# Initialize session state
|
| 510 |
if 'processed_df' not in st.session_state:
|
|
|
|
| 18 |
from langchain_community.llms import HuggingFacePipeline
|
| 19 |
from langchain.prompts import PromptTemplate
|
| 20 |
from langchain.chains import LLMChain
|
| 21 |
+
from langchain_core.runnables import RunnablePassthrough
|
| 22 |
from huggingface_hub import login
|
| 23 |
from accelerate import init_empty_weights
|
| 24 |
import logging
|
|
|
|
| 55 |
# Update progress
|
| 56 |
progress = (i + len(batch)) / len(texts)
|
| 57 |
st.progress(progress)
|
| 58 |
+
st.text(f"Предобработано {i + len(batch)} из {len(texts)} текстов")
|
| 59 |
|
| 60 |
return translated_texts
|
| 61 |
|
|
|
|
| 148 |
Reasoning: [Your reasoning]
|
| 149 |
"""
|
| 150 |
prompt = PromptTemplate(template=template, input_variables=["entity", "news"])
|
| 151 |
+
chain = prompt | llm | RunnablePassthrough()
|
| 152 |
+
response = chain.invoke({"entity": entity, "news": news_text})
|
| 153 |
|
| 154 |
# Parse the response
|
| 155 |
impact = "Неопределенный эффект"
|
| 156 |
reasoning = "Не удалось получить обоснование"
|
| 157 |
|
| 158 |
+
if isinstance(response, str) and "Estimated Impact:" in response and "Reasoning:" in response:
|
| 159 |
impact_part, reasoning_part = response.split("Reasoning:")
|
| 160 |
impact = impact_part.split("Estimated Impact:")[1].strip()
|
| 161 |
reasoning = reasoning_part.strip()
|
|
|
|
| 505 |
return output
|
| 506 |
|
| 507 |
def main():
|
| 508 |
+
st.title("... приступим к анализу... версия 61")
|
| 509 |
|
| 510 |
# Initialize session state
|
| 511 |
if 'processed_df' not in st.session_state:
|