Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/streamlit #576

Merged
merged 37 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
96e6a31
add plan update logic
dahaipeng Jul 4, 2024
0373d07
adding update task logic
dahaipeng Jul 5, 2024
6c418a3
update datascience assistant logic to achieve better results
dahaipeng Jul 12, 2024
61d6953
Merge branch 'master' into feature/datascience_assistant
dahaipeng Jul 12, 2024
7c1c20b
Merge branch 'refs/heads/master' into feature/datascience_assistant
dahaipeng Jul 15, 2024
70d844c
add ds tools
dahaipeng Jul 18, 2024
2e54983
add ds tools
dahaipeng Jul 19, 2024
0f42462
update prompt
dahaipeng Jul 22, 2024
dd7d05d
update utils
dahaipeng Jul 22, 2024
8b752a5
update init
dahaipeng Jul 22, 2024
800fc06
Merge branch 'refs/heads/master' into feature/datascience_assistant
dahaipeng Jul 22, 2024
4f7bd6a
update log
dahaipeng Jul 23, 2024
62c2bed
Merge branch 'refs/heads/master' into feature/datascience_assistant
dahaipeng Jul 23, 2024
cb05393
delete yml
dahaipeng Jul 23, 2024
5b70701
update ds_assistant
dahaipeng Jul 24, 2024
49c50d2
Merge branch 'refs/heads/master' into feature/datascience_assistant
dahaipeng Jul 25, 2024
428401a
update ds_assistant
dahaipeng Jul 25, 2024
f6bd4e2
update ds_assistant
dahaipeng Jul 25, 2024
ee8857f
Merge branch 'refs/heads/master' into feature/datascience_assistant
dahaipeng Jul 26, 2024
1f1be09
update ds_assistant
dahaipeng Jul 26, 2024
e2310b5
fix openapi tool
dahaipeng Jul 26, 2024
458d4d5
Merge branch 'refs/heads/feature/datascience_assistant'
dahaipeng Jul 30, 2024
c536e6d
Merge remote-tracking branch 'origin/master'
dahaipeng Aug 1, 2024
292c5b9
Merge remote-tracking branch 'origin/master'
dahaipeng Aug 1, 2024
67fa1ba
Merge remote-tracking branch 'origin/master'
dahaipeng Aug 5, 2024
84bff9a
Merge remote-tracking branch 'origin/master'
dahaipeng Aug 6, 2024
dd09e85
add streamlit for better visualization
dahaipeng Aug 11, 2024
2b0cb29
Merge remote-tracking branch 'origin/master'
dahaipeng Aug 12, 2024
62162b1
add streamlit for better visualization
dahaipeng Aug 11, 2024
97c5d9f
add streamlit app for better visualization
dahaipeng Aug 12, 2024
6e287e3
Merge remote-tracking branch 'origin/feature/streamlit' into feature/…
dahaipeng Aug 12, 2024
44413fb
fix bug
dahaipeng Aug 12, 2024
8ac12a6
fix bug
dahaipeng Aug 12, 2024
124a4ea
Merge remote-tracking branch 'origin/master'
dahaipeng Aug 13, 2024
8f0cee9
add upload file feature
dahaipeng Aug 14, 2024
dd351d3
add upload file feature
dahaipeng Aug 19, 2024
e87b6ac
Merge branch 'refs/heads/master' into feature/streamlit
dahaipeng Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
60 changes: 41 additions & 19 deletions apps/datascience_assistant/app.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
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

llm_config = {
'model': 'qwen2-72b-instruct',
'model_server': 'dashscope',
}
os.environ['DASHSCOPE_API_KEY'] = input(
'Please input your dashscope api key: ')
data_science_assistant = DataScienceAssistant(
llm=llm_config, tool_recommender=TypeMatchToolRecommender(tools=['<all>']))
st.title('Data Science Assistant')
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')
if st.button('submit'):
data_science_assistant.run(user_request=user_request, streamlit=True)
os.environ['DASHSCOPE_API_KEY'] = 'YOUR_API_KEY'


def setup_project_paths():
current_dir = os.path.dirname(os.path.abspath(__file__)) # noqa
project_root_path = os.path.abspath(os.path.join(current_dir,
'../../')) # noqa
sys.path.append(project_root_path) # noqa


if __name__ == '__main__':
setup_project_paths()
from modelscope_agent.agents.data_science_assistant import \
DataScienceAssistant # noqa
from modelscope_agent.tools.metagpt_tools.tool_recommend import \
TypeMatchToolRecommender # noqa
st.title('Data Science Assistant')
st.write(
'This is a data science assistant that can help you with your data science tasks.'
)
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'):
llm_config = {
'model': 'qwen2-72b-instruct',
'model_server': 'dashscope',
}
data_science_assistant = DataScienceAssistant(
llm=llm_config,
tool_recommender=TypeMatchToolRecommender(tools=['<all>']))
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.
Loading