diff --git a/README.md b/README.md index 39246bdd..d1271758 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ Play ChatGPT and other LLM with Xiaomi AI Speaker ## 获取小米音响DID -| 系统和Shell | Linux *sh | Windows CMD用户 | Windows PowerShell用户 | -|------------|------------------------------------------------|----------------------------------------|------------------------------------------------| +| 系统和Shell | Linux *sh | Windows CMD用户 | Windows PowerShell用户 | +| ------------- | ---------------------------------------------- | -------------------------------------- | ---------------------------------------------- | | 1、安装包 | `pip install miservice_fork` | `pip install miservice_fork` | `pip install miservice_fork` | | 2、设置变量 | `export MI_USER=xxx`
`export MI_PASS=xxx` | `set MI_USER=xxx`
`set MI_PASS=xxx` | `$env:MI_USER="xxx"`
`$env:MI_PASS="xxx"` | | 3、取得MI_DID | `micli list` | `micli list` | `micli list` | @@ -135,36 +135,32 @@ export SERPAPI_API_KEY=${your_serpapi_key} python3 xiaogpt.py --hardware Lx06 --use_langchain --mute_xiaoai --stream --openai_key ${your_api_key} --serpapi_api_key ${your_serpapi_key} ``` -## config.json +## config.yaml -如果想通过单一配置文件启动也是可以的, 可以通过 `--config` 参数指定配置文件, config 文件必须是合法的 JSON 格式 +如果想通过单一配置文件启动也是可以的, 可以通过 `--config` 参数指定配置文件, config 文件必须是合法的 Yaml 或 JSON 格式 参数优先级 - cli args > default > config ```shell -python3 xiaogpt.py --config xiao_config.json +python3 xiaogpt.py --config xiao_config.yaml # or -xiaogpt --config xiao_config.json +xiaogpt --config xiao_config.yaml ``` 或者 ```shell -cp xiao_config.json.example xiao_config.json +cp xiao_config.yaml.example xiao_config.yaml python3 xiaogpt.py ``` -若要指定 OpenAI 的模型参数,如 model, temporature, top_p, 请在config.json中指定: +若要指定 OpenAI 的模型参数,如 model, temporature, top_p, 请在 config.yaml 中指定: -```json -{ - ... - "gpt_options": { - "temperature": 0.9, - "top_p": 0.9, - } -} +```yaml +gpt_options: + temperature: 0.9 + top_p: 0.9 ``` 具体参数作用请参考 [Open AI API 文档](https://platform.openai.com/docs/api-reference/chat/create)。 @@ -172,43 +168,40 @@ ChatGLM [文档](http://open.bigmodel.cn/doc/api#chatglm_130b) ## 配置项说明 -| 参数 | 说明 | 默认值 | 可选值 | -|------------------|-----------------------------------------------------------------------------------------------------------|--------|--------| -| hardware | 设备型号 | | | -| account | 小爱账户 | | | -| password | 小爱账户密码 | | | -| openai_key | openai的apikey | | | -| moonshot_api_key | moonshot kimi 的 [apikey](https://platform.moonshot.cn/docs/api/chat#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B) | | | -| yi_api_key | 01 wanwu 的 [apikey](https://platform.lingyiwanwu.com/apikeys) | | | -| llama_api_key | groq 的 llama3 [apikey](https://console.groq.com/docs/quickstart) | | | -| serpapi_api_key | serpapi的key 参考 [SerpAPI](https://serpapi.com/) | | | -| glm_key | chatglm 的 apikey | | | -| gemini_key | gemini 的 apikey [参考](https://makersuite.google.com/app/apikey) | | | -| gemini_api_domain | gemini 的自定义域名 [参考](https://github.com/antergone/palm-netlify-proxy) | | -| qwen_key | qwen 的 apikey [参考](https://help.aliyun.com/zh/dashscope/developer-reference/api-details) | | | -| cookie | 小爱账户cookie (如果用上面密码登录可以不填) | | | -| mi_did | 设备did | | | -| use_command | 使用 MI command 与小爱交互 | `false` | | -| mute_xiaoai | 快速停掉小爱自己的回答 | `true` | | -| verbose | 是否打印详细日志 | `false` | | -| bot | 使用的 bot 类型,目前支持 chatgptapi,newbing, qwen, gemini | `chatgptapi` | | -| tts | 使用的 TTS 类型 | `mi` | `edge`、 `openai`、`azure`、`volc`、`baidu`、`google`、`minimax` | -| tts_options | TTS 参数字典,参考 [tetos](https://github.com/frostming/tetos) 获取可用参数 | | | -| prompt | 自定义prompt | `请用100字以内回答` | | -| keyword | 自定义请求词列表 | `["请"]` | | -| change_prompt_keyword | 更改提示词触发列表 | `["更改提示词"]` | | -| start_conversation | 开始持续对话关键词 | `开始持续对话` | | -| end_conversation | 结束持续对话关键词 | `结束持续对话` | | -| stream | 使用流式响应,获得更快的响应 | `false` | | -| proxy | 支持 HTTP 代理,传入 http proxy URL | "" | | -| gpt_options | OpenAI API 的参数字典 | `{}` | | -| bing_cookie_path | NewBing使用的cookie路径,参考[这里]获取 | 也可通过环境变量 `COOKIE_FILE` 设置 | | -| bing_cookies | NewBing使用的cookie字典,参考[这里]获取 | | | -| deployment_id | Azure OpenAI 服务的 deployment ID | 参考这个[如何找到deployment_id](https://github.com/yihong0618/xiaogpt/issues/347#issuecomment-1784410784) | | -| api_base | 如果需要替换默认的api,或者使用Azure OpenAI 服务 | 例如:`https://abc-def.openai.azure.com/` | -| volc_access_key | 火山引擎的 access key 请在[这里](https://console.volcengine.com/iam/keymanage/)获取 | | | -| volc_secret_key | 火山引擎的 secret key 请在[这里](https://console.volcengine.com/iam/keymanage/)获取 | | | -[这里]: +| 参数 | 说明 | 默认值 | 可选值 | +| --------------------- | ---------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | +| hardware | 设备型号 | | | +| account | 小爱账户 | | | +| password | 小爱账户密码 | | | +| openai_key | openai的apikey | | | +| moonshot_api_key | moonshot kimi 的 [apikey](https://platform.moonshot.cn/docs/api/chat#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B) | | | +| yi_api_key | 01 wanwu 的 [apikey](https://platform.lingyiwanwu.com/apikeys) | | | +| llama_api_key | groq 的 llama3 [apikey](https://console.groq.com/docs/quickstart) | | | +| serpapi_api_key | serpapi的key 参考 [SerpAPI](https://serpapi.com/) | | | +| glm_key | chatglm 的 apikey | | | +| gemini_key | gemini 的 apikey [参考](https://makersuite.google.com/app/apikey) | | | +| gemini_api_domain | gemini 的自定义域名 [参考](https://github.com/antergone/palm-netlify-proxy) | | +| qwen_key | qwen 的 apikey [参考](https://help.aliyun.com/zh/dashscope/developer-reference/api-details) | | | +| cookie | 小爱账户cookie (如果用上面密码登录可以不填) | | | +| mi_did | 设备did | | | +| use_command | 使用 MI command 与小爱交互 | `false` | | +| mute_xiaoai | 快速停掉小爱自己的回答 | `true` | | +| verbose | 是否打印详细日志 | `false` | | +| bot | 使用的 bot 类型,目前支持 chatgptapi,newbing, qwen, gemini | `chatgptapi` | | +| tts | 使用的 TTS 类型 | `mi` | `edge`、 `openai`、`azure`、`volc`、`baidu`、`google`、`minimax` | +| tts_options | TTS 参数字典,参考 [tetos](https://github.com/frostming/tetos) 获取可用参数 | | | +| prompt | 自定义prompt | `请用100字以内回答` | | +| keyword | 自定义请求词列表 | `["请"]` | | +| change_prompt_keyword | 更改提示词触发列表 | `["更改提示词"]` | | +| start_conversation | 开始持续对话关键词 | `开始持续对话` | | +| end_conversation | 结束持续对话关键词 | `结束持续对话` | | +| stream | 使用流式响应,获得更快的响应 | `true` | | +| proxy | 支持 HTTP 代理,传入 http proxy URL | "" | | +| gpt_options | OpenAI API 的参数字典 | `{}` | | +| deployment_id | Azure OpenAI 服务的 deployment ID | 参考这个[如何找到deployment_id](https://github.com/yihong0618/xiaogpt/issues/347#issuecomment-1784410784) | | +| api_base | 如果需要替换默认的api,或者使用Azure OpenAI 服务 | 例如:`https://abc-def.openai.azure.com/` | +| volc_access_key | 火山引擎的 access key 请在[这里](https://console.volcengine.com/iam/keymanage/)获取 | | | +| volc_secret_key | 火山引擎的 secret key 请在[这里](https://console.volcengine.com/iam/keymanage/)获取 | | ## 注意 @@ -254,13 +247,13 @@ docker run -e OPENAI_API_KEY= yihong0618/xiaogpt --account=:/config yihong0618/xiaogpt --config=/config/config.json +docker run -v :/config yihong0618/xiaogpt --config=/config/config.yaml ``` ### 网络使用 host 模型 ```shell -docker run -v :/config --network=host yihong0618/xiaogpt --config=/config/config.json +docker run -v :/config --network=host yihong0618/xiaogpt --config=/config/config.yaml ``` ### 本地编译Docker Image @@ -293,10 +286,8 @@ docker build --build-arg PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple 你可以通过参数 `tts`, 来启用它 -```json -{ - "tts": "edge", -} +```yaml +tts: edge ``` For edge 查看更多语言支持, 从中选择一个 @@ -310,7 +301,7 @@ edge-tts --list-voices 由于 Edge TTS 启动了一个本地的 HTTP 服务,所以需要将容器的端口映射到宿主机上,并且指定本地机器的 hostname: ```shell -docker run -v :/config -p 9527:9527 -e XIAOGPT_HOSTNAME= yihong0618/xiaogpt --config=/config/config.json +docker run -v :/config -p 9527:9527 -e XIAOGPT_HOSTNAME= yihong0618/xiaogpt --config=/config/config.yaml ``` 注意端口必须映射为与容器内一致,XIAOGPT_HOSTNAME 需要设置为宿主机的 IP 地址,否则小爱无法正常播放语音。 diff --git a/pdm.lock b/pdm.lock index c3efe54e..1ef2bf57 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default"] strategy = ["cross_platform", "inherit_metadata"] lock_version = "4.4.1" -content_hash = "sha256:f64eb5f3bc8c63e65740d39b5cdc792037f75af9ef3c490866af5716d222ea17" +content_hash = "sha256:b13a77de5418a6e7d7f394841654581ba5c15814ff5588ccefef1df3fab51353" [[package]] name = "aiohttp" @@ -179,21 +179,6 @@ files = [ {file = "beautifulsoup4-4.12.3.tar.gz", hash = "sha256:74e3d1928edc070d21748185c46e3fb33490f22f52a3addee9aee0f4f7781051"}, ] -[[package]] -name = "bingimagecreator" -version = "0.5.0" -summary = "High quality image generation by Microsoft. Reverse engineered API." -groups = ["default"] -dependencies = [ - "httpx", - "regex", - "requests", -] -files = [ - {file = "BingImageCreator-0.5.0-py3-none-any.whl", hash = "sha256:9822e07ec32f79a88d4a0db59e85dfed46477cfe706d534c2bd813f1c92120e0"}, - {file = "BingImageCreator-0.5.0.tar.gz", hash = "sha256:e15798b7c0394145b334d0b3bef4aad187d5e7e0c3f7b6d949e413fe11b5ea47"}, -] - [[package]] name = "cachetools" version = "5.3.2" @@ -368,25 +353,6 @@ files = [ {file = "edge_tts-6.1.10-py3-none-any.whl", hash = "sha256:e7a4bceea8f797498b9be1216a1448a0ce1c2ba832991a16ced4e5e7399e3e0a"}, ] -[[package]] -name = "edgegpt" -version = "0.1.26" -summary = "Reverse engineered Edge Chat API" -groups = ["default"] -dependencies = [ - "BingImageCreator>=0.1.1.1", - "certifi", - "httpx", - "prompt-toolkit", - "requests", - "rich", - "websockets", -] -files = [ - {file = "EdgeGPT-0.1.26-py3-none-any.whl", hash = "sha256:496891260f0242b5507baaf5ba150badac49d7bb1722f1a38668411f84969900"}, - {file = "EdgeGPT-0.1.26.tar.gz", hash = "sha256:39fef9ccfa82f4c3351e33c4c9260e118a624ee23ebc85cf313a9a602e3bdf3d"}, -] - [[package]] name = "exceptiongroup" version = "1.2.0" @@ -1287,20 +1253,6 @@ files = [ {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, ] -[[package]] -name = "prompt-toolkit" -version = "3.0.43" -requires_python = ">=3.7.0" -summary = "Library for building powerful interactive command lines in Python" -groups = ["default"] -dependencies = [ - "wcwidth", -] -files = [ - {file = "prompt_toolkit-3.0.43-py3-none-any.whl", hash = "sha256:a11a29cb3bf0a28a387fe5122cdb649816a957cd9261dcedf8c9f1fef33eacf6"}, - {file = "prompt_toolkit-3.0.43.tar.gz", hash = "sha256:3527b7af26106cbc65a040bcc84839a3566ec1b051bb0bfe953631e704b0ff7d"}, -] - [[package]] name = "proto-plus" version = "1.23.0" @@ -1526,6 +1478,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -1541,78 +1494,6 @@ files = [ {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, ] -[[package]] -name = "regex" -version = "2023.12.25" -requires_python = ">=3.7" -summary = "Alternative regular expression module, to replace re." -groups = ["default"] -files = [ - {file = "regex-2023.12.25-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:0694219a1d54336fd0445ea382d49d36882415c0134ee1e8332afd1529f0baa5"}, - {file = "regex-2023.12.25-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b014333bd0217ad3d54c143de9d4b9a3ca1c5a29a6d0d554952ea071cff0f1f8"}, - {file = "regex-2023.12.25-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d865984b3f71f6d0af64d0d88f5733521698f6c16f445bb09ce746c92c97c586"}, - {file = "regex-2023.12.25-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1e0eabac536b4cc7f57a5f3d095bfa557860ab912f25965e08fe1545e2ed8b4c"}, - {file = "regex-2023.12.25-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c25a8ad70e716f96e13a637802813f65d8a6760ef48672aa3502f4c24ea8b400"}, - {file = "regex-2023.12.25-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a9b6d73353f777630626f403b0652055ebfe8ff142a44ec2cf18ae470395766e"}, - {file = "regex-2023.12.25-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a9cc99d6946d750eb75827cb53c4371b8b0fe89c733a94b1573c9dd16ea6c9e4"}, - {file = "regex-2023.12.25-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:88d1f7bef20c721359d8675f7d9f8e414ec5003d8f642fdfd8087777ff7f94b5"}, - {file = "regex-2023.12.25-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:cb3fe77aec8f1995611f966d0c656fdce398317f850d0e6e7aebdfe61f40e1cd"}, - {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:7aa47c2e9ea33a4a2a05f40fcd3ea36d73853a2aae7b4feab6fc85f8bf2c9704"}, - {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:df26481f0c7a3f8739fecb3e81bc9da3fcfae34d6c094563b9d4670b047312e1"}, - {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:c40281f7d70baf6e0db0c2f7472b31609f5bc2748fe7275ea65a0b4601d9b392"}, - {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:d94a1db462d5690ebf6ae86d11c5e420042b9898af5dcf278bd97d6bda065423"}, - {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:ba1b30765a55acf15dce3f364e4928b80858fa8f979ad41f862358939bdd1f2f"}, - {file = "regex-2023.12.25-cp310-cp310-win32.whl", hash = "sha256:150c39f5b964e4d7dba46a7962a088fbc91f06e606f023ce57bb347a3b2d4630"}, - {file = "regex-2023.12.25-cp310-cp310-win_amd64.whl", hash = "sha256:09da66917262d9481c719599116c7dc0c321ffcec4b1f510c4f8a066f8768105"}, - {file = "regex-2023.12.25-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:1b9d811f72210fa9306aeb88385b8f8bcef0dfbf3873410413c00aa94c56c2b6"}, - {file = "regex-2023.12.25-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:d902a43085a308cef32c0d3aea962524b725403fd9373dea18110904003bac97"}, - {file = "regex-2023.12.25-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d166eafc19f4718df38887b2bbe1467a4f74a9830e8605089ea7a30dd4da8887"}, - {file = "regex-2023.12.25-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c7ad32824b7f02bb3c9f80306d405a1d9b7bb89362d68b3c5a9be53836caebdb"}, - {file = "regex-2023.12.25-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:636ba0a77de609d6510235b7f0e77ec494d2657108f777e8765efc060094c98c"}, - {file = "regex-2023.12.25-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0fda75704357805eb953a3ee15a2b240694a9a514548cd49b3c5124b4e2ad01b"}, - {file = "regex-2023.12.25-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f72cbae7f6b01591f90814250e636065850c5926751af02bb48da94dfced7baa"}, - {file = "regex-2023.12.25-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:db2a0b1857f18b11e3b0e54ddfefc96af46b0896fb678c85f63fb8c37518b3e7"}, - {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:7502534e55c7c36c0978c91ba6f61703faf7ce733715ca48f499d3dbbd7657e0"}, - {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:e8c7e08bb566de4faaf11984af13f6bcf6a08f327b13631d41d62592681d24fe"}, - {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:283fc8eed679758de38fe493b7d7d84a198b558942b03f017b1f94dda8efae80"}, - {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:f44dd4d68697559d007462b0a3a1d9acd61d97072b71f6d1968daef26bc744bd"}, - {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:67d3ccfc590e5e7197750fcb3a2915b416a53e2de847a728cfa60141054123d4"}, - {file = "regex-2023.12.25-cp311-cp311-win32.whl", hash = "sha256:68191f80a9bad283432385961d9efe09d783bcd36ed35a60fb1ff3f1ec2efe87"}, - {file = "regex-2023.12.25-cp311-cp311-win_amd64.whl", hash = "sha256:7d2af3f6b8419661a0c421584cfe8aaec1c0e435ce7e47ee2a97e344b98f794f"}, - {file = "regex-2023.12.25-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:8a0ccf52bb37d1a700375a6b395bff5dd15c50acb745f7db30415bae3c2b0715"}, - {file = "regex-2023.12.25-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:c3c4a78615b7762740531c27cf46e2f388d8d727d0c0c739e72048beb26c8a9d"}, - {file = "regex-2023.12.25-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ad83e7545b4ab69216cef4cc47e344d19622e28aabec61574b20257c65466d6a"}, - {file = "regex-2023.12.25-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b7a635871143661feccce3979e1727c4e094f2bdfd3ec4b90dfd4f16f571a87a"}, - {file = "regex-2023.12.25-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d498eea3f581fbe1b34b59c697512a8baef88212f92e4c7830fcc1499f5b45a5"}, - {file = "regex-2023.12.25-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:43f7cd5754d02a56ae4ebb91b33461dc67be8e3e0153f593c509e21d219c5060"}, - {file = "regex-2023.12.25-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:51f4b32f793812714fd5307222a7f77e739b9bc566dc94a18126aba3b92b98a3"}, - {file = "regex-2023.12.25-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ba99d8077424501b9616b43a2d208095746fb1284fc5ba490139651f971d39d9"}, - {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:4bfc2b16e3ba8850e0e262467275dd4d62f0d045e0e9eda2bc65078c0110a11f"}, - {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:8c2c19dae8a3eb0ea45a8448356ed561be843b13cbc34b840922ddf565498c1c"}, - {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:60080bb3d8617d96f0fb7e19796384cc2467447ef1c491694850ebd3670bc457"}, - {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:b77e27b79448e34c2c51c09836033056a0547aa360c45eeeb67803da7b0eedaf"}, - {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:518440c991f514331f4850a63560321f833979d145d7d81186dbe2f19e27ae3d"}, - {file = "regex-2023.12.25-cp312-cp312-win32.whl", hash = "sha256:e2610e9406d3b0073636a3a2e80db05a02f0c3169b5632022b4e81c0364bcda5"}, - {file = "regex-2023.12.25-cp312-cp312-win_amd64.whl", hash = "sha256:cc37b9aeebab425f11f27e5e9e6cf580be7206c6582a64467a14dda211abc232"}, - {file = "regex-2023.12.25-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:f7bc09bc9c29ebead055bcba136a67378f03d66bf359e87d0f7c759d6d4ffa31"}, - {file = "regex-2023.12.25-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:e14b73607d6231f3cc4622809c196b540a6a44e903bcfad940779c80dffa7be7"}, - {file = "regex-2023.12.25-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:9eda5f7a50141291beda3edd00abc2d4a5b16c29c92daf8d5bd76934150f3edc"}, - {file = "regex-2023.12.25-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc6bb9aa69aacf0f6032c307da718f61a40cf970849e471254e0e91c56ffca95"}, - {file = "regex-2023.12.25-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:298dc6354d414bc921581be85695d18912bea163a8b23cac9a2562bbcd5088b1"}, - {file = "regex-2023.12.25-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2f4e475a80ecbd15896a976aa0b386c5525d0ed34d5c600b6d3ebac0a67c7ddf"}, - {file = "regex-2023.12.25-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:531ac6cf22b53e0696f8e1d56ce2396311254eb806111ddd3922c9d937151dae"}, - {file = "regex-2023.12.25-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:22f3470f7524b6da61e2020672df2f3063676aff444db1daa283c2ea4ed259d6"}, - {file = "regex-2023.12.25-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:89723d2112697feaa320c9d351e5f5e7b841e83f8b143dba8e2d2b5f04e10923"}, - {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0ecf44ddf9171cd7566ef1768047f6e66975788258b1c6c6ca78098b95cf9a3d"}, - {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:905466ad1702ed4acfd67a902af50b8db1feeb9781436372261808df7a2a7bca"}, - {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:4558410b7a5607a645e9804a3e9dd509af12fb72b9825b13791a37cd417d73a5"}, - {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:7e316026cc1095f2a3e8cc012822c99f413b702eaa2ca5408a513609488cb62f"}, - {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:3b1de218d5375cd6ac4b5493e0b9f3df2be331e86520f23382f216c137913d20"}, - {file = "regex-2023.12.25-cp39-cp39-win32.whl", hash = "sha256:11a963f8e25ab5c61348d090bf1b07f1953929c13bd2309a0662e9ff680763c9"}, - {file = "regex-2023.12.25-cp39-cp39-win_amd64.whl", hash = "sha256:e693e233ac92ba83a87024e1d32b5f9ab15ca55ddd916d878146f4e3406b5c91"}, - {file = "regex-2023.12.25.tar.gz", hash = "sha256:29171aa128da69afdf4bde412d5bedc335f2ca8fcfe4489038577d05f16181e5"}, -] - [[package]] name = "requests" version = "2.31.0" @@ -1831,86 +1712,6 @@ files = [ {file = "urllib3-2.1.0.tar.gz", hash = "sha256:df7aa8afb0148fa78488e7899b2c59b5f4ffcfa82e6c54ccb9dd37c1d7b52d54"}, ] -[[package]] -name = "wcwidth" -version = "0.2.13" -summary = "Measures the displayed width of unicode strings in a terminal" -groups = ["default"] -files = [ - {file = "wcwidth-0.2.13-py2.py3-none-any.whl", hash = "sha256:3da69048e4540d84af32131829ff948f1e022c1c6bdb8d6102117aac784f6859"}, - {file = "wcwidth-0.2.13.tar.gz", hash = "sha256:72ea0c06399eb286d978fdedb6923a9eb47e1c486ce63e9b4e64fc18303972b5"}, -] - -[[package]] -name = "websockets" -version = "12.0" -requires_python = ">=3.8" -summary = "An implementation of the WebSocket Protocol (RFC 6455 & 7692)" -groups = ["default"] -files = [ - {file = "websockets-12.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d554236b2a2006e0ce16315c16eaa0d628dab009c33b63ea03f41c6107958374"}, - {file = "websockets-12.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:2d225bb6886591b1746b17c0573e29804619c8f755b5598d875bb4235ea639be"}, - {file = "websockets-12.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:eb809e816916a3b210bed3c82fb88eaf16e8afcf9c115ebb2bacede1797d2547"}, - {file = "websockets-12.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c588f6abc13f78a67044c6b1273a99e1cf31038ad51815b3b016ce699f0d75c2"}, - {file = "websockets-12.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5aa9348186d79a5f232115ed3fa9020eab66d6c3437d72f9d2c8ac0c6858c558"}, - {file = "websockets-12.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6350b14a40c95ddd53e775dbdbbbc59b124a5c8ecd6fbb09c2e52029f7a9f480"}, - {file = "websockets-12.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:70ec754cc2a769bcd218ed8d7209055667b30860ffecb8633a834dde27d6307c"}, - {file = "websockets-12.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:6e96f5ed1b83a8ddb07909b45bd94833b0710f738115751cdaa9da1fb0cb66e8"}, - {file = "websockets-12.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4d87be612cbef86f994178d5186add3d94e9f31cc3cb499a0482b866ec477603"}, - {file = "websockets-12.0-cp310-cp310-win32.whl", hash = "sha256:befe90632d66caaf72e8b2ed4d7f02b348913813c8b0a32fae1cc5fe3730902f"}, - {file = "websockets-12.0-cp310-cp310-win_amd64.whl", hash = "sha256:363f57ca8bc8576195d0540c648aa58ac18cf85b76ad5202b9f976918f4219cf"}, - {file = "websockets-12.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:5d873c7de42dea355d73f170be0f23788cf3fa9f7bed718fd2830eefedce01b4"}, - {file = "websockets-12.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3f61726cae9f65b872502ff3c1496abc93ffbe31b278455c418492016e2afc8f"}, - {file = "websockets-12.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ed2fcf7a07334c77fc8a230755c2209223a7cc44fc27597729b8ef5425aa61a3"}, - {file = "websockets-12.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8e332c210b14b57904869ca9f9bf4ca32f5427a03eeb625da9b616c85a3a506c"}, - {file = "websockets-12.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5693ef74233122f8ebab026817b1b37fe25c411ecfca084b29bc7d6efc548f45"}, - {file = "websockets-12.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6e9e7db18b4539a29cc5ad8c8b252738a30e2b13f033c2d6e9d0549b45841c04"}, - {file = "websockets-12.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:6e2df67b8014767d0f785baa98393725739287684b9f8d8a1001eb2839031447"}, - {file = "websockets-12.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:bea88d71630c5900690fcb03161ab18f8f244805c59e2e0dc4ffadae0a7ee0ca"}, - {file = "websockets-12.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:dff6cdf35e31d1315790149fee351f9e52978130cef6c87c4b6c9b3baf78bc53"}, - {file = "websockets-12.0-cp311-cp311-win32.whl", hash = "sha256:3e3aa8c468af01d70332a382350ee95f6986db479ce7af14d5e81ec52aa2b402"}, - {file = "websockets-12.0-cp311-cp311-win_amd64.whl", hash = "sha256:25eb766c8ad27da0f79420b2af4b85d29914ba0edf69f547cc4f06ca6f1d403b"}, - {file = "websockets-12.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:0e6e2711d5a8e6e482cacb927a49a3d432345dfe7dea8ace7b5790df5932e4df"}, - {file = "websockets-12.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:dbcf72a37f0b3316e993e13ecf32f10c0e1259c28ffd0a85cee26e8549595fbc"}, - {file = "websockets-12.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:12743ab88ab2af1d17dd4acb4645677cb7063ef4db93abffbf164218a5d54c6b"}, - {file = "websockets-12.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7b645f491f3c48d3f8a00d1fce07445fab7347fec54a3e65f0725d730d5b99cb"}, - {file = "websockets-12.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9893d1aa45a7f8b3bc4510f6ccf8db8c3b62120917af15e3de247f0780294b92"}, - {file = "websockets-12.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1f38a7b376117ef7aff996e737583172bdf535932c9ca021746573bce40165ed"}, - {file = "websockets-12.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:f764ba54e33daf20e167915edc443b6f88956f37fb606449b4a5b10ba42235a5"}, - {file = "websockets-12.0-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:1e4b3f8ea6a9cfa8be8484c9221ec0257508e3a1ec43c36acdefb2a9c3b00aa2"}, - {file = "websockets-12.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:9fdf06fd06c32205a07e47328ab49c40fc1407cdec801d698a7c41167ea45113"}, - {file = "websockets-12.0-cp312-cp312-win32.whl", hash = "sha256:baa386875b70cbd81798fa9f71be689c1bf484f65fd6fb08d051a0ee4e79924d"}, - {file = "websockets-12.0-cp312-cp312-win_amd64.whl", hash = "sha256:ae0a5da8f35a5be197f328d4727dbcfafa53d1824fac3d96cdd3a642fe09394f"}, - {file = "websockets-12.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:ab3d732ad50a4fbd04a4490ef08acd0517b6ae6b77eb967251f4c263011a990d"}, - {file = "websockets-12.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:a1d9697f3337a89691e3bd8dc56dea45a6f6d975f92e7d5f773bc715c15dde28"}, - {file = "websockets-12.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:1df2fbd2c8a98d38a66f5238484405b8d1d16f929bb7a33ed73e4801222a6f53"}, - {file = "websockets-12.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:23509452b3bc38e3a057382c2e941d5ac2e01e251acce7adc74011d7d8de434c"}, - {file = "websockets-12.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2e5fc14ec6ea568200ea4ef46545073da81900a2b67b3e666f04adf53ad452ec"}, - {file = "websockets-12.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:46e71dbbd12850224243f5d2aeec90f0aaa0f2dde5aeeb8fc8df21e04d99eff9"}, - {file = "websockets-12.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b81f90dcc6c85a9b7f29873beb56c94c85d6f0dac2ea8b60d995bd18bf3e2aae"}, - {file = "websockets-12.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:a02413bc474feda2849c59ed2dfb2cddb4cd3d2f03a2fedec51d6e959d9b608b"}, - {file = "websockets-12.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:bbe6013f9f791944ed31ca08b077e26249309639313fff132bfbf3ba105673b9"}, - {file = "websockets-12.0-cp39-cp39-win32.whl", hash = "sha256:cbe83a6bbdf207ff0541de01e11904827540aa069293696dd528a6640bd6a5f6"}, - {file = "websockets-12.0-cp39-cp39-win_amd64.whl", hash = "sha256:fc4e7fa5414512b481a2483775a8e8be7803a35b30ca805afa4998a84f9fd9e8"}, - {file = "websockets-12.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:248d8e2446e13c1d4326e0a6a4e9629cb13a11195051a73acf414812700badbd"}, - {file = "websockets-12.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f44069528d45a933997a6fef143030d8ca8042f0dfaad753e2906398290e2870"}, - {file = "websockets-12.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c4e37d36f0d19f0a4413d3e18c0d03d0c268ada2061868c1e6f5ab1a6d575077"}, - {file = "websockets-12.0-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3d829f975fc2e527a3ef2f9c8f25e553eb7bc779c6665e8e1d52aa22800bb38b"}, - {file = "websockets-12.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:2c71bd45a777433dd9113847af751aae36e448bc6b8c361a566cb043eda6ec30"}, - {file = "websockets-12.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:0bee75f400895aef54157b36ed6d3b308fcab62e5260703add87f44cee9c82a6"}, - {file = "websockets-12.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:423fc1ed29f7512fceb727e2d2aecb952c46aa34895e9ed96071821309951123"}, - {file = "websockets-12.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:27a5e9964ef509016759f2ef3f2c1e13f403725a5e6a1775555994966a66e931"}, - {file = "websockets-12.0-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c3181df4583c4d3994d31fb235dc681d2aaad744fbdbf94c4802485ececdecf2"}, - {file = "websockets-12.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:b067cb952ce8bf40115f6c19f478dc71c5e719b7fbaa511359795dfd9d1a6468"}, - {file = "websockets-12.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:00700340c6c7ab788f176d118775202aadea7602c5cc6be6ae127761c16d6b0b"}, - {file = "websockets-12.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e469d01137942849cff40517c97a30a93ae79917752b34029f0ec72df6b46399"}, - {file = "websockets-12.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ffefa1374cd508d633646d51a8e9277763a9b78ae71324183693959cf94635a7"}, - {file = "websockets-12.0-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba0cab91b3956dfa9f512147860783a1829a8d905ee218a9837c18f683239611"}, - {file = "websockets-12.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2cb388a5bfb56df4d9a406783b7f9dbefb888c09b71629351cc6b036e9259370"}, - {file = "websockets-12.0-py3-none-any.whl", hash = "sha256:dc284bbc8d7c78a6c69e0c7325ab46ee5e40bb4d50e494d8131a07ef47500e9e"}, - {file = "websockets-12.0.tar.gz", hash = "sha256:81df9cbcbb6c260de1e007e58c011bfebe2dafc8435107b0537f393dd38c8b1b"}, -] - [[package]] name = "yarl" version = "1.9.4" diff --git a/pyproject.toml b/pyproject.toml index b48e59ac..6e07aacf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,6 @@ dependencies = [ "rich", "zhipuai>=2.0.1", "httpx[socks]", - "EdgeGPT==0.1.26", "langchain>=0.0.343", "beautifulsoup4>=4.12.0", "google-search-results>=2.4.2", @@ -27,6 +26,7 @@ dependencies = [ "dashscope>=1.10.0", "tetos>=0.2.1", "groq>=0.5.0", + "pyyaml>=6.0.1", ] license = {text = "MIT"} dynamic = ["version", "optional-dependencies"] diff --git a/requirements.txt b/requirements.txt index 02c1aee1..5af8720d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,6 @@ async-timeout==4.0.3; python_version < "3.11" attrs==23.2.0 azure-cognitiveservices-speech==1.37.0 beautifulsoup4==4.12.3 -bingimagecreator==0.5.0 cachetools==5.3.2 certifi==2024.2.2 charset-normalizer==3.3.2 @@ -19,7 +18,6 @@ dashscope==1.18.0 dataclasses-json==0.6.3 distro==1.9.0 edge-tts==6.1.10 -edgegpt==0.1.26 exceptiongroup==1.2.0; python_version < "3.11" frozenlist==1.4.1 google-ai-generativelanguage==0.6.2 @@ -59,7 +57,6 @@ numpy==1.26.3 openai==1.25.1 orjson==3.10.0 packaging==23.2 -prompt-toolkit==3.0.43 proto-plus==1.23.0 protobuf==4.25.1 pyasn1==0.5.1 @@ -70,7 +67,6 @@ pygments==2.17.2 pyjwt==2.8.0 pyparsing==3.1.2; python_version > "3.0" pyyaml==6.0.1 -regex==2023.12.25 requests==2.31.0 rich==13.7.1 rsa==4.9 @@ -85,7 +81,5 @@ typing-extensions==4.9.0 typing-inspect==0.9.0 uritemplate==4.1.1 urllib3==2.1.0 -wcwidth==0.2.13 -websockets==12.0 yarl==1.9.4 zhipuai==2.0.1.20240423.1 diff --git a/xiao_config.json.example b/xiao_config.json.example deleted file mode 100644 index e9a63b2d..00000000 --- a/xiao_config.json.example +++ /dev/null @@ -1,33 +0,0 @@ -{ - "hardware": "LX06", - "account": "", - "password": "", - "openai_key": "", - "glm_key": "", - "gemini_key": "", - "gemini_api_domain": "", - "qwen_key": "", - "serpapi_api_key": "", - "cookie": "", - "mi_did": "", - "use_command": false, - "mute_xiaoai": true, - "verbose": false, - "bot": "chatgptapi", - "tts": "mi", - "tts_options": {}, - "prompt": "请用100字以内回答", - "keyword": ["请"], - "change_prompt_keyword": ["更改提示词"], - "start_conversation": "开始持续对话", - "end_conversation": "结束持续对话", - "stream": false, - "proxy": "", - "gpt_options": {}, - "bing_cookie_path": "", - "bing_cookies": {}, - "api_base": "https://abc-def.openai.azure.com/", - "deployment_id": "", - "volc_access_key": "", - "volc_secret_key": "" -} diff --git a/xiao_config.yaml.example b/xiao_config.yaml.example new file mode 100644 index 00000000..ed960eef --- /dev/null +++ b/xiao_config.yaml.example @@ -0,0 +1,94 @@ +# This is a YAML configuration file + +# 小米设备型号,可在底部标签获得 +hardware: LX06 +# 小米账号 +account: "" +# 小米密码 +password: "" +# 小米账户 cookie (如果用上面密码登录可以不填) +cookie: "" +# 设备 DID,参考 https://github.com/yihong0618/MiService +mi_did: "" +# 使用 MI command 与小爱交互 +use_command: false +# 快速停掉小爱自己的回答 +mute_xiaoai: true +# 是否打印详细日志 +verbose: false +# HTTP 代理地址 +proxy: "" + +# ===== 对话 AI 设置 ===== +# 使用的 bot 类型,目前支持 chatgptapi, glm, gemini, langchain, qwen, doubao, moonshot, yi, llama, +bot: chatgptapi +# 自定义 prompt +prompt: "请用100字以内回答" +# 触发词列表 +keyword: + - "请" +# 更改提示词触发列表 +change_prompt_keyword: + - "更改提示词" +# 开始持续对话关键词 +start_conversation: "开始持续对话" +# 结束持续对话关键词 +end_conversation: "结束持续对话" +# 使用流式响应,获得更快的响应 +stream: true +# 传给 Chatbot completion 接口的参数,比如要使用自定义模型: +# gpt_options: +# model: gpt4-turbo +gpt_options: {} + +# ----- OpenAI ----- +# OpenAI key +openai_key: "" +# OpenAI API 地址 +# 例:OpenAI 代理地址: https://myopenai.com/v1/ +# 或:Azure Open AI: https://abc.openai.azure.com/ +api_base: "https://abc-def.openai.azure.com/" +# Azure Open AI 的 deployment id(如使用 Azure OpenAI) +deployment_id: "" + + +# ----- Moonshot(Kimi) ----- +# Kimi 的 API key: https://platform.moonshot.cn/docs/api/chat#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B +moonshot_api_key: "" + +# ----- Yi ----- +# 零一万物的 API key: https://platform.lingyiwanwu.com/apikeys +yi_api_key: "" + +# ----- Groq(Llama3) ----- +# Groq API key: https://console.groq.com/docs/quickstart +llama_api_key: "" + +# ----- SerpAPI(Bot 类型为 langchain 时需要) ----- +# SerpAPI key: https://serpapi.com/ +serpapi_api_key: "" + +# ----- 智谱清言(ChatGLM) ----- +# ChatGLM API key +glm_key: "" + +# ----- Gemini ----- +# Gemini key: https://makersuite.google.com/app/apikey +gemini_key: "" +# Gemini 自定义域名: https://github.com/antergone/palm-netlify-proxy +gemini_api_domain: "" + +# ----- 通义千问(Qwen) ----- +# Qwen API key: https://help.aliyun.com/zh/dashscope/developer-reference/api-details +qwen_key: "" + +# ----- 火山(豆包)----- +# 火山引擎的 access key 和 secret key,参考 https://console.volcengine.com/iam/keymanage/ +volc_access_key: "" +volc_secret_key: "" + +# ===== 语音设置 ===== +# 使用的 TTS 类型,目前支持 mi, edge, openai, azure, volc, baidu, google, minimax +tts: mi +# TTS 参数字典,参考 https://github.com/frostming/tetos 获取可用参数 +tts_options: {} diff --git a/xiaogpt/bot/__init__.py b/xiaogpt/bot/__init__.py index 9df06677..1cb592b1 100644 --- a/xiaogpt/bot/__init__.py +++ b/xiaogpt/bot/__init__.py @@ -6,15 +6,13 @@ from xiaogpt.bot.gemini_bot import GeminiBot from xiaogpt.bot.glm_bot import GLMBot from xiaogpt.bot.langchain_bot import LangChainBot -from xiaogpt.bot.newbing_bot import NewBingBot -from xiaogpt.bot.qwen_bot import QwenBot +from xiaogpt.bot.llama_bot import LlamaBot from xiaogpt.bot.moonshot_bot import MoonshotBot +from xiaogpt.bot.qwen_bot import QwenBot from xiaogpt.bot.yi_bot import YiBot -from xiaogpt.bot.llama_bot import LlamaBot from xiaogpt.config import Config BOTS: dict[str, type[BaseBot]] = { - "newbing": NewBingBot, "chatgptapi": ChatGPTBot, "glm": GLMBot, "gemini": GeminiBot, @@ -36,7 +34,6 @@ def get_bot(config: Config) -> BaseBot: __all__ = [ "ChatGPTBot", - "NewBingBot", "GLMBot", "GeminiBot", "MoonshotBot", diff --git a/xiaogpt/bot/newbing_bot.py b/xiaogpt/bot/newbing_bot.py deleted file mode 100644 index 2631b40f..00000000 --- a/xiaogpt/bot/newbing_bot.py +++ /dev/null @@ -1,81 +0,0 @@ -from __future__ import annotations - -import re - -from xiaogpt.bot.base_bot import BaseBot, ChatHistoryMixin -from xiaogpt.utils import split_sentences - -_reference_link_re = re.compile(r"\[\d+\]: .+?\n+") - - -class NewBingBot(ChatHistoryMixin, BaseBot): - name = "Bing" - - def __init__( - self, - bing_cookie_path: str = "", - bing_cookies: dict | None = None, - proxy: str | None = None, - ): - from EdgeGPT import Chatbot - - self.history = [] - self._bot = Chatbot( - cookiePath=bing_cookie_path, cookies=bing_cookies, proxy=proxy - ) - - @classmethod - def from_config(cls, config): - return cls( - bing_cookie_path=config.bing_cookie_path, - bing_cookies=config.bing_cookies, - proxy=config.proxy, - ) - - @staticmethod - def clean_text(s): - s = s.replace("**", "") - s = _reference_link_re.sub("", s) - s = re.sub(r"\[[\^\d]+\]", "", s) - return s.strip() - - async def ask(self, query, **options): - from EdgeGPT import ConversationStyle - - kwargs = {"conversation_style": ConversationStyle.balanced, **options} - completion = await self._bot.ask(prompt=query, **kwargs) - try: - text = self.clean_text(completion["item"]["messages"][1]["text"]) - except Exception as e: - print(str(e)) - return - print(text) - return text - - async def ask_stream(self, query, **options): - from EdgeGPT import ConversationStyle - - kwargs = {"conversation_style": ConversationStyle.balanced, **options} - try: - completion = self._bot.ask_stream(prompt=query, **kwargs) - except Exception: - return - - async def text_gen(): - current = "" - async for final, resp in completion: - if final: - break - text = self.clean_text(resp) - if text == current: - continue - diff = text[len(current) :] - print(diff, end="") - yield diff - current = text - - try: - async for sentence in split_sentences(text_gen()): - yield sentence - finally: - print() diff --git a/xiaogpt/cli.py b/xiaogpt/cli.py index aca37c23..9b0d8add 100644 --- a/xiaogpt/cli.py +++ b/xiaogpt/cli.py @@ -145,13 +145,6 @@ def main(): const="langchain", help="if use langchain", ) - bot_group.add_argument( - "--use_newbing", - dest="bot", - action="store_const", - const="newbing", - help="if use newbing", - ) bot_group.add_argument( "--use_glm", dest="bot", @@ -198,7 +191,6 @@ def main(): help="bot type", choices=[ "chatgptapi", - "newbing", "glm", "gemini", "langchain", diff --git a/xiaogpt/config.py b/xiaogpt/config.py index 6a7fdb8c..847ec583 100644 --- a/xiaogpt/config.py +++ b/xiaogpt/config.py @@ -6,6 +6,8 @@ from dataclasses import dataclass, field from typing import Any, Iterable, Literal +import yaml + from xiaogpt.utils import validate_proxy LATEST_ASK_API = "https://userprofile.mina.mi.com/device_profile/v2/conversation?source=dialogu&hardware={hardware}×tamp={timestamp}&limit=2" @@ -84,18 +86,10 @@ class Config: ] = "mi" tts_options: dict[str, Any] = field(default_factory=dict) gpt_options: dict[str, Any] = field(default_factory=dict) - bing_cookie_path: str = "" - bing_cookies: dict | None = None def __post_init__(self) -> None: if self.proxy: validate_proxy(self.proxy) - if self.bot == "newbing": - if not (self.bing_cookie_path or self.bing_cookies): - raise Exception( - "New bing bot needs bing_cookie_path or bing_cookies, read this: " - "https://github.com/acheong08/EdgeGPT#getting-authentication-required" - ) if ( self.api_base and self.api_base.endswith(("openai.azure.com", "openai.azure.com/")) @@ -140,7 +134,10 @@ def from_options(cls, options: argparse.Namespace) -> Config: def read_from_file(cls, config_path: str) -> dict: result = {} with open(config_path, "rb") as f: - config = json.load(f) + if config_path.endswith(".json"): + config = json.load(f) + else: + config = yaml.safe_load(f) for key, value in config.items(): if value is None: continue