4.1 KiB
Alibaba Cloud Bailian High-Code Agent Starter
Project Introduction
This is a starter project based on FastAPI Web framework and AgentScope, providing you with an initial template code package for deploying Agents locally or via Alibaba Cloud Bailian high-code cloud deployment. It supports direct local running and testing, and deployment to Alibaba Cloud Bailian via uvicorn, allowing you to freely code and assemble atomic capabilities such as LLM, MCP, RAG, memory, and search from Alibaba Cloud Bailian & AgentScope.
Installing Dependencies
First, make sure you have Python 3.10 or higher installed.
Local Startup and Testing
pip install -r requirements.txt
Dependency Description
fastapi: For building Web APIsuvicorn: For running FastAPI applicationsagentscope-runtime: AgentScope runtime environmentPyYAML: PyYAML parsing package
Configuration
DashScope API Configuration
To use LLM features, you need to configure the Alibaba Cloud Bailian DashScope API KEY, which can also be added to the deployment machine's environment variables for subsequent cloud deployment:
-
Set
DASHSCOPE_API_KEYin thedeploy_starter/config.ymlfile:DASHSCOPE_API_KEY: "your-api-key-here,sk-xxx" -
Or set it as an environment variable:
export DASHSCOPE_API_KEY="your-api-key-here,sk-xxx"
Running the Project
Switch to project root directory and run directly
cd current-project-root-directory, the directory where setup.py is located
python -m deploy_starter.main
Running with uvicorn
uvicorn deploy_starter.main:app --host 127.0.0.1 --port 8080 --reload
API Endpoints
Health Check
Check if the application is running properly:
curl http://127.0.0.1:8080/health
Expected response:
"OK"
Chat Endpoint
Chat with the LLM (requires DashScope API key configuration):
curl -X POST http://127.0.0.1:8080/process \
-H "Content-Type: application/json" \
-d '{"message": "Hello, world!"}'
Expected response:
{
"response": "Hello! How can I help you?"
}
Notes
- Chat functionality will be unavailable if
DASHSCOPE_API_KEYis not configured. - The default model is
qwen-turbo. You can changeDASHSCOPE_MODEL_NAMEinconfig.ymlto switch models.
Alibaba Cloud Bailian High-Code Cloud Deployment
Preferably, you can directly upload the code package through the Alibaba Cloud Bailian High-Code Console
Create Application - High-Code Application
Command-line console method for code upload and deployment - Better for quick code modifications and update deployments
1. Install Dependencies
pip install agentscope-runtime==1.0.0
pip install "agentscope-runtime[deployment]==1.0.0"
2. Set Environment Variables
export ALIBABA_CLOUD_ACCESS_KEY_ID=... # Your Alibaba Cloud account AccessKey (required)
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=... # Your Alibaba Cloud account SecurityKey (required)
# Optional: If you want to use separate OSS AK/SK, you can set the following (if not set, the account AK/SK above will be used). Please ensure the account has OSS read/write permissions.
export MODELSTUDIO_WORKSPACE_ID=... # Your Bailian workspace ID
export OSS_ACCESS_KEY_ID=...
export OSS_ACCESS_KEY_SECRET=...
export OSS_REGION=cn-beijing
3. Packaging and Deployment
Method A: Manually build wheel file
Ensure your project can be built into a wheel file. You can use setup.py, setup.cfg, or pyproject.toml.
Build the wheel file:
python setup.py bdist_wheel
Deploy:
runtime-fc-deploy \
--deploy-name [your app name] \
--whl-path [relative path to your wheel file, e.g. "/dist/your_app.whl"]
For details, please refer to the Alibaba Cloud Bailian High-Code Deployment Documentation: Alibaba Cloud Bailian High-Code Deployment Documentation

