Skip to content

Commit

Permalink
add upload file feature
Browse files Browse the repository at this point in the history
  • Loading branch information
dahaipeng committed Aug 14, 2024
1 parent 8ac12a6 commit 8f0cee9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
18 changes: 12 additions & 6 deletions apps/datascience_assistant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@ Detailed information can be found in the [documentation](../../docs/source/agent
## Quick Start
Streamlit is a Python library that makes it easy to create and share beautiful, custom web apps for machine learning and data science.

To run the DS Assistant in streamlit, you need to install the Streamlit library. You can install it using pip:
To run the DS Assistant in streamlit, you need to install additional libraries. You can install it using pip:
```bash
pip install streamlit streamlit-jupyter
pip install streamlit mistune matplotlib nbconvert
```
Then, you need to set

Then, you can run the DS Assistant using the following command:
```bash
streamlit run app.py
cd ../../
streamlit run ./apps/datascience_assistant/app.py
```

After running the command, a new tab will open in your default web browser with the DS Assistant running.
The following are screenshots of the DS Assistant running in the browser:

you can upload your dataset and write your request.
![img_2.png](../../resources/data_science_assistant_streamlit_1.png)
you can view all of the codes and in streamlit

After submitting your request, DS Assistant will automatically generate a plan for this request.
![img_2.png](../../resources/data_science_assistant_streamlit_4.png)

After that, DS Assistant will automatically excute every task, you can view all of the codes and details in streamlit
![img_3.png](../../resources/data_science_assistant_streamlit_2.png)

After you have finished using the DS Assistant, you can directly convert the running process to a pdf
![img_5.png](../../resources/data_science_assistant_streamlit_3.png)
16 changes: 14 additions & 2 deletions apps/datascience_assistant/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import os
import sys

import streamlit as st
from modelscope_agent.agents.data_science_assistant import DataScienceAssistant
from modelscope_agent.tools.metagpt_tools.tool_recommend import \
TypeMatchToolRecommender

current_dir = os.path.dirname(os.path.abspath(__file__))
project_root_path = os.path.abspath(os.path.join(current_dir, '../../'))
sys.path.append(project_root_path)
llm_config = {
'model': 'qwen2-72b-instruct',
'model_server': 'dashscope',
Expand All @@ -17,7 +21,15 @@
st.write(
'This is a data science assistant that can help you with your data science tasks.'
)
st.write('Please input your request below and click the submit button.')
user_request = st.text_input('User Request')
st.write(
'Please input your request and upload files then click the submit button.')

files = st.file_uploader(
'Please upload files that you need. ', accept_multiple_files=True)
last_file_name = ''
user_request = st.text_area('User Request')
if st.button('submit'):
for file in files:
with open(file.name, 'wb') as f:
f.write(file.getbuffer())
data_science_assistant.run(user_request=user_request, streamlit=True)
Binary file modified resources/data_science_assistant_streamlit_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/data_science_assistant_streamlit_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8f0cee9

Please sign in to comment.