PD03 commited on
Commit
daedd19
·
verified ·
1 Parent(s): 8353d84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -4,19 +4,19 @@ from transformers import pipeline
4
  from langchain_community.llms import HuggingFacePipeline
5
  from langchain_experimental.agents import create_pandas_dataframe_agent
6
 
7
- # Load your data
8
  df = pd.read_csv("synthetic_profit.csv")
9
 
10
- # Setup lightweight Hugging Face pipeline with Flan-T5 base
11
  hf_pipeline = pipeline(
12
  task="text2text-generation",
13
  model="google/flan-t5-base",
14
- device=-1 # CPU only
15
  )
16
 
17
- # LangChain agent setup
18
  llm = HuggingFacePipeline(pipeline=hf_pipeline)
19
- agent = create_pandas_dataframe_agent(llm, df, verbose=True)
20
 
21
  def answer(query: str) -> str:
22
  try:
 
4
  from langchain_community.llms import HuggingFacePipeline
5
  from langchain_experimental.agents import create_pandas_dataframe_agent
6
 
7
+ # Load data
8
  df = pd.read_csv("synthetic_profit.csv")
9
 
10
+ # Set up lightweight Hugging Face pipeline (Flan-T5 Base)
11
  hf_pipeline = pipeline(
12
  task="text2text-generation",
13
  model="google/flan-t5-base",
14
+ device=-1 # CPU
15
  )
16
 
17
+ # LangChain agent setup (with explicit security opt-in)
18
  llm = HuggingFacePipeline(pipeline=hf_pipeline)
19
+ agent = create_pandas_dataframe_agent(llm, df, verbose=True, allow_dangerous_code=True)
20
 
21
  def answer(query: str) -> str:
22
  try: