### Node.js Handler with Initializer Function Source: https://www.volcengine.com/docs/6662/116908 This example demonstrates adding an initializer function to perform global setup, such as database connections, before the handler is invoked. This helps reduce cold start times. ```javascript // vefaas-nodejs14-default exports.handler = async function handler (event, context) { return { statusCode: 200, headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ 'vefaas-nodejs14-default': 'hello world'}), }; }; // vefaas will try to do initializer when start up the instance, to avoid cold start from user perspective. // initializer will only be executed for one time when there is no exception. // otherwise initializer will be executed again before every invoke, till successfully inited. exports.initializer = async function (context) { console.log('initializer begin'); // replace the following line, with the real init logic await new Promise(resolve => setTimeout(resolve, 3 * 1000)); console.log('initializer end'); }; ``` -------------------------------- ### TLS Configuration Example Source: https://www.volcengine.com/docs/6662/1327609 Example of TLS configuration for logging, including project ID and topic ID. ```json { "EnableLog": true, "TlsProjectId": "a40202c5-fe22-4ea7-******", "TlsTopicId": "2ff955cb-1f03-4b9b-******" } ``` -------------------------------- ### CreateTimer Request and Response Examples Source: https://www.volcengine.com/docs/6662/1391867?lang=zh Examples showing the HTTP POST request structure for creating a timer and the corresponding JSON response from the server. ```json POST http://open.volcengineapi.com/?Action=CreateTimer&Version=2024-06-06 HTTP/1.1 Content-Type: application/json { "FunctionId": "qtqzj**", "Name": "doc-timer", "Description": "Timer触发器", "Enabled": true, "Crontab": "*/5 * * * *", "EnableConcurrency": false } ``` ```json HTTP/1.1 200 OK Content-Type: application/json { "ResponseMetadata": { "RequestId": "202411291616311B603AD90**", "Action": "CreateTimer", "Version": "2024-06-06", "Service": "vefaas", "Region": "cn-beijing" }, "Result": { "FunctionId": "qtqzj**", "Id": "ing3qa2**", "Name": "doc-timer", "Description": "Timer触发器", "Enabled": true, "Crontab": "*/5 * * * *", "Payload": "", "CreationTime": "2024-11-29 16:16:31.540584873 +0800 CST m=+65768.359252459", "LastUpdateTime": "2024-11-29 16:16:31.540584953 +0800 CST m=+65768.359252522", "EnableConcurrency": false, "Retries": 0 } } ``` -------------------------------- ### ListReleaseRecords Response Example Source: https://www.volcengine.com/docs/6662/1327610?lang=zh Example of a successful 200 OK response containing the list of release records and metadata. ```json HTTP/1.1 200 OK Content-Type: application/json { "ResponseMetadata": { "RequestId": "20230604110420****100232280022D31", "Action": "ListReleaseRecords", "Version": "2024-06-06", "Service": "vefaas", "Region": "cn-beijing" }, "Result": { "Items": [ { "Id": "cytso41iugitj01x", "Status": "finished", "FinishTime": "2024-06-14 15:31:07.143863491 +0800 CST m=+88714.902440914", "FunctionId": "nuvpugx5", "Description": "Support xxx feature", "CreationTime": "2024-06-14 15:31:07.143863441 +0800 CST m=+88714.902440864", "LastUpdateTime": "2024-06-14 15:31:07.143863491 +0800 CST m=+88714.902440914", "SourceRevisionNumber": 9, "TargetRevisionNumber": 10 } ], "Total": 1 } } ``` -------------------------------- ### GetReleaseStatus Request and Response Examples Source: https://www.volcengine.com/docs/6662/1327338 Examples of the HTTP POST request and the corresponding JSON response for checking function release status. ```json POST http://open.volcengineapi.com/?Action=GetReleaseStatus&Version=2024-06-06 HTTP/1.1 Content-Type: application/json { "FunctionId": "nw******" } ``` ```json HTTP/1.1 200 OK Content-Type: application/json { "ResponseMetadata": { "RequestId": "20230604110420****100232280022D31", "Action": "GetReleaseStatus", "Version": "2024-06-06", "Service": "vefaas", "Region": "cn-beijing" }, "Result": { "FunctionId": "nwwzoaq1", "Status": "done", "StatusMessage": "Function release finished successfully", "StableRevisionNumber": 1, "NewRevisionNumber": 1, "OldRevisionNumber": 1, "StartTime": "2024-06-27 07:05:12", "TargetTrafficWeight": 100, "CurrentTrafficWeight": 50, "ErrorCode": "function_start_failed", "FailedInstanceLogs": "https://vefaas-sit.tos-s3-cn-boe.volces.com/release_failed_instance_logs/******", "ReleaseRecordId": "xozo******" } } ``` -------------------------------- ### ListFunctionInstances Request Example Source: https://www.volcengine.com/docs/6662/1327336?lang=zh This example demonstrates how to make a POST request to the ListFunctionInstances API to query function instances. Ensure the Content-Type is set to application/json. ```http POST http://open.volcengineapi.com/?Action=ListFunctionInstances&Version=2024-06-06 HTTP/1.1 Content-Type: application/json { "FunctionId": "nw******" } ``` -------------------------------- ### VPC Configuration Example Source: https://www.volcengine.com/docs/6662/1327609 Example of VPC configuration for a function, including VPC ID, subnet IDs, security group IDs, and internet access settings. ```json { "EnableVpc": true, "VpcId": "vpc-rrag******", "SubnetIds": [ "subnet-milb******" ], "SecurityGroupIds": [ "sg-rrag******" ], "EnableSharedInternetAccess": true } ``` -------------------------------- ### PrecacheSandboxImages Request and Response Examples Source: https://www.volcengine.com/docs/6662/1824712?lang=zh Examples showing the HTTP POST request structure and the corresponding JSON response for the PrecacheSandboxImages API. ```JSON POST http://open.volcengineapi.com/?Action=PrecacheSandboxImages&Version=2024-06-06 HTTP/1.1 Content-Type: application/json { "ImageUrls": [ "vefaas-******.cr.volces.com/vefaas-cr/******:latest" ] } ``` ```JSON HTTP/1.1 200 OK Content-Type: application/json { "ResponseMetadata": { "RequestId": "20230604110420****100232280022D31", "Action": "PrecacheSandboxImages", "Version": "2024-06-06", "Service": "vefaas", "Region": "cn-beijing" }, "Result": { "TicketId": "948410ee80954******" } } ``` -------------------------------- ### Create Function HTTP Request Example Source: https://www.volcengine.com/docs/6662/1262132 This example shows the HTTP POST request structure for creating a function, including the endpoint and headers. ```http POST http://open.volcengineapi.com/?Action=CreateFunction&Version=2024-06-06 HTTP/1.1 Content-Type: application/json ``` -------------------------------- ### ListFunctionInstances Response Example Source: https://www.volcengine.com/docs/6662/1327336?lang=zh This is an example of a successful response from the ListFunctionInstances API, showing the structure of returned function instance data, including metadata and a list of items. ```json HTTP/1.1 200 OK Content-Type: application/json { "ResponseMetadata": { "RequestId": "20230604110420****100232280022D31", "Action": "ListFunctionInstances", "Version": "2024-06-06", "Service": "vefaas", "Region": "cn-beijing" }, "Result": { "Items": [ { "Id": "nw******", "CreationTime": "2024-06-25 11:17:11.492301904 +0800 CST", "InstanceName": "nw******-vd9qztck6t-74b9cf8975-bkd99", "InstanceStatus": "Starting", "RevisionNumber": 1 } ], "Total": 1 } } ``` -------------------------------- ### Startup script for host and port configuration Source: https://www.volcengine.com/docs/6662/1336108?lang=zh This section of the startup script demonstrates how to configure the listening address (HOST) and port (PORT) from environment variables or command-line arguments. The HOST must be '0.0.0.0' for deployment. ```bash # 配置监听地址和端口。 # 监听地址必须为 0.0.0.0,否则会导致部署失败。 HOST="0.0.0.0" PORT=${_FAAS_RUNTIME_PORT} TIMEOUT=${_FAAS_FUNC_TIMEOUT} # 解析参数 while [[ $# -gt 0 ]]; do case $1 in --port) PORT="$2" shift 2 ;; --host) HOST="$2" shift 2 ;; *) shift ;; esac done ``` -------------------------------- ### Initialize Volcengine Provider for Sandbox Source: https://www.volcengine.com/docs/6662/1851199?lang=zh Demonstrates how to initialize the Volcengine provider using environment variables for credentials and region. ```python from __future__ import print_function import os import sys # Add the parent directory to Python path so we can import agent_sandbox sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from agent_sandbox.providers import VolcengineProvider def main(): """ Main function demonstrating Volcengine provider usage. """ # Configuration - replace with your actual credentials access_key = os.getenv("VOLC_ACCESSKEY") secret_key = os.getenv("VOLC_SECRETKEY") region = os.getenv("VOLCENGINE_REGION", "cn-beijing") ``` -------------------------------- ### Get Kafka Trigger Request Example Source: https://www.volcengine.com/docs/6662/1451302?lang=zh Use this POST request to retrieve the details of a specific Kafka trigger. Ensure you provide the correct `Id` and `FunctionId`. ```http POST http://open.volcengineapi.com/?Action=GetKafkaTrigger&Version=2024-06-06 HTTP/1.1 Content-Type: application/json { "Id": "nw******", "FunctionId": "wrw******" } ``` ```json { "Id": "nw******", "FunctionId": "wrw******" } ``` -------------------------------- ### Get Kafka Trigger Response Example Source: https://www.volcengine.com/docs/6662/1451302?lang=zh This is a successful HTTP 200 OK response for the GetKafkaTrigger API call, detailing the Kafka trigger's configuration and status. ```json HTTP/1.1 200 OK Content-Type: application/json { "ResponseMetadata": { "RequestId": "20230604110420****100232280022D31", "Action": "GetKafkaTrigger", "Version": "2024-06-06", "Service": "vefaas", "Region": "cn-beijing" }, "Result": { "FunctionId": "wrw******", "Name": "reviews-consumer", "Description": "示例 kafka 触发器", "Enabled": true, "MqInstanceId": "kafka-cnngl4if******", "TopicName": "reviews-topic", "StartingPosition": "Latest", "MaximumRetryAttempts": 100, "Id": "18lt****", "ConsumerGroup": "reviews-topic_18lt****", "Status": "pending", "CreationTime": "2025-02-03 06:47:41.423691239 +0000 UTC", "LastUpdateTime": "2025-02-03 06:47:41.423691239 +0000 UTC" } } ``` -------------------------------- ### 使用 Python SDK 创建沙箱实例 Source: https://www.volcengine.com/docs/6662/1852301 通过 VolcengineProvider 初始化并调用 create_sandbox 方法创建沙箱实例,需配置有效的访问密钥和区域信息。 ```python from __future__ import print_function import os import sys # Add the parent directory to Python path so we can import agent_sandbox sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from agent_sandbox.providers import VolcengineProvider def main(): """ Main function demonstrating Volcengine provider usage. """ # Configuration - replace with your actual credentials access_key = os.getenv("VOLC_ACCESSKEY") secret_key = os.getenv("VOLC_SECRETKEY") region = os.getenv("VOLCENGINE_REGION", "cn-beijing") # Initialize the Volcengine provider provider = VolcengineProvider( access_key=access_key, secret_key=secret_key, region=region ) print("=== Volcengine Sandbox Provider Example ===\n") function_id = "yato****" print("1. Creating a sandbox...") sandbox_id = provider.create_sandbox(function_id=function_id) print(f"Create response: {sandbox_id}") if __name__ == "__main__": main() ``` -------------------------------- ### Get Kafka Trigger Response Example Source: https://www.volcengine.com/docs/6662/1451302 This is a successful response (HTTP 200 OK) for the GetKafkaTrigger API call. It includes metadata about the request and the detailed configuration of the Kafka trigger. ```json HTTP/1.1 200 OK Content-Type: application/json { "ResponseMetadata": { "RequestId": "20230604110420****100232280022D31", "Action": "GetKafkaTrigger", "Version": "2024-06-06", "Service": "vefaas", "Region": "cn-beijing" }, "Result": { "FunctionId": "wrw******", "Name": "reviews-consumer", "Description": "示例 kafka 触发器", "Enabled": true, "MqInstanceId": "kafka-cnngl4if******", "TopicName": "reviews-topic", "StartingPosition": "Latest", "MaximumRetryAttempts": 100, "Id": "18lt****", "ConsumerGroup": "reviews-topic_18lt****", "Status": "pending", "CreationTime": "2025-02-03 06:47:41.423691239 +0000 UTC", "LastUpdateTime": "2025-02-03 06:47:41.423691239 +0000 UTC" } } ``` -------------------------------- ### FastAPI application example Source: https://www.volcengine.com/docs/6662/1336108?lang=zh A basic FastAPI application demonstrating GET and POST request handling for the root path. This code is intended for use within the Native Python runtime. ```python from fastapi import FastAPI import time # 创建一个 FastAPI 应用实例 app = FastAPI() # 定义根路径 '/' 的 GET 路由 @app.get('/') def index_handler(): return 'Hello FastAPI From FaaS nativepython3 (and bye python2)!' # 定义根路径 '/' 的 POST 路由 @app.post('/') async def root_post_handler(payload: dict): return {"message": "POST request received", "payload": payload} ``` -------------------------------- ### Make run.sh executable Source: https://www.volcengine.com/docs/6662/1336108?lang=zh Ensure your startup script is executable before deployment. This command should be run locally. ```shell # 注意是在本地执行该命令 # 假设启动脚本为 run.sh chmod a+x run.sh ``` -------------------------------- ### Get Kafka Trigger Request Example Source: https://www.volcengine.com/docs/6662/1451302 Use this POST request to retrieve the details of a specific Kafka trigger by providing its ID and the associated Function ID. Ensure the Content-Type is set to application/json. ```http POST http://open.volcengineapi.com/?Action=GetKafkaTrigger&Version=2024-06-06 HTTP/1.1 Content-Type: application/json { "Id": "nw******", "FunctionId": "wrw******" } ``` -------------------------------- ### Deploy Project to Volcengine Function Service Source: https://www.volcengine.com/docs/6662/2206937?lang=zh Deploy projects to Volcengine Function Service using `vefaas cli`. Consult `vefaas -h` and the quickstart guide for assistance. Ensure non-interactive mode is used for deployment to avoid terminal waiting. ```bash vefaas -h ``` ```bash vefaas deploy -h ``` -------------------------------- ### Create a Microservice Application Function with Python SDK Source: https://www.volcengine.com/docs/6662/1386373 Demonstrates how to initialize the client and call the create_function method to deploy a microservice application using a function template. ```python from __future__ import print_function​ import volcenginesdkvefaas​ import volcenginesdkcore​ from pprint import pprint​ from volcenginesdkcore.rest import ApiException​ ​ region = "cn-beijing"​ access_key = "yourAccessKeyId"​ secret_key = "yourAccessKeySecret"​ ​ ​ def create_function_micro_service_code():​ configuration = volcenginesdkcore.Configuration()​ configuration.ak = access_key​ configuration.sk = secret_key​ configuration.region = region​ configuration.client_side_validation = True​ volcenginesdkcore.Configuration.set_default(configuration)​ ​ client = volcenginesdkvefaas.VEFAASApi(volcenginesdkcore.ApiClient(configuration))​ ​ try:​ resp = client.create_function(​ volcenginesdkvefaas.CreateFunctionRequest(​ name="micro-service-doctest",​ runtime="native/v1",​ vpc_config=volcenginesdkvefaas.VpcConfigForCreateFunctionInput(​ enable_vpc=True,​ vpc_id="vpc-id",​ subnet_ids=["subnet-id"],​ security_group_ids=["sg-id"]​ ),​ cpu_strategy="always",​ command="./run.sh"​ )​ )​ pprint(resp)​ except ApiException as e:​ print("Exception when calling API: %s\n" % e)​ ​ ​ if __name__ == "__main__":​ create_function_micro_service_code() ``` -------------------------------- ### Create Sandbox Instance using Volcengine Python SDK Source: https://www.volcengine.com/docs/6662/1851199 This Python script demonstrates how to create a sandbox instance using the Volcengine provider from the All-in-One SDK. It requires setting environment variables for access key, secret key, and region. Replace 'yatoczqh' with your actual function ID. ```python from __future__ import print_function import os import sys # Add the parent directory to Python path so we can import agent_sandbox sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from agent_sandbox.providers import VolcengineProvider def main(): """ Main function demonstrating Volcengine provider usage. """ # Configuration - replace with your actual credentials access_key = os.getenv("VOLC_ACCESSKEY") secret_key = os.getenv("VOLC_SECRETKEY") region = os.getenv("VOLCENGINE_REGION", "cn-beijing") # Initialize the Volcengine provider provider = VolcengineProvider( access_key=access_key, secret_key=secret_key, region=region ) print("=== Volcengine Sandbox Provider Example ===\n") function_id = "yatoczqh" print("1. Creating a sandbox...") sandbox_id = provider.create_sandbox(function_id=function_id) print(f"Create response: {sandbox_id}") if __name__ == "__main__": main() ``` -------------------------------- ### GetRocketMQTrigger Request Example Source: https://www.volcengine.com/docs/6662/1327337?lang=zh Example of a POST request to retrieve RocketMQ trigger details. ```http POST http://open.volcengineapi.com/?Action=GetRocketMQTrigger&Version=2024-06-06 HTTP/1.1 Content-Type: application/json { "Id": "kh******", "FunctionId": "aj******" } ``` -------------------------------- ### GetRocketMQTrigger Response Example Source: https://www.volcengine.com/docs/6662/1327337?lang=zh Example of a successful JSON response containing the RocketMQ trigger configuration. ```json HTTP/1.1 200 OK Content-Type: application/json { "ResponseMetadata": { "RequestId": "20230604110420****100232280022D31", "Action": "GetRocketMQTrigger", "Version": "2024-06-06", "Service": "vefaas", "Region": "cn-beijing" }, "Result": { "FunctionId": "aj******", "Name": "rmq1", "Description": "轻量级官网", "Enabled": true, "MqInstanceId": "rocketmq-cnoe******", "TopicName": "test", "StartingPosition": "Latest", "MaximumRetryAttempts": 100, "Id": "kh******", "ConsumerGroup": "GID_test", "Status": "ready", "Orderly": true, "QPSLimit": 0, "CreationTime": "2024-02-13 02:36:23.033 +0000 UTC", "LastUpdateTime": "2024-02-13 02:36:23.033 +0000 UTC", "Endpoint": "http://rocketmq-cnoeaf70cd8b1234.rocketmq.ivolces.com:9876" } } ``` -------------------------------- ### 编写 Golang 编译脚本 build.sh Source: https://www.volcengine.com/docs/6662/1206695?lang=zh 用于编译 Golang 代码的脚本,需确保二进制文件在 Linux 环境下运行。 ```bash #! /bin/bash set -ex cd `dirname $0` go mod tidy # Note: the binary should be compiled using linux env so as to run on FaaS Platform XD. GOOS=linux GOARCH=amd64 go build -v -ldflags '-w -extldflags "-static"' -o main ``` -------------------------------- ### Example Request Data for SandboxFusion Source: https://www.volcengine.com/docs/6662/1585066 This is an example of the data payload structure for requesting code execution from SandboxFusion. ```json "data": { "code": "print(\"Hello, SandboxFusion!\")", "language": "python" } ``` -------------------------------- ### Create Function Request Example Source: https://www.volcengine.com/docs/6662/1262132 This JSON payload demonstrates how to configure a function, including source, environment variables, VPC, TLS, NAS storage, and TOS mounts. ```json { "Name": "official-site", "Description": "Lightweight Official Website", "Runtime": "python3.8/v1", "ExclusiveMode": false, "RequestTimeout": 30, "MaxConcurrency": 100, "MemoryMB": 1024, "SourceType": "tos", "Source": "pqyqo9qa/3kwem******.zip", "Envs": [ { "Key": "business_type", "Value": "free" } ], "VpcConfig": { "VpcId": "vpc-2d73mgm****", "EnableVpc": true, "SubnetIds": [ "subnet-mj1l******" ], "SecurityGroupIds": [ "sg-3re8ffwjclybk5zsk****" ], "EnableSharedInternetAccess": true }, "TlsConfig": { "EnableLog": true, "TlsTopicId": "0cd4e4c4-5436-4b05-b39e-****", "TlsProjectId": "48f49d74-cd50-4591-a3d0-****" }, "SourceAccessConfig": { "Password": "password ", "Username": "operator" }, "Tags": [ { "Key": "business", "Value": "ecommerce" } ], "NasStorage": { "EnableNas": true, "NasConfigs": [ { "RemotePath": "/", "FileSystemId": "enas-cns******", "MountPointId": "mount-63******", "LocalMountPath": "/mnt/nas" } ] }, "TosMountConfig": { "EnableTos": false, "Credentials": { "AccessKeyId": "******", "SecretAccessKey": "******" }, "MountPoints": [ { "Endpoint": "http://tos-cn-beijing.ivolces.com", "ReadOnly": true, "BucketName": "ai-model", "BucketPath": "/", "LocalMountPath": "/mnt/tos" } ] }, "InitializerSec": 30, "Command": "./run.sh", "Port": 8000, "CpuStrategy": "always", "ProjectName": "default", "CpuMilli": 10, "Cell": "2", "Role": "trn:iam::140******:role/VeFaaSDefaultRole" } ``` -------------------------------- ### ListReleaseRecords Request Example Source: https://www.volcengine.com/docs/6662/1327610?lang=zh Example of a POST request to the ListReleaseRecords endpoint, including pagination and filtering parameters. ```json POST http://open.volcengineapi.com/?Action=ListReleaseRecords&Version=2024-06-06 HTTP/1.1 Content-Type: application/json { "FunctionId": "nuvpugx5", "PageNumber": 1, "PageSize": 10, "Filters": [ { "Name": "Id", "Value": [ "7d2******" ] } ], "OrderBy": { "Key": "CreationTime", "Ascend": false } } ``` -------------------------------- ### Create Sandbox Instance Source: https://www.volcengine.com/docs/6662/1824706?lang=zh Creates a sandbox instance with specified configurations. ```APIDOC ## POST /api/createSandbox ### Description Creates a sandbox instance. This endpoint allows you to provision a new sandbox environment with various configuration options. ### Method POST ### Endpoint http://open.volcengineapi.com/?Action=CreateSandbox&Version=2024-06-06 ### Parameters #### Query Parameters - **Action** (String) - Required - The name of the API action. Must be `CreateSandbox`. - **Version** (String) - Required - The API version. Must be `2024-06-06`. #### Request Body - **FunctionId** (String) - Required - The ID of the sandbox application to which the sandbox instance belongs. - **Timeout** (Integer) - Optional - The survival time of the sandbox instance in minutes. Defaults to 60. Range: 3-1440. - **Metadata** (JSON Map) - Optional - Metadata for the sandbox instance, used for tagging and filtering. Format: `{"key":"value"}`. - **InstanceTosMountConfig** (Object) - Optional - Configuration for mounting Object Storage (TOS) for the sandbox instance. - **Enable** (Boolean) - Required - Whether instance-level TOS mounting is enabled. `true` or `false`. - **TosMountPoints** (Array of Object) - Required if `Enable` is true. Specific TOS mount point information. - **BucketPath** (String) - Required - The remote directory in TOS to mount. - **LocalMountPath** (String) - Required - The local directory in the sandbox instance to mount the TOS bucket to. - **Envs** (Array of Object) - Optional - Environment variables for the sandbox instance. - **Key** (String) - Required - The key of the environment variable. - **Value** (String) - Required - The value of the environment variable. - **InstanceImageInfo** (Object) - Optional - Information about the sandbox instance image. - **Id** (String) - Optional - The ID of the pre-warmed image to use. - **Port** (Integer) - Required - The listening port of the sandbox instance image. Avoid ports 9000, 9001, 9990. - **Image** (String) - Optional - The address of the pre-warmed image to use. - **Command** (String) - Required - The command to start the sandbox instance program. Use absolute paths for scripts. - **CpuMilli** (Integer) - Optional - The CPU specification for the sandbox instance in milli CPU. Defaults to 1000. Range: 250-16000. - **MemoryMB** (Integer) - Optional - The memory specification for the sandbox instance in MiB. Defaults to 2048. Range: 512-131072. - **MaxConcurrency** (Integer) - Optional - The maximum number of concurrent requests per instance. Defaults to 100. Range: 10-1000. - **RequestTimeout** (Integer) - Optional - The request timeout in seconds. Defaults to 30. Range: 1-900. ### Request Example ```json { "FunctionId": "wrws****", "Timeout": 60, "Metadata": { "app": "test" }, "InstanceTosMountConfig": { "Enable": true, "TosMountPoints": [ { "BucketPath": "/sandbox", "LocalMountPath": "/mnt/tos" } ] }, "Envs": [ { "Key": "business_type", "Value": "free" } ], "InstanceImageInfo": { "Id": "xGWv****", "Port": 8080, "Image": "cr-vefaas-cn-beijing.cr.volces.com/wdf/test/****:latest", "Command": "bash /root/sandbox/scripts/run.sh" }, "CpuMilli": 500, "MemoryMB": 1024, "MaxConcurrency": 20, "RequestTimeout": 30 } ``` ### Response #### Success Response (200) - **SandboxId** (String) - The ID of the created sandbox instance, which is also its name. #### Response Example ```json { "ResponseMetadata": { "RequestId": "20230604110420****100232280022D31", "Action": "CreateSandbox", "Version": "2024-06-06", "Service": "vefaas", "Region": "cn-beijing" }, "Result": { "SandboxId": "vefaas-e8m6xarn-p2zamuv2fr-******" } } ``` ### Error Handling Refer to Common Error Codes for troubleshooting API call failures. ``` -------------------------------- ### 执行结果评测 Source: https://www.volcengine.com/docs/6662/2191799 使用 sb-cli 工具对推理结果进行评测。 ```Bash sb-cli verified test --predictions_path preds/preds.json --workers=5 --output_dir eval ``` -------------------------------- ### GetFunctionInstanceLogs API Response Example Source: https://www.volcengine.com/docs/6662/1327340?lang=zh This is an example of a successful response from the GetFunctionInstanceLogs API. It includes ResponseMetadata and the Result containing the Logs. ```json { "ResponseMetadata": { "RequestId": "20230604110420****100232280022D31", "Action": "GetFunctionInstanceLogs", "Version": "2024-06-06", "Service": "vefaas", "Region": "cn-beijing" }, "Result": { "Logs": "2024-06-25T11:18:25.136415053+08:00 Model loaded in 11.1s (load weights from disk: 3.7s, create model: 0.6s, apply weights to model: 5.5s, load textual inversion embeddings: 0.2s, calculate empty prompt: 1.0s).\n" } } ``` -------------------------------- ### 执行 SWE-Bench 推理流程 Source: https://www.volcengine.com/docs/6662/2191799 使用 mini-extra 工具启动单次或批量推理任务。 ```Bash mini-extra swebench-single -c swebench_vefaas.yaml ``` ```Bash mini-extra swebench -c swebench_vefaas.yaml --subset=verified --split=test --shuffle --output=preds --workers=5 ```