Play ChatGPT and other LLM with Xiaomi AI Speaker
System and Shell | Linux *sh | Windows CMD users | Windows PowerShell users |
---|---|---|---|
1. Installation package | pip install miservice_fork | pip install miservice_fork | pip install miservice_fork |
2. Set variables | 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. Obtain MI_DID | micli list | micli list | micli list |
4. Set MI_DID | export MI_DID=xxx | set MI_DID=xxx | $env:MI_DID="xxx" |
Notes on interactive interactions between Xiaoai and ChatGPT without root
pip install -U --force-reinstall xiaogpt[locked]
micli list
in the local terminal to get the DID of your speaker. If successful, don’t forget to set export MI_DID=xxx for this MI_DID.xiaogpt --hardware ${your_hardware} --use_chatgpt_api
hardware You see there is a model number on Xiao Ai's butt, enter it. If you can't find it on your butt or the model is wrong, you can use micli mina
to find the model number.--cookie '${cookie}'
Don't forget to wrap the cookie in single quotes--use_command
to use command to tts.--mute_xiaoai
option to quickly stop Xiaoai's answers--account ${account} --password ${password}
--use_chatgpt_api
to have a smoother conversation, which is very fast and achieves a conversational experience. Openai api, command --use_chatgpt_api
--api_base ${url}
instead. Please note that the api you enter here should be ' https://xxxx/v1
', and the domain name needs to be wrapped in quotes.--use_moonshot_api
and other models please refer below开始持续对话
and automatically enter the continuous conversation state, and结束持续对话
to end the continuous conversation state.--tts edge
to get better tts capabilities--tts fish --fish_api_key <your-fish-key> --fish_voice_key <fish-voice>
to obtain the fish-audio capability (see below for how to obtain fish voice)--tts openai
to obtain openai tts capabilities--tts azure --azure_tts_speech_key <your-speech-key>
to obtain Azure TTS capabilities--use_langchain
instead of --use_chatgpt_api
to call the LangChain (default chatgpt) service to implement online retrieval and mathematical operations..e.g.
export OPENAI_API_KEY= ${your_api_key}
xiaogpt --hardware LX06 --use_chatgpt_api
# or
xiaogpt --hardware LX06 --cookie ${cookie} --use_chatgpt_api
# 如果你想直接输入账号密码
xiaogpt --hardware LX06 --account ${your_xiaomi_account} --password ${your_password} --use_chatgpt_api
# 如果你想 mute 小米的回答
xiaogpt --hardware LX06 --mute_xiaoai --use_chatgpt_api
# 使用流式响应,获得更快的响应
xiaogpt --hardware LX06 --mute_xiaoai --stream
# 如果你想使用 google 的 gemini
xiaogpt --hardware LX06 --mute_xiaoai --use_gemini --gemini_key ${gemini_key}
# 如果你想使用自己的 google gemini 服务
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_gemini --gemini_key ${gemini_key} --gemini_api_domain ${gemini_api_domain}
# 如果你想使用阿里的通义千问
xiaogpt --hardware LX06 --mute_xiaoai --use_qwen --qwen_key ${qwen_key}
# 如果你想使用 kimi
xiaogpt --hardware LX06 --mute_xiaoai --use_moonshot_api --moonshot_api_key ${moonshot_api_key}
# 如果你想使用 llama3
xiaogpt --hardware LX06 --mute_xiaoai --use_llama --llama_api_key ${llama_api_key}
# 如果你想使用 01
xiaogpt --hardware LX06 --mute_xiaoai --use_yi_api --ti_api_key ${yi_api_key}
# 如果你想使用 LangChain+SerpApi 实现上网检索或其他本地服务(目前仅支持 stream 模式)
export OPENAI_API_KEY= ${your_api_key}
export SERPAPI_API_KEY= ${your_serpapi_key}
xiaogpt --hardware Lx06 --use_langchain --mute_xiaoai --stream --openai_key ${your_api_key} --serpapi_api_key ${your_serpapi_key}
Use git clone to run
export OPENAI_API_KEY= ${your_api_key}
python3 xiaogpt.py --hardware LX06
# or
python3 xiaogpt.py --hardware LX06 --cookie ${cookie}
# 如果你想直接输入账号密码
python3 xiaogpt.py --hardware LX06 --account ${your_xiaomi_account} --password ${your_password} --use_chatgpt_api
# 如果你想 mute 小米的回答
python3 xiaogpt.py --hardware LX06 --mute_xiaoai
# 使用流式响应,获得更快的响应
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --stream
# 如果你想使用 ChatGLM api
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_glm --glm_key ${glm_key}
# 如果你想使用 google 的 gemini
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_gemini --gemini_key ${gemini_key}
# 如果你想使用自己的 google gemini 服务
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_gemini --gemini_key ${gemini_key} --gemini_api_domain ${gemini_api_domain}
# 如果你想使用阿里的通义千问
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_qwen --qwen_key ${qwen_key}
# 如果你想使用 kimi
xiaogpt --hardware LX06 --mute_xiaoai --use_moonshot_api --moonshot_api_key ${moonshot_api_key}
# 如果你想使用 01
xiaogpt --hardware LX06 --mute_xiaoai --use_yi_api --ti_api_key ${yi_api_key}
# 如果你想使用豆包
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_doubao --stream --volc_access_key xxxx --volc_secret_key xxx
# 如果你想使用 llama3
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_llama --llama_api_key ${llama_api_key}
# 如果你想使用 LangChain+SerpApi 实现上网检索或其他本地服务(目前仅支持 stream 模式)
export OPENAI_API_KEY= ${your_api_key}
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}
If you want to start through a single configuration file, it is also possible. You can specify the configuration file through the --config
parameter. The config file must be a legal Yaml or JSON format parameter priority.
python3 xiaogpt.py --config xiao_config.yaml
# or
xiaogpt --config xiao_config.yaml
or
cp xiao_config.yaml.example xiao_config.yaml
python3 xiaogpt.py
To specify OpenAI model parameters, such as model, temporal, top_p, please specify in config.yaml:
gpt_options :
temperature : 0.9
top_p : 0.9
Please refer to the Open AI API documentation for specific parameter functions. ChatGLM documentation
parameter | illustrate | default value | Optional value |
---|---|---|---|
hardware | Device model | ||
account | Xiaoai account | ||
password | Xiaoai account password | ||
openai_key | openai's apikey | ||
moonshot_api_key | apikey by moonshot kimi | ||
yi_api_key | 01 wanwu's apikey | ||
llama_api_key | llama3 apikey for groq | ||
serpapi_api_key | Serpapi key reference SerpAPI | ||
glm_key | chatglm apikey | ||
gemini_key | gemini apikey reference | ||
gemini_api_domain | Gemini’s custom domain name reference | ||
qwen_key | qwen's apikey reference | ||
cookies | Xiaoai account cookie (you can leave it blank if you log in with the above password) | ||
mi_did | devicedid | ||
use_command | Use MI command to interact with Xiaoai | false | |
mute_xiaoai | Quickly stop Xiaoai’s own answer | true | |
verbose | Whether to print detailed logs | false | |
bot | The type of bot used currently supports chatgptapi, newbing, qwen, gemini | chatgptapi | |
tts | TTS type used | mi | edge , openai , azure , volc , baidu , google , minimax |
tts_options | TTS parameter dictionary, refer to tetos for available parameters | ||
prompt | Custom prompt | 请用100字以内回答 | |
keyword | Custom request word list | ["请"] | |
change_prompt_keyword | Change prompt word trigger list | ["更改提示词"] | |
start_conversation | Start ongoing conversation keywords | 开始持续对话 | |
end_conversation | End ongoing conversation keywords | 结束持续对话 | |
stream | Use streaming responses for faster responses | true | |
proxy | Support HTTP proxy, pass in http proxy URL | "" | |
gpt_options | Parameter dictionary for OpenAI API | {} | |
deployment_id | Deployment ID of Azure OpenAI service | Refer to this how to find deployment_id | |
api_base | If you need to replace the default api, or use Azure OpenAI service | For example: https://abc-def.openai.azure.com/ | |
volc_access_key | Please get the access key of Volcano Engine here | ||
volc_secret_key | Please get the secret key of Volcano Engine here |
--use_command
LX04, These models also only support Xiaoai’s original TTS.C:Users用户名
after deploying the project locally, and then Throw it to the server where you cannot log in. If it is Linux, please put it in the home folder of the current user. At this time, you can re-execute the previous command and you can log in normally without any accident (but the cookie may expire after a period of time and needs to be restarted. get)https://www.youtube.com/watch?v=K4YA8YwzOOA
X86/ARM Docker Image: yihong0618/xiaogpt
docker run -e OPENAI_API_KEY= < your-openapi-key > yihong0618/xiaogpt <命令行参数>
like
docker run -e OPENAI_API_KEY= < your-openapi-key > yihong0618/xiaogpt --account= < your-xiaomi-account > --password= < your-xiaomi-password > --hardware= < your-xiaomi-hardware > --use_chatgpt_api
The configuration file of xiaogpt can be processed by specifying volume /config and specifying the parameter --config, such as
docker run -v < your-config-dir > :/config yihong0618/xiaogpt --config=/config/config.yaml
docker run -v < your-config-dir > :/config --network=host yihong0618/xiaogpt --config=/config/config.yaml
docker build -t xiaogpt .
If the build fails or the installation is slow when installing dependencies, you can use the --build-arg
parameter to specify the domestic source address when building the Docker image:
docker build --build-arg PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple -t xiaogpt .
If you need to compile x86 on Apple M1/M2
docker buildx build --platform=linux/amd64 -t xiaogpt-x86 .
We currently support three third-party TTS: edge/openai/azure/volc/baidu/google
edge-tts provides capabilities similar to Microsoft TTS azure-tts provides capabilities similar to Microsoft Azure TTS openai-tts provides capabilities similar to OpenAI TTS fish-tts provides capabilities similar to fish TTS
You can enable it through the parameter tts
,
tts : edge
For edge See more language support, choose one
edge-tts --list-voices
e80ea225770f42f79d50aa98be3cedfc
is the key id of the sound tts : fish
# TTS 参数字典,参考 https://github.com/frostming/tetos 获取可用参数
tts_options : {
" api_key " : " xxxxx " ,
" voice " : " xxxxxx "
}
Since Edge TTS starts a local HTTP service, you need to map the container's port to the host and specify the hostname of the local machine:
docker run -v < your-config-dir > :/config -p 9527:9527 -e XIAOGPT_HOSTNAME= < your ip > yihong0618/xiaogpt --config=/config/config.yaml
Note that the port must be mapped consistent with the container, and XIAOGPT_HOSTNAME needs to be set to the IP address of the host, otherwise Xiaoai cannot play voice normally.
持续会话功能
Thank you is enough