package llm import ( "errors" ) var ( llmInstanceMap = make(map[string]LLMService) ) const ( ETA_LLM_CLIENT = "eta_llm" ) func Register(name string, llmClient LLMService) (err error) { if name == "" { err = errors.New("模型实例名不能为空") return } if _, ok := llmInstanceMap[name]; ok { err = errors.New("模型实例已经存在") return } llmInstanceMap[name] = llmClient return } func GetInstance(name string) (llmClient LLMService, err error) { if name == "" { err = errors.New("模型实例名不能为空") return } if _, ok := llmInstanceMap[name]; !ok { err = errors.New("当前模型类型不支持") return } llmClient = llmInstanceMap[name] return }