main: 初始化 Face to API 项目

- 添加前端抽卡台与模型配置界面
- 添加 Express API 服务与多厂商模型调用适配
- 配置本地环境示例、构建脚本和忽略规则
This commit is contained in:
2026-05-27 11:10:40 +08:00
commit cf457e8349
17 changed files with 7304 additions and 0 deletions

22
server/template.ts Normal file
View File

@@ -0,0 +1,22 @@
import type { ChatModel } from "./modelRegistry.js";
export type TemplateContext = {
draw: number;
model: ChatModel;
startedAt: Date;
};
export const renderPrompt = (template: string, context: TemplateContext) => {
const values: Record<string, string> = {
draw: String(context.draw),
model: context.model.label,
provider: context.model.providerName,
now: context.startedAt.toLocaleString("zh-CN", { hour12: false }),
timestamp: context.startedAt.toISOString()
};
return template.replace(/\{\{\s*([a-zA-Z0-9_-]+)\s*\}\}/g, (match, key: string) => {
return values[key] ?? match;
});
};