diff --git a/README.md b/README.md index d46753f4..55f381de 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ It mainly has the following characteristics: ## 🎉 News * 🔥🔥🔥Aug 8, 2024: A new graph based code generation tool [CodexGraph](https://arxiv.org/abs/2408.03910) is released by Modelscope-Agent, it has been proved effective and versatile on various code related tasks, please check [example](https://github.com/modelscope/modelscope-agent/tree/master/apps/codexgraph_agent). -* 🔥🔥Aug 1, 2024: A high efficient and reliable Data Science Assistant is running on Modelscope-Agent, please find detail in [example](https://github.com/modelscope/modelscope-agent/blob/master/examples/agents/data_science_assistant.ipynb). +* 🔥🔥Aug 1, 2024: A high efficient and reliable Data Science Assistant is running on Modelscope-Agent, please find detail in [example](https://github.com/modelscope/modelscope-agent/tree/master/apps/datascience_assistant). * 🔥July 17, 2024: Parallel tool calling on Modelscope-Agent-Server, please find detail in [doc](https://github.com/modelscope/modelscope-agent/blob/master/modelscope_agent_servers/README.md). * 🔥June 17, 2024: Upgrading RAG flow based on LLama-index, allow user to hybrid search knowledge by different strategies and modalities, please find detail in [doc](https://github.com/modelscope/modelscope-agent/blob/master/modelscope_agent/rag/README_zh.md). * 🔥June 6, 2024: With [Modelscope-Agent-Server](https://github.com/modelscope/modelscope-agent/blob/master/modelscope_agent_servers/README.md), **Qwen2** could be used by OpenAI SDK with tool calling ability, please find detail in [doc](https://github.com/modelscope/modelscope-agent/blob/master/docs/llms/qwen2_tool_calling.md). diff --git a/README_CN.md b/README_CN.md index 08f85405..bb2d5ad7 100644 --- a/README_CN.md +++ b/README_CN.md @@ -41,7 +41,7 @@ Modelscope-Agent是一个可定制的、可扩展的Agent代码框架。单Agent ## 更新 * 🔥🔥🔥Aug 8, 2024: 基于Graph的[CodexGraph](https://arxiv.org/abs/2408.03910)代码生成工具依赖Modelscope-Agent上线, 目前在多个代码生成、补全任务上展示了有效性和通用性,请查看[使用示例](https://github.com/modelscope/modelscope-agent/tree/master/apps/codexgraph_agent). -* 🔥🔥Aug 1, 2024: Modelscope-Agent目前支持了高性能的且效果可靠的数据科学助理, 请查看[使用示例](https://github.com/modelscope/modelscope-agent/blob/master/examples/agents/data_science_assistant.ipynb). +* 🔥🔥Aug 1, 2024: Modelscope-Agent目前支持了高性能的且效果可靠的数据科学助理, 请查看[使用示例](https://github.com/modelscope/modelscope-agent/tree/master/apps/datascience_assistant). * 🔥July 17, 2024: Modelscope-Agent-Server支持并行工具生成(parallel_tool_calls)[doc](https://github.com/modelscope/modelscope-agent/blob/master/modelscope_agent_servers/README.md). * 🔥June 17, 2024: 基于llama-index的RAG链路升级,支持混合搜索(多策略,多模态),相关详情具体参考[文档](https://github.com/modelscope/modelscope-agent/blob/master/modelscope_agent/rag/README_zh.md). * 🔥June 6, 2024: 通过利用[Modelscope-Agent-Server](https://github.com/modelscope/modelscope-agent/blob/master/modelscope_agent_servers/README.md),**Qwen2**可以通过OpenAI的SDK实现tool calling的能力,具体参考[文档](https://github.com/modelscope/modelscope-agent/blob/master/docs/llms/qwen2_tool_calling.md). diff --git a/apps/datascience_assistant/README.md b/apps/datascience_assistant/README.md index 961ce0d8..dc1f739d 100644 --- a/apps/datascience_assistant/README.md +++ b/apps/datascience_assistant/README.md @@ -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) diff --git a/apps/datascience_assistant/app.py b/apps/datascience_assistant/app.py index e590a1a6..db3dcbf8 100644 --- a/apps/datascience_assistant/app.py +++ b/apps/datascience_assistant/app.py @@ -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=[''])) -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=[''])) + 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) diff --git a/docs/source_en/agents/data_science_assistant_en.md b/docs/source_en/agents/data_science_assistant.md similarity index 100% rename from docs/source_en/agents/data_science_assistant_en.md rename to docs/source_en/agents/data_science_assistant.md diff --git a/resources/data_science_assistant_streamlit_1.png b/resources/data_science_assistant_streamlit_1.png index e98b56c4..7dc423e6 100644 Binary files a/resources/data_science_assistant_streamlit_1.png and b/resources/data_science_assistant_streamlit_1.png differ diff --git a/resources/data_science_assistant_streamlit_4.png b/resources/data_science_assistant_streamlit_4.png new file mode 100644 index 00000000..f24499ec Binary files /dev/null and b/resources/data_science_assistant_streamlit_4.png differ