Version: 0.9.80.dev.260506
后端: 1. LLM 独立服务与统一计费出口落地:新增 `cmd/llm`、`client/llm` 与 `services/llm/rpc`,补齐 BillingContext、CreditBalanceGuard、价格规则解析、stream usage 归集与 `credit.charge.requested` outbox 发布,active-scheduler / agent / course / memory / gateway fallback 全部改走 llm zrpc,不再各自本地初始化模型。 2. TokenStore 收口为 Credit 权威账本:新增 credit account / ledger / product / order / price-rule / reward-rule 能力与 Redis 快照缓存,扩展 tokenstore rpc/client 支撑余额快照、消耗看板、商品、订单、流水、价格规则和奖励规则,并接入 LLM charge 事件消费完成 Credit 扣费落账。 3. 计费旧链路下线与网关切口切换:`/token-store` 语义整体切到 `/credit-store`,agent chat 移除旧 TokenQuotaGuard,userauth 的 CheckTokenQuota / AdjustTokenUsage 改为废弃,聊天历史落库不再同步旧 token 额度账本,course 图片解析请求补 user_id 进入新计费口径。 前端: 4. 计划广场从 mock 数据切到真实接口:新增 forum api/types,首页支持真实列表、标签、搜索、防抖、点赞、导入和发布计划,详情页补齐帖子详情、评论树、回复和删除评论链路,同时补上“至少一个标签”的前后端约束与默认标签兜底。 5. 商店页切到 Credit 体系并重做展示:顶部改为余额 + Credit/Token 消耗看板,支持 24h/7d/30d/all 周期切换;套餐区展示原价与当前价;历史区改为当前用户 Credit 流水并支持查看更多,整体视觉和交互同步收口。 仓库: 6. 配置与本地启动体系补齐 llm / outbox 编排:`config.example.yaml` 增加 llm rpc 和统一 outbox service 配置,`dev-common.ps1` 把 llm 纳入多服务依赖并自动建 Kafka topic,`docker-compose.yml` 同步初始化 agent/task/memory/active-scheduler/notification/taskclass-forum/llm/token-store 全量 outbox topic。
This commit is contained in:
@@ -13,6 +13,16 @@ service TokenStoreService {
|
||||
rpc MockPaidOrder(MockPaidOrderRequest) returns (MockPaidOrderResponse);
|
||||
rpc ListGrants(ListTokenGrantsRequest) returns (ListTokenGrantsResponse);
|
||||
rpc RecordForumRewardGrant(RecordForumRewardGrantRequest) returns (RecordForumRewardGrantResponse);
|
||||
rpc GetCreditBalanceSnapshot(GetCreditBalanceSnapshotRequest) returns (GetCreditBalanceSnapshotResponse);
|
||||
rpc GetCreditConsumptionDashboard(GetCreditConsumptionDashboardRequest) returns (GetCreditConsumptionDashboardResponse);
|
||||
rpc ListCreditProducts(ListCreditProductsRequest) returns (ListCreditProductsResponse);
|
||||
rpc CreateCreditOrder(CreateCreditOrderRequest) returns (CreateCreditOrderResponse);
|
||||
rpc ListCreditOrders(ListCreditOrdersRequest) returns (ListCreditOrdersResponse);
|
||||
rpc GetCreditOrder(GetCreditOrderRequest) returns (GetCreditOrderResponse);
|
||||
rpc MockPaidCreditOrder(MockPaidCreditOrderRequest) returns (MockPaidCreditOrderResponse);
|
||||
rpc ListCreditTransactions(ListCreditTransactionsRequest) returns (ListCreditTransactionsResponse);
|
||||
rpc ListCreditPriceRules(ListCreditPriceRulesRequest) returns (ListCreditPriceRulesResponse);
|
||||
rpc ListCreditRewardRules(ListCreditRewardRulesRequest) returns (ListCreditRewardRulesResponse);
|
||||
}
|
||||
|
||||
message PageResponse {
|
||||
@@ -154,3 +164,191 @@ message RecordForumRewardGrantRequest {
|
||||
message RecordForumRewardGrantResponse {
|
||||
TokenGrantView grant = 1;
|
||||
}
|
||||
|
||||
message CreditBalanceSnapshotView {
|
||||
uint64 user_id = 1;
|
||||
int64 balance = 2;
|
||||
bool is_blocked = 3;
|
||||
string snapshot_source = 4;
|
||||
string updated_at = 5;
|
||||
int64 total_recharged = 6;
|
||||
int64 total_rewarded = 7;
|
||||
int64 total_consumed = 8;
|
||||
}
|
||||
|
||||
message CreditProductView {
|
||||
uint64 product_id = 1;
|
||||
string name = 2;
|
||||
string description = 3;
|
||||
int64 credit_amount = 4;
|
||||
int64 price_cent = 5;
|
||||
string price_text = 6;
|
||||
string currency = 7;
|
||||
string badge = 8;
|
||||
string status = 9;
|
||||
int32 sort_order = 10;
|
||||
int64 original_price_cent = 11;
|
||||
}
|
||||
|
||||
message CreditOrderView {
|
||||
uint64 order_id = 1;
|
||||
string order_no = 2;
|
||||
string status = 3;
|
||||
int64 credit_amount = 4;
|
||||
int64 amount_cent = 5;
|
||||
string price_text = 6;
|
||||
string currency = 7;
|
||||
string payment_mode = 8;
|
||||
string created_at = 9;
|
||||
string paid_at = 10;
|
||||
string credited_at = 11;
|
||||
string product_snapshot = 12;
|
||||
string product_name = 13;
|
||||
int32 quantity = 14;
|
||||
}
|
||||
|
||||
message CreditTransactionView {
|
||||
uint64 transaction_id = 1;
|
||||
string event_id = 2;
|
||||
string source = 3;
|
||||
string source_label = 4;
|
||||
string direction = 5;
|
||||
int64 amount = 6;
|
||||
int64 balance_after = 7;
|
||||
string status = 8;
|
||||
string description = 9;
|
||||
string metadata_json = 10;
|
||||
string created_at = 11;
|
||||
uint64 order_id = 12;
|
||||
}
|
||||
|
||||
message CreditPriceRuleView {
|
||||
uint64 rule_id = 1;
|
||||
string scene = 2;
|
||||
string provider_name = 3;
|
||||
string model_name = 4;
|
||||
int64 input_price_micros = 5;
|
||||
int64 output_price_micros = 6;
|
||||
int64 cached_price_micros = 7;
|
||||
int64 reasoning_price_micros = 8;
|
||||
int64 credit_per_yuan = 9;
|
||||
string status = 10;
|
||||
int32 priority = 11;
|
||||
string description = 12;
|
||||
}
|
||||
|
||||
message CreditRewardRuleView {
|
||||
uint64 rule_id = 1;
|
||||
string source = 2;
|
||||
string name = 3;
|
||||
int64 amount = 4;
|
||||
string status = 5;
|
||||
string description = 6;
|
||||
}
|
||||
|
||||
message GetCreditBalanceSnapshotRequest {
|
||||
uint64 user_id = 1;
|
||||
}
|
||||
|
||||
message GetCreditBalanceSnapshotResponse {
|
||||
CreditBalanceSnapshotView snapshot = 1;
|
||||
}
|
||||
|
||||
message CreditConsumptionDashboardView {
|
||||
string period = 1;
|
||||
int64 credit_consumed = 2;
|
||||
int64 token_consumed = 3;
|
||||
}
|
||||
|
||||
message GetCreditConsumptionDashboardRequest {
|
||||
uint64 actor_user_id = 1;
|
||||
string period = 2;
|
||||
}
|
||||
|
||||
message GetCreditConsumptionDashboardResponse {
|
||||
CreditConsumptionDashboardView dashboard = 1;
|
||||
}
|
||||
|
||||
message ListCreditProductsRequest {
|
||||
uint64 actor_user_id = 1;
|
||||
}
|
||||
|
||||
message ListCreditProductsResponse {
|
||||
repeated CreditProductView items = 1;
|
||||
}
|
||||
|
||||
message CreateCreditOrderRequest {
|
||||
uint64 actor_user_id = 1;
|
||||
uint64 product_id = 2;
|
||||
int32 quantity = 3;
|
||||
string idempotency_key = 4;
|
||||
}
|
||||
|
||||
message CreateCreditOrderResponse {
|
||||
CreditOrderView order = 1;
|
||||
}
|
||||
|
||||
message ListCreditOrdersRequest {
|
||||
uint64 actor_user_id = 1;
|
||||
int32 page = 2;
|
||||
int32 page_size = 3;
|
||||
string status = 4;
|
||||
}
|
||||
|
||||
message ListCreditOrdersResponse {
|
||||
repeated CreditOrderView items = 1;
|
||||
PageResponse page = 2;
|
||||
}
|
||||
|
||||
message GetCreditOrderRequest {
|
||||
uint64 actor_user_id = 1;
|
||||
uint64 order_id = 2;
|
||||
}
|
||||
|
||||
message GetCreditOrderResponse {
|
||||
CreditOrderView order = 1;
|
||||
}
|
||||
|
||||
message MockPaidCreditOrderRequest {
|
||||
uint64 actor_user_id = 1;
|
||||
uint64 order_id = 2;
|
||||
string mock_channel = 3;
|
||||
string idempotency_key = 4;
|
||||
}
|
||||
|
||||
message MockPaidCreditOrderResponse {
|
||||
CreditOrderView order = 1;
|
||||
}
|
||||
|
||||
message ListCreditTransactionsRequest {
|
||||
uint64 actor_user_id = 1;
|
||||
int32 page = 2;
|
||||
int32 page_size = 3;
|
||||
string source = 4;
|
||||
string direction = 5;
|
||||
}
|
||||
|
||||
message ListCreditTransactionsResponse {
|
||||
repeated CreditTransactionView items = 1;
|
||||
PageResponse page = 2;
|
||||
}
|
||||
|
||||
message ListCreditPriceRulesRequest {
|
||||
string scene = 1;
|
||||
string provider_name = 2;
|
||||
string model_name = 3;
|
||||
string status = 4;
|
||||
}
|
||||
|
||||
message ListCreditPriceRulesResponse {
|
||||
repeated CreditPriceRuleView items = 1;
|
||||
}
|
||||
|
||||
message ListCreditRewardRulesRequest {
|
||||
string source = 1;
|
||||
string status = 2;
|
||||
}
|
||||
|
||||
message ListCreditRewardRulesResponse {
|
||||
repeated CreditRewardRuleView items = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user