Merge pull request #1139 from 666haiwen/feat/add_agent_in_runflow
Feat/add data analysis agent in runflow
This commit is contained in:
@@ -137,6 +137,17 @@ For unstable multi-agent version, you also can run:
|
||||
python run_flow.py
|
||||
```
|
||||
|
||||
### Custom Adding Multiple Agents
|
||||
|
||||
Currently, besides the general OpenManus Agent, we have also integrated the DataAnalysis Agent, which is suitable for data analysis and data visualization tasks. You can add this agent to `run_flow` in `config.toml`.
|
||||
|
||||
```toml
|
||||
# Optional configuration for run-flow
|
||||
[runflow]
|
||||
use_data_analysis_agent = true # Disabled by default, change to true to activate
|
||||
```
|
||||
In addition, you need to install the relevant dependencies to ensure the agent runs properly: [Detailed Installation Guide](app/tool/chart_visualization/README.md##Installation)
|
||||
|
||||
## How to contribute
|
||||
|
||||
We welcome any friendly suggestions and helpful contributions! Just create issues or submit pull requests.
|
||||
|
||||
@@ -137,6 +137,19 @@ python run_mcp.py
|
||||
python run_flow.py
|
||||
```
|
||||
|
||||
## カスタムマルチエージェントの追加
|
||||
|
||||
現在、一般的なOpenManusエージェントに加えて、データ分析とデータ可視化タスクに適したDataAnalysisエージェントが組み込まれています。このエージェントを`config.toml`の`run_flow`に追加することができます。
|
||||
|
||||
```toml
|
||||
# run-flowのオプション設定
|
||||
[runflow]
|
||||
use_data_analysis_agent = true # デフォルトでは無効、trueに変更すると有効化されます
|
||||
```
|
||||
|
||||
これに加えて、エージェントが正常に動作するために必要な依存関係をインストールする必要があります:[具体的なインストールガイド](app/tool/chart_visualization/README_ja.md##インストール)
|
||||
|
||||
|
||||
## 貢献方法
|
||||
|
||||
我々は建設的な意見や有益な貢献を歓迎します!issueを作成するか、プルリクエストを提出してください。
|
||||
|
||||
@@ -137,6 +137,18 @@ python run_mcp.py
|
||||
python run_flow.py
|
||||
```
|
||||
|
||||
### 사용자 정의 다중 에이전트 추가
|
||||
|
||||
현재 일반 OpenManus 에이전트 외에도 데이터 분석 및 데이터 시각화 작업에 적합한 DataAnalysis 에이전트를 통합했습니다. 이 에이전트를 `config.toml`의 `run_flow`에 추가할 수 있습니다.
|
||||
|
||||
```toml
|
||||
# run-flow에 대한 선택적 구성
|
||||
[runflow]
|
||||
use_data_analysis_agent = true # 기본적으로 비활성화되어 있으며, 활성화하려면 true로 변경
|
||||
```
|
||||
|
||||
또한, 에이전트가 제대로 작동하도록 관련 종속성을 설치해야 합니다: [상세 설치 가이드](app/tool/chart_visualization/README.md##Installation)
|
||||
|
||||
## 기여 방법
|
||||
|
||||
모든 친절한 제안과 유용한 기여를 환영합니다! 이슈를 생성하거나 풀 리퀘스트를 제출해 주세요.
|
||||
|
||||
@@ -138,6 +138,17 @@ python run_mcp.py
|
||||
python run_flow.py
|
||||
```
|
||||
|
||||
## 添加自定义多智能体
|
||||
|
||||
目前除了通用的 OpenManus Agent, 我们还内置了DataAnalysis Agent,适用于数据分析和数据可视化任务,你可以在`config.toml`中将这个智能体加入到`run_flow`中
|
||||
```toml
|
||||
# run-flow可选配置
|
||||
[runflow]
|
||||
use_data_analysis_agent = true # 默认关闭,将其改为true则为激活
|
||||
```
|
||||
除此之外,你还需要安装相关的依赖来确保智能体正常运行:[具体安装指南](app/tool/chart_visualization/README_zh.md##安装)
|
||||
|
||||
|
||||
## 贡献指南
|
||||
|
||||
我们欢迎任何友好的建议和有价值的贡献!可以直接创建 issue 或提交 pull request。
|
||||
|
||||
@@ -17,8 +17,8 @@ class DataAnalysis(ToolCallAgent):
|
||||
including Data Analysis, Chart Visualization, Data Report.
|
||||
"""
|
||||
|
||||
name: str = "DataAnalysis"
|
||||
description: str = "An analytical agent that utilizes multiple tools to solve diverse data analysis tasks"
|
||||
name: str = "Data_Analysis"
|
||||
description: str = "An analytical agent that utilizes python and data visualization tools to solve diverse data analysis tasks"
|
||||
|
||||
system_prompt: str = SYSTEM_PROMPT.format(directory=config.workspace_root)
|
||||
next_step_prompt: str = NEXT_STEP_PROMPT
|
||||
|
||||
@@ -60,6 +60,12 @@ class SearchSettings(BaseModel):
|
||||
)
|
||||
|
||||
|
||||
class RunflowSettings(BaseModel):
|
||||
use_data_analysis_agent: bool = Field(
|
||||
default=False, description="Enable data analysis agent in run flow"
|
||||
)
|
||||
|
||||
|
||||
class BrowserSettings(BaseModel):
|
||||
headless: bool = Field(False, description="Whether to run browser in headless mode")
|
||||
disable_security: bool = Field(
|
||||
@@ -158,6 +164,9 @@ class AppConfig(BaseModel):
|
||||
None, description="Search configuration"
|
||||
)
|
||||
mcp_config: Optional[MCPSettings] = Field(None, description="MCP configuration")
|
||||
run_flow_config: Optional[RunflowSettings] = Field(
|
||||
None, description="Run flow configuration"
|
||||
)
|
||||
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
@@ -269,6 +278,11 @@ class Config:
|
||||
else:
|
||||
mcp_settings = MCPSettings(servers=MCPSettings.load_server_config())
|
||||
|
||||
run_flow_config = raw_config.get("runflow")
|
||||
if run_flow_config:
|
||||
run_flow_settings = RunflowSettings(**run_flow_config)
|
||||
else:
|
||||
run_flow_settings = RunflowSettings()
|
||||
config_dict = {
|
||||
"llm": {
|
||||
"default": default_settings,
|
||||
@@ -281,6 +295,7 @@ class Config:
|
||||
"browser_config": browser_settings,
|
||||
"search_config": search_settings,
|
||||
"mcp_config": mcp_settings,
|
||||
"run_flow_config": run_flow_settings,
|
||||
}
|
||||
|
||||
self._config = AppConfig(**config_dict)
|
||||
@@ -306,6 +321,11 @@ class Config:
|
||||
"""Get the MCP configuration"""
|
||||
return self._config.mcp_config
|
||||
|
||||
@property
|
||||
def run_flow_config(self) -> RunflowSettings:
|
||||
"""Get the Run Flow configuration"""
|
||||
return self._config.run_flow_config
|
||||
|
||||
@property
|
||||
def workspace_root(self) -> Path:
|
||||
"""Get the workspace root directory"""
|
||||
|
||||
+21
-3
@@ -137,12 +137,30 @@ class PlanningFlow(BaseFlow):
|
||||
"""Create an initial plan based on the request using the flow's LLM and PlanningTool."""
|
||||
logger.info(f"Creating initial plan with ID: {self.active_plan_id}")
|
||||
|
||||
# Create a system message for plan creation
|
||||
system_message = Message.system_message(
|
||||
system_message_content = (
|
||||
"You are a planning assistant. Create a concise, actionable plan with clear steps. "
|
||||
"Focus on key milestones rather than detailed sub-steps. "
|
||||
"Optimize for clarity and efficiency."
|
||||
)
|
||||
agents_description = []
|
||||
for key in self.executor_keys:
|
||||
if key in self.agents:
|
||||
agents_description.append(
|
||||
{
|
||||
"name": key.upper(),
|
||||
"description": self.agents[key].description,
|
||||
}
|
||||
)
|
||||
if len(agents_description) > 1:
|
||||
# Add description of agents to select
|
||||
system_message_content += (
|
||||
f"\nNow we have {agents_description} agents. "
|
||||
f"The infomation of them are below: {json.dumps(agents_description)}\n"
|
||||
"When creating steps in the planning tool, please specify the agent names using the format '[agent_name]'."
|
||||
)
|
||||
|
||||
# Create a system message for plan creation
|
||||
system_message = Message.system_message(system_message_content)
|
||||
|
||||
# Create a user message with the request
|
||||
user_message = Message.user_message(
|
||||
@@ -270,7 +288,7 @@ class PlanningFlow(BaseFlow):
|
||||
YOUR CURRENT TASK:
|
||||
You are now working on step {self.current_step_index}: "{step_text}"
|
||||
|
||||
Please execute this step using the appropriate tools. When you're done, provide a summary of what you accomplished.
|
||||
Please only execute this current step using the appropriate tools. When you're done, provide a summary of what you accomplished.
|
||||
"""
|
||||
|
||||
# Use agent.run() to execute the step
|
||||
|
||||
@@ -4,19 +4,46 @@
|
||||
|
||||
The chart visualization tool generates data processing code through Python and ultimately invokes [@visactor/vmind](https://github.com/VisActor/VMind) to obtain chart specifications. Chart rendering is implemented using [@visactor/vchart](https://github.com/VisActor/VChart).
|
||||
|
||||
## Installation
|
||||
## Installation (Mac / Linux)
|
||||
|
||||
1. Install Node.js >= 18
|
||||
1. Install node >= 18
|
||||
|
||||
```bash
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
|
||||
# After installation, restart the terminal and install the latest Node.js LTS version:
|
||||
nvm install --lts
|
||||
# Activate nvm, for example in Bash
|
||||
source ~/.bashrc
|
||||
# Then install the latest stable release of Node
|
||||
nvm install node
|
||||
# Activate usage, for example if the latest stable release is 22, then use 22
|
||||
nvm use 22
|
||||
```
|
||||
|
||||
2. Install dependencies
|
||||
|
||||
```bash
|
||||
# Navigate to the appropriate location in the current repository
|
||||
cd app/tool/chart_visualization
|
||||
npm install
|
||||
```
|
||||
|
||||
## Installation (Windows)
|
||||
1. Install nvm-windows
|
||||
|
||||
Download the latest version `nvm-setup.exe` from the [official GitHub page](https://github.com/coreybutler/nvm-windows?tab=readme-ov-file#readme) and install it.
|
||||
|
||||
2. Use nvm to install node
|
||||
|
||||
```powershell
|
||||
# Then install the latest stable release of Node
|
||||
nvm install node
|
||||
# Activate usage, for example if the latest stable release is 22, then use 22
|
||||
nvm use 22
|
||||
```
|
||||
|
||||
3. Install dependencies
|
||||
|
||||
```bash
|
||||
# Navigate to the appropriate location in the current repository
|
||||
cd app/tool/chart_visualization
|
||||
npm install
|
||||
```
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
# グラフ可視化ツール
|
||||
|
||||
グラフ可視化ツールは、Pythonを使用してデータ処理コードを生成し、最終的に[@visactor/vmind](https://github.com/VisActor/VMind)を呼び出してグラフのspec結果を得ます。グラフのレンダリングには[@visactor/vchart](https://github.com/VisActor/VChart)を使用します。
|
||||
|
||||
## インストール (Mac / Linux)
|
||||
|
||||
1. Node >= 18をインストール
|
||||
|
||||
```bash
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
|
||||
# nvmを有効化、例としてBashを使用
|
||||
source ~/.bashrc
|
||||
# その後、最新の安定版Nodeをインストール
|
||||
nvm install node
|
||||
# 使用を有効化、例えば最新の安定版が22の場合、use 22
|
||||
nvm use 22
|
||||
```
|
||||
|
||||
2. 依存関係をインストール
|
||||
|
||||
```bash
|
||||
cd app/tool/chart_visualization
|
||||
npm install
|
||||
```
|
||||
|
||||
## インストール (Windows)
|
||||
1. nvm-windowsをインストール
|
||||
|
||||
[GitHub公式サイト](https://github.com/coreybutler/nvm-windows?tab=readme-ov-file#readme)から最新バージョンの`nvm-setup.exe`をダウンロードしてインストール
|
||||
|
||||
2. nvmを使用してNodeをインストール
|
||||
|
||||
```powershell
|
||||
# その後、最新の安定版Nodeをインストール
|
||||
nvm install node
|
||||
# 使用を有効化、例えば最新の安定版が22の場合、use 22
|
||||
nvm use 22
|
||||
```
|
||||
|
||||
3. 依存関係をインストール
|
||||
|
||||
```bash
|
||||
# 現在のリポジトリで適切な位置に移動
|
||||
cd app/tool/chart_visualization
|
||||
npm install
|
||||
```
|
||||
|
||||
## ツール
|
||||
### python_execute
|
||||
|
||||
Pythonコードを使用してデータ分析(データ可視化を除く)に必要な部分を実行します。これにはデータ処理、データ要約、レポート生成、および一般的なPythonスクリプトコードが含まれます。
|
||||
|
||||
#### 入力
|
||||
```typescript
|
||||
{
|
||||
// コードタイプ:データ処理/データレポート/その他の一般的なタスク
|
||||
code_type: "process" | "report" | "others"
|
||||
// 最終実行コード
|
||||
code: string;
|
||||
}
|
||||
```
|
||||
|
||||
#### 出力
|
||||
Python実行結果、中間ファイルの保存とprint出力結果を含む
|
||||
|
||||
### visualization_preparation
|
||||
|
||||
データ可視化の準備ツールで、2つの用途があります。
|
||||
|
||||
#### Data -> Chart
|
||||
データから分析に必要なデータ(.csv)と対応する可視化の説明を抽出し、最終的にJSON設定ファイルを出力します。
|
||||
|
||||
#### Chart + Insight -> Chart
|
||||
既存のグラフと対応するデータインサイトを選択し、データインサイトをデータ注釈の形式でグラフに追加し、最終的にJSON設定ファイルを生成します。
|
||||
|
||||
#### 入力
|
||||
```typescript
|
||||
{
|
||||
// コードタイプ:データ可視化またはデータインサイト追加
|
||||
code_type: "visualization" | "insight"
|
||||
// 最終的なJSONファイルを生成するためのPythonコード
|
||||
code: string;
|
||||
}
|
||||
```
|
||||
|
||||
#### 出力
|
||||
データ可視化の設定ファイル、`data_visualization tool`で使用
|
||||
|
||||
## data_visualization
|
||||
|
||||
`visualization_preparation`の内容に基づいて具体的なデータ可視化を生成
|
||||
|
||||
### 入力
|
||||
```typescript
|
||||
{
|
||||
// 設定ファイルのパス
|
||||
json_path: string;
|
||||
// 現在の用途、データ可視化またはインサイト注釈追加
|
||||
tool_type: "visualization" | "insight";
|
||||
// 最終成果物pngまたはhtml;htmlではvchartのレンダリングとインタラクションをサポート
|
||||
output_type: 'png' | 'html'
|
||||
// 言語、現在は中国語と英語をサポート
|
||||
language: "zh" | "en"
|
||||
}
|
||||
```
|
||||
|
||||
## 出力
|
||||
最終的に'png'または'html'の形式でローカルに保存され、保存されたグラフのパスとグラフ内で発見されたデータインサイトを出力
|
||||
|
||||
## VMind設定
|
||||
|
||||
### LLM
|
||||
|
||||
VMind自体
|
||||
@@ -0,0 +1,128 @@
|
||||
# 차트 시각화 도구
|
||||
|
||||
차트 시각화 도구는 Python을 통해 데이터 처리 코드를 생성하고, 최종적으로 [@visactor/vmind](https://github.com/VisActor/VMind)를 호출하여 차트 사양을 얻습니다. 차트 렌더링은 [@visactor/vchart](https://github.com/VisActor/VChart)를 사용하여 구현됩니다.
|
||||
|
||||
## 설치 (Mac / Linux)
|
||||
|
||||
1. Node.js 18 이상 설치
|
||||
|
||||
```bash
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
|
||||
# nvm 활성화, 예를 들어 Bash
|
||||
source ~/.bashrc
|
||||
# 그런 다음 최신 안정 버전의 Node 설치
|
||||
nvm install node
|
||||
# 사용 활성화, 예를 들어 최신 안정 버전이 22인 경우 use 22
|
||||
nvm use 22
|
||||
```
|
||||
|
||||
2. 의존성 설치
|
||||
|
||||
```bash
|
||||
# 현재 저장소에서 해당 위치로 이동
|
||||
cd app/tool/chart_visualization
|
||||
npm install
|
||||
```
|
||||
|
||||
## 설치 (Windows)
|
||||
1. nvm-windows 설치
|
||||
|
||||
[공식 GitHub 페이지](https://github.com/coreybutler/nvm-windows?tab=readme-ov-file#readme)에서 최신 버전의 `nvm-setup.exe`를 다운로드하고 설치합니다.
|
||||
|
||||
2. nvm을 사용하여 Node.js 설치
|
||||
|
||||
```powershell
|
||||
# 그런 다음 최신 안정 버전의 Node 설치
|
||||
nvm install node
|
||||
# 사용 활성화, 예를 들어 최신 안정 버전이 22인 경우 use 22
|
||||
nvm use 22
|
||||
```
|
||||
|
||||
3. 의존성 설치
|
||||
|
||||
```bash
|
||||
# 현재 저장소에서 해당 위치로 이동
|
||||
cd app/tool/chart_visualization
|
||||
npm install
|
||||
```
|
||||
|
||||
## 도구
|
||||
### python_execute
|
||||
|
||||
Python 코드를 사용하여 데이터 분석의 필요한 부분(데이터 시각화 제외)을 실행합니다. 여기에는 데이터 처리, 데이터 요약, 보고서 생성 및 일부 일반적인 Python 스크립트 코드가 포함됩니다.
|
||||
|
||||
#### 입력
|
||||
```typescript
|
||||
{
|
||||
// 코드 유형: 데이터 처리/데이터 보고서/기타 일반 작업
|
||||
code_type: "process" | "report" | "others"
|
||||
// 최종 실행 코드
|
||||
code: string;
|
||||
}
|
||||
```
|
||||
|
||||
#### 출력
|
||||
Python 실행 결과, 중간 파일 저장 및 출력 결과 포함.
|
||||
|
||||
### visualization_preparation
|
||||
|
||||
데이터 시각화를 위한 사전 도구로 두 가지 목적이 있습니다.
|
||||
|
||||
#### 데이터 -> 차트
|
||||
분석에 필요한 데이터(.csv)와 해당 시각화 설명을 데이터에서 추출하여 최종적으로 JSON 구성 파일을 출력합니다.
|
||||
|
||||
#### 차트 + 인사이트 -> 차트
|
||||
기존 차트와 해당 데이터 인사이트를 선택하고, 데이터 주석 형태로 차트에 추가할 데이터 인사이트를 선택하여 최종적으로 JSON 구성 파일을 생성합니다.
|
||||
|
||||
#### 입력
|
||||
```typescript
|
||||
{
|
||||
// 코드 유형: 데이터 시각화 또는 데이터 인사이트 추가
|
||||
code_type: "visualization" | "insight"
|
||||
// 최종 JSON 파일을 생성하는 데 사용되는 Python 코드
|
||||
code: string;
|
||||
}
|
||||
```
|
||||
|
||||
#### 출력
|
||||
`data_visualization tool`에 사용되는 데이터 시각화를 위한 구성 파일.
|
||||
|
||||
## data_visualization
|
||||
|
||||
`visualization_preparation`의 내용을 기반으로 특정 데이터 시각화를 생성합니다.
|
||||
|
||||
### 입력
|
||||
```typescript
|
||||
{
|
||||
// 구성 파일 경로
|
||||
json_path: string;
|
||||
// 현재 목적, 데이터 시각화 또는 인사이트 주석 추가
|
||||
tool_type: "visualization" | "insight";
|
||||
// 최종 제품 png 또는 html; html은 vchart 렌더링 및 상호작용 지원
|
||||
output_type: 'png' | 'html'
|
||||
// 언어, 현재 중국어 및 영어 지원
|
||||
language: "zh" | "en"
|
||||
}
|
||||
```
|
||||
|
||||
## VMind 구성
|
||||
|
||||
### LLM
|
||||
|
||||
VMind는 지능형 차트 생성을 위해 LLM 호출이 필요합니다. 기본적으로 `config.llm["default"]` 구성을 사용합니다.
|
||||
|
||||
### 생성 설정
|
||||
|
||||
주요 구성에는 차트 크기, 테마 및 생성 방법이 포함됩니다.
|
||||
### 생성 방법
|
||||
기본값: png. 현재 LLM이 컨텍스트에 따라 `output_type`을 자동으로 선택하는 것을 지원합니다.
|
||||
|
||||
### 크기
|
||||
기본 크기는 지정되지 않았습니다. HTML 출력의 경우 차트는 기본적으로 전체 페이지를 채웁니다. PNG 출력의 경우 기본값은 `1000*1000`입니다.
|
||||
|
||||
### 테마
|
||||
기본 테마: `'light'`. VChart는 여러 테마를 지원합니다. [테마](https://www.visactor.io/vchart/guide/tutorial_docs/Theme/Theme_Extension)를 참조하세요.
|
||||
|
||||
## 테스트
|
||||
|
||||
현재, 서로 다른 난이도의
|
||||
@@ -2,14 +2,18 @@
|
||||
|
||||
图表可视化工具,通过python生成数据处理代码,最终调用[@visactor/vmind](https://github.com/VisActor/VMind)得到图表的spec结果,图表渲染使用[@visactor/vchart](https://github.com/VisActor/VChart)
|
||||
|
||||
## 安装
|
||||
## 安装(Mac / Linux)
|
||||
|
||||
1. 安装node >= 18
|
||||
|
||||
```bash
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
|
||||
# 安装完成后重启终端,然后安装 Node 最新 LTS 版本:
|
||||
nvm install --lts
|
||||
# 激活nvm,以Bash为例
|
||||
source ~/.bashrc
|
||||
# 然后安装 Node 最近一个稳定颁布
|
||||
nvm install node
|
||||
# 激活使用,例如最新一个稳定颁布为22,则use 22
|
||||
nvm use 22
|
||||
```
|
||||
|
||||
2. 安装依赖
|
||||
@@ -18,6 +22,28 @@ nvm install --lts
|
||||
cd app/tool/chart_visualization
|
||||
npm install
|
||||
```
|
||||
|
||||
## 安装(Windows)
|
||||
1. 安装nvm-windows
|
||||
|
||||
从[github官网](https://github.com/coreybutler/nvm-windows?tab=readme-ov-file#readme)上下载最新版本`nvm-setup.exe`并且安装
|
||||
|
||||
2. 使用nvm安装node
|
||||
|
||||
```powershell
|
||||
# 然后安装 Node 最近一个稳定颁布
|
||||
nvm install node
|
||||
# 激活使用,例如最新一个稳定颁布为22,则use 22
|
||||
nvm use 22
|
||||
```
|
||||
|
||||
3. 安装依赖
|
||||
|
||||
```bash
|
||||
# 在当前仓库下定位到相应位置
|
||||
cd app/tool/chart_visualization
|
||||
npm install
|
||||
```
|
||||
## Tool
|
||||
### python_execute
|
||||
|
||||
@@ -108,7 +134,7 @@ VMind本身也需要通过调用大模型得到智能图表生成结果,目前
|
||||
|
||||
给予数据和具体的图表生成需求,测试结果,执行命令:
|
||||
```bash
|
||||
python -m app.tool.chart_visualization.test.simple_chart
|
||||
python -m app.tool.chart_visualization.test.chart_demo
|
||||
```
|
||||
结果应位于`worksapce\visualization`下,涉及到9种不同的图表结果
|
||||
|
||||
@@ -116,6 +142,6 @@ python -m app.tool.chart_visualization.test.simple_chart
|
||||
|
||||
给予简单原始数据可分析需求,需要对数据进行简单加工处理,执行命令:
|
||||
```bash
|
||||
python -m app.tool.chart_visualization.test.simple_report
|
||||
python -m app.tool.chart_visualization.test.report_demo
|
||||
```
|
||||
结果同样位于`worksapce\visualization`下
|
||||
|
||||
+950
-609
File diff suppressed because it is too large
Load Diff
@@ -10,8 +10,8 @@
|
||||
"dependencies": {
|
||||
"@visactor/vchart": "^1.13.7",
|
||||
"@visactor/vmind": "2.0.5",
|
||||
"canvas": "^2.11.2",
|
||||
"get-stdin": "^9.0.0"
|
||||
"get-stdin": "^9.0.0",
|
||||
"puppeteer": "^24.9.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import Canvas from "canvas";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import puppeteer from "puppeteer";
|
||||
import VMind, { ChartType, DataTable } from "@visactor/vmind";
|
||||
import VChart from "@visactor/vchart";
|
||||
import { isString } from "@visactor/vutils";
|
||||
|
||||
enum AlgorithmType {
|
||||
@@ -26,17 +25,20 @@ const getBase64 = async (spec: any, width?: number, height?: number) => {
|
||||
spec.animation = false;
|
||||
width && (spec.width = width);
|
||||
height && (spec.height = height);
|
||||
const cs = new VChart(spec, {
|
||||
mode: "node",
|
||||
modeParams: Canvas,
|
||||
animation: false,
|
||||
dpr: 2,
|
||||
const browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(getHtmlVChart(spec, width, height));
|
||||
|
||||
const dataUrl = await page.evaluate(() => {
|
||||
const canvas: any = document
|
||||
.getElementById("chart-container")
|
||||
?.querySelector("canvas");
|
||||
return canvas?.toDataURL("image/png");
|
||||
});
|
||||
|
||||
await cs.renderAsync();
|
||||
|
||||
const buffer = await cs.getImageBuffer();
|
||||
return buffer;
|
||||
const base64Data = dataUrl.replace(/^data:image\/png;base64,/, "");
|
||||
await browser.close();
|
||||
return Buffer.from(base64Data, "base64");
|
||||
};
|
||||
|
||||
const serializeSpec = (spec: any) => {
|
||||
@@ -53,11 +55,11 @@ const serializeSpec = (spec: any) => {
|
||||
});
|
||||
};
|
||||
|
||||
async function getHtmlVChart(spec: any, width?: number, height?: number) {
|
||||
function getHtmlVChart(spec: any, width?: number, height?: number) {
|
||||
return `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>VChart 示例</title>
|
||||
<title>VChart Demo</title>
|
||||
<script src="https://unpkg.com/@visactor/vchart/build/index.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -161,7 +163,7 @@ async function saveChartRes(options: {
|
||||
const base64 = await getBase64(spec, width, height);
|
||||
fs.writeFileSync(savedPath, base64);
|
||||
} else {
|
||||
const html = await getHtmlVChart(spec, width, height);
|
||||
const html = getHtmlVChart(spec, width, height);
|
||||
fs.writeFileSync(savedPath, html, "utf-8");
|
||||
}
|
||||
return savedPath;
|
||||
|
||||
@@ -98,3 +98,8 @@ temperature = 0.0 # Controls randomness for vision mode
|
||||
# MCP (Model Context Protocol) configuration
|
||||
[mcp]
|
||||
server_reference = "app.mcp.server" # default server module reference
|
||||
|
||||
# Optional Runflow configuration
|
||||
# Your can add additional agents into run-flow workflow to solve different-type tasks.
|
||||
[runflow]
|
||||
use_data_analysis_agent = false # The Data Analysi Agent to solve various data analysis tasks
|
||||
|
||||
+4
-1
@@ -1,7 +1,9 @@
|
||||
import asyncio
|
||||
import time
|
||||
|
||||
from app.agent.data_analysis import DataAnalysis
|
||||
from app.agent.manus import Manus
|
||||
from app.config import config
|
||||
from app.flow.flow_factory import FlowFactory, FlowType
|
||||
from app.logger import logger
|
||||
|
||||
@@ -10,7 +12,8 @@ async def run_flow():
|
||||
agents = {
|
||||
"manus": Manus(),
|
||||
}
|
||||
|
||||
if config.run_flow_config.use_data_analysis_agent:
|
||||
agents["data_analysis"] = DataAnalysis()
|
||||
try:
|
||||
prompt = input("Enter your prompt: ")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user