Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -98,13 +98,20 @@ def execute_python(code: str, config: RunnableConfig):
|
|
| 98 |
except Exception as e:
|
| 99 |
return (f"Error executing code: {str(e)}", None)
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
memory = MemorySaver()
|
| 103 |
model = ChatOpenAI(model="gpt-4o", streaming=True)
|
| 104 |
prompt = ChatPromptTemplate.from_messages([
|
| 105 |
("system", f"You are a Data Visualization assistant.You have access to an jupyter notebook with access to internet for python code execution.\
|
| 106 |
Your taks is to assist users with your data analysis and visualization expertise. Use Plotly for creating visualizations and charts. Generated artifacts\
|
| 107 |
-
are automatically rendered in the UI. Variables do not persist across tool calls, hence save any data to current directory you want to use in the next tool call to a file.(use file_name and do not add file path, as you have only permission to edit current folder)
|
| 108 |
{datetime.now().strftime('%Y-%m-%d')}. Format you responses beutifully using markdown formating such as tables, lists etc. The current folder contains the following files: {{collection_files}} {yf_docs}"),
|
| 109 |
("placeholder", "{messages}"),
|
| 110 |
])
|
|
|
|
| 98 |
except Exception as e:
|
| 99 |
return (f"Error executing code: {str(e)}", None)
|
| 100 |
|
| 101 |
+
save_yf_prompt = """
|
| 102 |
+
# Save downloaded data
|
| 103 |
+
data = yf.download(['MSFT', 'AAPL', 'GOOG'], period='6mo')
|
| 104 |
+
data.to_pickle('stock_data.pkl')
|
| 105 |
+
"""
|
| 106 |
+
# Load it back later
|
| 107 |
+
data = pd.read_pickle('stock_data.pkl')
|
| 108 |
|
| 109 |
memory = MemorySaver()
|
| 110 |
model = ChatOpenAI(model="gpt-4o", streaming=True)
|
| 111 |
prompt = ChatPromptTemplate.from_messages([
|
| 112 |
("system", f"You are a Data Visualization assistant.You have access to an jupyter notebook with access to internet for python code execution.\
|
| 113 |
Your taks is to assist users with your data analysis and visualization expertise. Use Plotly for creating visualizations and charts. Generated artifacts\
|
| 114 |
+
are automatically rendered in the UI. Variables do not persist across tool calls, hence save any data to current directory you want to use in the next tool call to a file.(use file_name and do not add file path, as you have only permission to edit current folder) {save_yf_prompt} Today's date is \
|
| 115 |
{datetime.now().strftime('%Y-%m-%d')}. Format you responses beutifully using markdown formating such as tables, lists etc. The current folder contains the following files: {{collection_files}} {yf_docs}"),
|
| 116 |
("placeholder", "{messages}"),
|
| 117 |
])
|