# test-case **Repository Path**: allmyteacher/test-case ## Basic Information - **Project Name**: test-case - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-20 - **Last Updated**: 2025-11-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Agent Interface Tester This project provides a small test harness that sends predefined human prompts to an agent backend via LangChain and records the responses in an Excel report. ## Setup 1. Install dependencies (preferably in a virtual environment): ``` pip install -r requirements.txt ``` 2. Prepare environment variables as needed: - `AGENT_BASE_URL` (default `http://172.16.1.239:2024`) - `AGENT_THREAD_ENDPOINT` (default `/threads`) - `AGENT_DATA_ENDPOINT` (default `/threads/{thread_id}/runs/stream`) - `AGENT_API_KEY` if the service requires authentication - `AGENT_THREAD_ID` to reuse an existing thread id (optional) - `AGENT_NUM_THREADS` number of threads for concurrent execution (default: 3) - `AGENT_ASSISTANT_ID` assistant identifier passed to the backend (default: `multi_agent`) ## CLI Run (批量命令行模式) The tester reads prompts from all JSON files in the `test_cases` directory and writes an Excel report (`agent_execution_result.xlsx`) that includes row number, source file name, query payload, returned `Data` value, whether `Data` is present, and latency. The final row summarizes success ratio and timing statistics. **Test Cases Directory Structure:** - Place all your test case JSON files in the `test_cases` directory - Each JSON file should follow the same format: ```json [ { "messages": [ { "role": "human", "content": "Your query here" } ] } ] ``` ```powershell python agent_interface_tester.py ` --test-dir test_cases ` --output agent_execution_result.xlsx ` --base-url http://172.16.1.239:2024 ` --thread-endpoint /threads ` --data-endpoint /threads/{thread_id}/runs/stream ` --num-threads 3 ``` All command-line options have environment-variable defaults, so in the simplest case you can just run `python agent_interface_tester.py` (it will look for the `test_cases` directory by default). ## Web Run (可视化网页模式) 除了命令行模式,还提供了一个 Flask + H5 的网页模式,便于给领导/业务演示: 1. 启动 Web Server: ```powershell $env:WEB_HOST="127.0.0.1" $env:WEB_PORT="5050" python web_server.py ``` 默认监听 `http://127.0.0.1:5050/`(如需修改,可设置环境变量 `WEB_HOST` / `WEB_PORT`)。 2. 在浏览器打开: - 单条查询模式:输入自然语言 `content`,点击“执行查询”,流式输出会实时滚动显示。 - 批量用例模式:选择本地 `test_cases` 文件夹(或其他包含 JSON 的文件夹),点击“开始批量执行”: - 网页上会显示任务进度条和动态日志区域(来源文件名、已完成条数等)。 - 执行完成后,可在页面上点击按钮下载生成的 Excel 结果文件。 - 顶部配置栏可随时调整 Base URL,并展示当前 `assistant_id` 以便确认调用对象。 ## Features - **Batch processing**: Process multiple JSON files from a directory automatically - **Source file tracking**: Excel report includes source file name for each query - **Multi-threaded execution (CLI)**: Run multiple queries concurrently (default: 3 threads) - **Streaming response handling**: Real-time display of streaming responses (CLI & Web) - **Web UI for demos**: Modern dark-themed page with tabs, progress bar, and downloadable results - **Configurable endpoints**: Web UI exposes Base URL + assistant_id for quick switching - **Progress tracking**: Visual progress bar showing test execution status with current file - **Excel reporting**: Comprehensive results with statistics summary