还在用其他AI?不是说它不火了,而是你基本上很难访问了。这里介绍个便宜且免费的AI聊天插件,一样可以很棒。永久免费且不限制次数,有这好事?且听下文分解。
前言
虽然GPT 是用不了,推荐下国内的一些大模型,做的也相当不错了,至少可以追到GPT-3.5了。想体验人工智能AI的,可以试用下百度,科大讯飞等大模型。然而,这里要介绍的并不是这些。
BITO简介
Bito 是一个继Copilot
之后的又一款神级IDEA
代码辅助插件,感觉它可以超越Copilot,它的强大之处就是可以通过类似于GPT
对话的方式来编写代码,分析代码等,生成的代码可以复制以及直接插入,永久免费且不限制次数,用来会话搜索也是可以的。可以在vscode中直接搜索到这个插件并使用。最最关键的是它的注册流程很简单,而且免费。
插件介绍
虽然BITO插件很好用,但是想用它用在其他地方。所以还是更灵活方便些。分享给有需要的伙伴,欢迎点赞评论和收藏。完整项目代码上传到csdn了,可以接入公众号。
下载地址:https://download.csdn.net/download/qq8864/87921258
报文示例
报文请求:
POST https://bitoai.bito.ai/ai/v2/chat/?processSilently=true HTTP/1.1
content-type: application/json
sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="102"
authorization: 10086
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Code/1.75.1 Chrome/102.0.5005.194 Electron/19.1.9 Safari/537.36
sec-ch-ua-platform: "Windows"
accept: */*
origin: vscode-webview://00ufp6vep7ebihor39h3aap2cnc6j0ptg8638daeifr55n0kqpom{"bitoUserId": 10086,"email": "534117529@qq.com","ideName": "VSCODE","prompt": "今天的天气","uId": "bbbb-97ad-4885-897b-3df900fa82ce","wsId": 10086,"stream": false,"requestId": "aaaa-5e55-8959-fddc-aa9f0cf12b64"
}
应答:
HTTP/1.1 200 OK
Date: Sat, 17 Jun 2023 22:56:44 GMT
Content-Type: application/json; charset=UTF-8
Content-Length: 262
Connection: close
Access-Control-Allow-Origin: *
Vary: Origin{"response": "抱歉,作为AI语言模型,我没有实时获取天气信息的能力。请您打开天气预报应用或者网站查询当地天气情况。","status": 0,"created": "2023-06-17T22:56:44.054650024Z","id": "chatcmpl-7SM1ZH0yQ2Q4H9liMwCt0yOa9DTlD"
}
golang封装
https请求
func HttpsPostNotVerify(url string, headers map[string]string, data []byte) ([]byte, error) {tr := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true},}client := &http.Client{Transport: tr}log.Println("begin post...")req, err := http.NewRequest("POST", url, bytes.NewReader(data))if err != nil {// handle errorlog.Println("error..")log.Println(err)return nil, err}for key := range headers {fmt.Println(key, ":", headers[key])req.Header.Set(key, headers[key])}resp, err := client.Do(req)if err != nil {// handle errorlog.Println("error1..")log.Println(err)return nil, err}defer resp.Body.Close()var body []bytebody, err = ioutil.ReadAll(resp.Body)if err != nil {// handle errorlog.Println(err)return nil, err}//fmt.Println(string(body))//log.Printf(string(body))return body, nil//jsonStr := string(body)//fmt.Println("jsonStr", jsonStr)
}func ChatHttpsPost(url string, body []byte) ([]byte, error) {headers := make(map[string]string)headers["user-agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Code/1.75.1 Chrome/102.0.5005.194 Electron/19.1.9 Safari/537.36"headers["content-type"] = "application/json"headers["authorization"] = "xxxxxx"headers["accept"] = "*/*"headers["origin"] = "vscode-webview://00uxxxxxxxxqpom*"out, err := HttpsPostNotVerify(url, headers, body)if err != nil {//log.Info(sn + err)return nil, err}//log.Info(strout)return out, nil
}
chat封装
type RequestBITO struct{BitoUserId int `json:"bitoUserId"`Email string `json:"email"`IdeName string `json:"ideName"`Prompt string `json:"prompt"`UId string `json:"uId"`WsId int `json:"wsId"`Stream bool `json:"stream"`RequestId string `json:"requestId"`}func AskChatBITO(question string) string{fmt.Printf("\033[31mAsk chatBITO,\033[0m question:%s\n", question)begin := time.Now()request := RequestBITO{BitoUserId: xxxxxx,Email: "5xxxxxx@qq.com",IdeName: "VSCODE",Prompt: question,UId: "xxxxx-97ad-4885-897b-xxxx82ce",WsId: xxxxx,Stream: false,RequestId: "xxxx-5e55-8959-fddc-xxxx12b64",}req, _ := json.Marshal(request)//将json对象序列化为byte[]fmt.Printf("req:%s\n", string(req))response, err := util.ChatHttpsPost(CHATBITOURL, req)elapsed := time.Since(begin)//fmt.Println(response, err)if err != nil {fmt.Printf("\033[31mError:\033[0m %v\nTime: ", err,elapsed)return ""}else{fmt.Printf("Answer:%s\n\033[32mTime:\033[0m %v\n\n", string(response),elapsed)return string(response)}
}
测试验证
可以看到响应速度还挺快,总共耗时1.9秒,不限速度不限次数。
其他资源
Bito - 超越Copilot的一款神级插件_杨林伟的博客-CSDN博客
福音:IDEA、VSCODE神级插件Bito_靈熙雲的博客-CSDN博客