| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| package main |
|
|
| import ( |
| "encoding/json" |
| "fmt" |
| "log" |
|
|
| "veloera/model" |
| "veloera/service" |
| ) |
|
|
| func main() { |
| |
| if err := service.InitializeModelMappingService(); err != nil { |
| log.Fatalf("Failed to initialize model mapping service: %v", err) |
| } |
|
|
| |
| exampleMapping := &model.GlobalModelMapping{ |
| Mapping: map[string][]model.ModelMappingItem{ |
| "gpt-3.5-turbo": { |
| {Model: "gpt-3.5-turbo-0613", Priorities: 10}, |
| {Model: "gpt-3.5-turbo-0301", Priorities: 10}, |
| {Model: "gpt-3.5-turbo-16k", Priorities: 5}, |
| }, |
| "gpt-4": { |
| {Model: "gpt-4-0613", Priorities: 10}, |
| {Model: "gpt-4-0314", Priorities: 8}, |
| }, |
| "claude-instant": { |
| {Model: "claude-instant-1.2", Priorities: 10}, |
| {Model: "claude-instant-1.1", Priorities: 5}, |
| }, |
| }, |
| } |
|
|
| |
| if err := service.UpdateGlobalModelMapping(exampleMapping); err != nil { |
| log.Fatalf("Failed to update global model mapping: %v", err) |
| } |
|
|
| |
| testModels := []string{"gpt-3.5-turbo", "gpt-4", "claude-instant", "non-existent-model"} |
|
|
| fmt.Println("模型映射测试:") |
| for _, virtualModel := range testModels { |
| actualModel, err := service.GetActualModel(virtualModel) |
| if err != nil { |
| log.Printf("Error getting actual model for %s: %v", virtualModel, err) |
| continue |
| } |
| fmt.Printf("虚拟模型: %-20s -> 实际模型: %s\n", virtualModel, actualModel) |
| } |
|
|
| |
| currentConfig := service.GetGlobalModelMapping() |
| fmt.Println("\n当前全局模型映射配置:") |
| jsonData, _ := json.MarshalIndent(currentConfig, "", " ") |
| fmt.Println(string(jsonData)) |
|
|
| |
| if err := service.ReloadModelMapping(); err != nil { |
| log.Printf("Failed to reload model mapping: %v", err) |
| } else { |
| fmt.Println("\n配置重新加载成功") |
| } |
| } |