Jeremy Live commited on
Commit
c26cd3f
·
1 Parent(s): f44bd60
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -4,6 +4,7 @@ import sys
4
  import re
5
  import traceback
6
  import subprocess
 
7
  import gradio as gr
8
  import pandas as pd
9
  from dotenv import load_dotenv
@@ -11,6 +12,9 @@ from crewai import Crew, Agent, Task, Process, LLM
11
  from crewai_tools import FileReadTool
12
  from pydantic import BaseModel, Field
13
 
 
 
 
14
  # Load environment variables
15
  load_dotenv()
16
 
@@ -175,6 +179,21 @@ def run_crewai_process(user_query, model, temperature):
175
  with open(temp_script_path, "w") as f:
176
  f.write(generated_code)
177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  # Execute the temporary script using subprocess
179
  # Use python3 to ensure correct interpreter in Colab
180
  process = subprocess.run(
 
4
  import re
5
  import traceback
6
  import subprocess
7
+ import warnings
8
  import gradio as gr
9
  import pandas as pd
10
  from dotenv import load_dotenv
 
12
  from crewai_tools import FileReadTool
13
  from pydantic import BaseModel, Field
14
 
15
+ # Filter out specific warnings
16
+ warnings.filterwarnings('ignore', category=FutureWarning, module='yfinance.*')
17
+
18
  # Load environment variables
19
  load_dotenv()
20
 
 
179
  with open(temp_script_path, "w") as f:
180
  f.write(generated_code)
181
 
182
+ # Add auto_adjust=True to yf.download() calls in the generated script
183
+ with open(temp_script_path, 'r') as f:
184
+ script_content = f.read()
185
+
186
+ # Update yf.download() calls to include auto_adjust=True
187
+ script_content = re.sub(
188
+ r'yf\.download\(([^)]+)\)',
189
+ r'yf.download(\1, auto_adjust=True)',
190
+ script_content
191
+ )
192
+
193
+ # Write the updated script back
194
+ with open(temp_script_path, 'w') as f:
195
+ f.write(script_content)
196
+
197
  # Execute the temporary script using subprocess
198
  # Use python3 to ensure correct interpreter in Colab
199
  process = subprocess.run(