33import { Command } from 'commander' ;
44import app from './app' ;
55import { version } from '../package.json'
6+ import { loadModelMapping , getMappedModelName } from './config/modelMapping' ;
67// 扩展全局对象类型
78declare global {
89 var verboseLogging : boolean ;
@@ -17,6 +18,7 @@ program
1718 . option ( '-p, --port <number>' , 'Server port' , '3000' )
1819 . option ( '-H, --host <address>' , 'Server host address' , '0.0.0.0' )
1920 . option ( '-v, --verbose' , 'Enable request logging to console' , false )
21+ . option ( '-c, --config <path>' , 'Path to model mapping config file' , './model-mapping.json' )
2022 . parse ( ) ;
2123
2224const options = program . opts ( ) ;
@@ -27,13 +29,17 @@ const HOST = options.host || '0.0.0.0';
2729// 设置全局变量控制日志输出
2830global . verboseLogging = options . verbose ;
2931
32+ // Load model mapping configuration
33+ loadModelMapping ( options . config ) ;
34+
3035app . listen ( PORT , HOST , ( ) => {
3136 console . log ( `🚀 Mock OpenAI API server started successfully!` ) ;
3237 console . log ( `📍 Server address: http://${ HOST } :${ PORT } ` ) ;
3338 console . log ( `⚙️ Configuration:` ) ;
3439 console . log ( ` • Port: ${ PORT } ` ) ;
3540 console . log ( ` • Host: ${ HOST } ` ) ;
3641 console . log ( ` • Verbose logging: ${ options . verbose ? 'ENABLED' : 'DISABLED' } ` ) ;
42+ console . log ( ` • Config file: ${ options . config } ` ) ;
3743 console . log ( ` • Version: ${ version } ` ) ;
3844 console . log ( `📖 API Documentation:` ) ;
3945 console . log ( ` • GET /health - Health check` ) ;
@@ -47,27 +53,28 @@ app.listen(PORT, HOST, () => {
4753 console . log ( ` • POST /v1beta/models/{model}:streamGenerateContent - Gemini streaming generation` ) ;
4854 console . log ( `\n✨ Available models:` ) ;
4955 console . log ( ` OpenAI Compatible:` ) ;
50- console . log ( ` - mock-gpt-thinking: Model supporting thought process` ) ;
51- console . log ( ` - gpt-4-mock: Model supporting function calls` ) ;
52- console . log ( ` - mock-gpt-markdown: Model outputting standard Markdown` ) ;
53- console . log ( ` - gpt-4o-image: Model specifically for image generation` ) ;
56+ console . log ( ` - ${ getMappedModelName ( ' mock-gpt-thinking' ) } : Model supporting thought process` ) ;
57+ console . log ( ` - ${ getMappedModelName ( ' gpt-4-mock' ) } : Model supporting function calls` ) ;
58+ console . log ( ` - ${ getMappedModelName ( ' mock-gpt-markdown' ) } : Model outputting standard Markdown` ) ;
59+ console . log ( ` - ${ getMappedModelName ( ' gpt-4o-image' ) } : Model specifically for image generation` ) ;
5460 console . log ( ` Anthropic Compatible:` ) ;
55- console . log ( ` - mock-claude-markdown: Claude markdown sample model` ) ;
61+ console . log ( ` - ${ getMappedModelName ( ' mock-claude-markdown' ) } : Claude markdown sample model` ) ;
5662 console . log ( ` Gemini Compatible:` ) ;
57- console . log ( ` - gemini-1.5-pro: Advanced multimodal AI model` ) ;
58- console . log ( ` - gemini-1.5-flash: Fast and efficient model` ) ;
59- console . log ( ` - gemini-pro: Versatile model for various tasks` ) ;
60- console . log ( ` - gemini-pro-vision: Multimodal model for text and images` ) ;
63+ console . log ( ` - ${ getMappedModelName ( ' gemini-1.5-pro' ) } : Advanced multimodal AI model` ) ;
64+ console . log ( ` - ${ getMappedModelName ( ' gemini-1.5-flash' ) } : Fast and efficient model` ) ;
65+ console . log ( ` - ${ getMappedModelName ( ' gemini-pro' ) } : Versatile model for various tasks` ) ;
66+ console . log ( ` - ${ getMappedModelName ( ' gemini-pro-vision' ) } : Multimodal model for text and images` ) ;
6167 console . log ( `\n🔗 Usage example:` ) ;
6268 console . log ( ` curl -X POST http://localhost:${ PORT } /v1/chat/completions \\` ) ;
6369 console . log ( ` -H "Content-Type: application/json" \\` ) ;
6470 console . log ( ` -d '{` ) ;
65- console . log ( ` "model": "gpt-4-mock",` ) ;
71+ console . log ( ` "model": "${ getMappedModelName ( ' gpt-4-mock' ) } ",` ) ;
6672 console . log ( ` "messages": [{"role": "user", "content": "Hello"}]` ) ;
6773 console . log ( ` }'` ) ;
6874 console . log ( `\n💡 CLI Options:` ) ;
6975 console . log ( ` • Use --help to see all available options` ) ;
7076 console . log ( ` • Use -v or --verbose to enable request logging` ) ;
7177 console . log ( ` • Use -p <port> to specify custom port` ) ;
7278 console . log ( ` • Use -H <host> to specify custom host address` ) ;
79+ console . log ( ` • Use -c <path> to specify custom config file` ) ;
7380} ) ;
0 commit comments