Implementation:A616567126 GPT WEB JAVA CommonConst
| Knowledge Sources | |
|---|---|
| Domains | Configuration, Constants |
| Last Updated | 2026-10-13 00:00 GMT |
Overview
Concrete constants class providing global configuration keys, API endpoint paths, credit cost values, and service-specific constants for the GPT-WEB-JAVA application.
Description
The CommonConst class is a central repository of static final constants used throughout the GPT-WEB-JAVA application. It defines Redis key prefixes, API callback URLs, credit consumption counts for each AI service (GPT, Midjourney, Stable Diffusion, Spark, Bard, StableStudio), external API endpoints (Discord, OpenAI, Baidu, StableStudio, Spark), and various configuration values like queue sizes and thread pool sizes.
Usage
Reference this class when you need to use any application-wide constant, such as Redis key prefixes for caching, credit cost values for billing, or API endpoint URLs for external service integration.
Code Reference
Source Location
- Repository: A616567126_GPT_WEB_JAVA
- File: src/main/java/com/intelligent/bot/constant/CommonConst.java
- Lines: 1-412
Signature
public class CommonConst {
// Redis key prefixes
public static final long TOKEN_EXPIRE_TIME = 7L;
public static final String REDIS_KEY_PREFIX_TOKEN = "TOKEN:";
public static final String SEND_EMAIL_CODE = "email:code";
public static final String KEY_PREFIX = "mj-task::";
public static final String SYS_CONFIG = "sysConfig";
public static final String PAY_CONFIG = "payConfig";
public static final String EMAIL_LIST = "emailList";
// Credit consumption counts
public static final Integer GPT_NUMBER = 2;
public static final Integer GPT_4_NUMBER = 5;
public static final Integer MJ_NUMBER = 5;
public static final Integer SD_NUMBER = 2;
public static final Integer SPARK_V2_NUMBER = 3;
public static final Integer SPARK_V3_NUMBER = 5;
public static final Integer SPARK_V35_NUMBER = 7;
// Discord API URLs
public static final String DISCORD_API_URL = "https://discord.com/api/v9/interactions";
public static final String MJ_WSS_URL = "wss://gateway.discord.gg";
// OpenAI API paths
public static final String CPT_CHAT_URL = "/v1/chat/completions";
public static final String CPT_IMAGES_URL = "/v1/images/generations";
// StableStudio API paths
public static final String STABLE_STUDIO_USER_ACCOUNT = "/v1/user/account";
public static final String STABLE_STUDIO_TEXT_TO_IMAGE = "/v1/generation/%s/text-to-image";
// SD WebUI API paths
public static final String SD_TXT_2_IMG = "/sdapi/v1/txt2img";
public static final String SD_IMG_2_IMG = "/sdapi/v1/img2img";
// Spark API hosts
public static final String SPARK_API_HOST_WSS_V2_1 = "https://spark-api.xf-yun.com/v2.1/chat";
public static final String SPARK_API_HOST_WSS_V3_5 = "https://spark-api.xf-yun.com/v3.5/chat";
// Queue configuration
public static final Integer QUEUE_SIZE = 5;
public static final String QUEUE_KEY = "user:queue";
// Notification thread pool
public static final Integer NOTIFY_POOL_SIZE = 10;
}
Import
import com.intelligent.bot.constant.CommonConst;
I/O Contract
Inputs
This is a constants class with no inputs. All values are static final fields.
Outputs
| Name | Type | Description |
|---|---|---|
| REDIS_KEY_PREFIX_TOKEN | String | Redis key prefix for JWT tokens ("TOKEN:") |
| SYS_CONFIG | String | Redis key for system configuration ("sysConfig") |
| PAY_CONFIG | String | Redis key for payment configuration ("payConfig") |
| GPT_NUMBER | Integer | Credit cost for GPT-3.5 chat (2) |
| GPT_4_NUMBER | Integer | Credit cost for GPT-4 chat (5) |
| MJ_NUMBER | Integer | Credit cost for Midjourney imagine (5) |
| SD_NUMBER | Integer | Credit cost for Stable Diffusion (2) |
| SPARK_V2_NUMBER | Integer | Credit cost for Spark V2 (3) |
| SPARK_V3_NUMBER | Integer | Credit cost for Spark V3 (5) |
| SPARK_V35_NUMBER | Integer | Credit cost for Spark V3.5 (7) |
| DISCORD_API_URL | String | Discord interactions API endpoint |
| MJ_WSS_URL | String | Discord Gateway WSS URL |
| CPT_CHAT_URL | String | OpenAI chat completions endpoint path |
| SD_TXT_2_IMG | String | SD WebUI text-to-image API path |
| QUEUE_SIZE | Integer | Max concurrent image generation tasks (5) |
| NOTIFY_POOL_SIZE | Integer | Notification thread pool core size (10) |
Usage Examples
Using Credit Constants
import com.intelligent.bot.constant.CommonConst;
// Deduct credits based on AI service type
int cost = CommonConst.MJ_NUMBER; // 5 credits for MJ imagine
checkService.deductCredits(userId, cost);
Using Redis Key Prefixes
import com.intelligent.bot.constant.CommonConst;
// Cache system config in Redis
RedisUtil.setCacheObject(CommonConst.SYS_CONFIG, sysConfig);
// Retrieve system config from Redis
SysConfig config = RedisUtil.getCacheObject(CommonConst.SYS_CONFIG);
Using API Endpoints
import com.intelligent.bot.constant.CommonConst;
// Build Discord interactions URL
String url = CommonConst.DISCORD_API_URL;
// Build SD WebUI text-to-image URL
String sdUrl = sysConfig.getSdUrl() + CommonConst.SD_TXT_2_IMG;