package l_ai_address import ( "context" "gitea.cdlsxd.cn/self-tools/l_ai_address/ai/doubao" "strings" ) type Address struct { P string C string D string } func GetAddress(ctx context.Context, address, key, model string) (Address, error) { modelObj := doubao.NewDouBao(model, key) text := []string{ "解析省市区地址[QUESTION]" + address + "[/QUESTION]", "-根据国家统计局的地址信息 帮我匹配出对应的省市区信息,如果是直辖县级行政区,直接按照区来处理,然后市一级显示上级代管市", "-只需要给出省市区具体名称,不需要解释", "-省市区之间用\",\"隔开", } res, err := modelObj.GetData(ctx, doubao.Text, func(input string) (string, error) { return input, nil }, text...) if err != nil { return Address{}, err } resSlice := strings.Split(res, ",") return Address{P: resSlice[0], C: resSlice[1], D: resSlice[2]}, nil }