xiaogpt 2.63__py3-none-any.whl → 2.70__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xiaogpt/bot/__init__.py +9 -0
- xiaogpt/bot/llama_bot.py +25 -0
- xiaogpt/bot/moonshot_bot.py +28 -0
- xiaogpt/bot/yi_bot.py +28 -0
- xiaogpt/cli.py +39 -0
- xiaogpt/config.py +13 -2
- xiaogpt/tts/tetos.py +8 -33
- xiaogpt/xiaogpt.py +18 -3
- {xiaogpt-2.63.dist-info → xiaogpt-2.70.dist-info}/METADATA +78 -56
- {xiaogpt-2.63.dist-info → xiaogpt-2.70.dist-info}/RECORD +13 -10
- {xiaogpt-2.63.dist-info → xiaogpt-2.70.dist-info}/WHEEL +1 -1
- {xiaogpt-2.63.dist-info → xiaogpt-2.70.dist-info}/entry_points.txt +0 -0
- {xiaogpt-2.63.dist-info → xiaogpt-2.70.dist-info}/licenses/LICENSE +0 -0
xiaogpt/bot/__init__.py
CHANGED
@@ -8,6 +8,9 @@ from xiaogpt.bot.glm_bot import GLMBot
|
|
8
8
|
from xiaogpt.bot.langchain_bot import LangChainBot
|
9
9
|
from xiaogpt.bot.newbing_bot import NewBingBot
|
10
10
|
from xiaogpt.bot.qwen_bot import QwenBot
|
11
|
+
from xiaogpt.bot.moonshot_bot import MoonshotBot
|
12
|
+
from xiaogpt.bot.yi_bot import YiBot
|
13
|
+
from xiaogpt.bot.llama_bot import LlamaBot
|
11
14
|
from xiaogpt.config import Config
|
12
15
|
|
13
16
|
BOTS: dict[str, type[BaseBot]] = {
|
@@ -18,6 +21,9 @@ BOTS: dict[str, type[BaseBot]] = {
|
|
18
21
|
"qwen": QwenBot,
|
19
22
|
"langchain": LangChainBot,
|
20
23
|
"doubao": DoubaoBot,
|
24
|
+
"moonshot": MoonshotBot,
|
25
|
+
"yi": YiBot,
|
26
|
+
"llama": LlamaBot,
|
21
27
|
}
|
22
28
|
|
23
29
|
|
@@ -33,8 +39,11 @@ __all__ = [
|
|
33
39
|
"NewBingBot",
|
34
40
|
"GLMBot",
|
35
41
|
"GeminiBot",
|
42
|
+
"MoonshotBot",
|
36
43
|
"QwenBot",
|
37
44
|
"get_bot",
|
38
45
|
"LangChainBot",
|
39
46
|
"DoubaoBot",
|
47
|
+
"YiBot",
|
48
|
+
"LlamaBot",
|
40
49
|
]
|
xiaogpt/bot/llama_bot.py
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
import httpx
|
2
|
+
from groq import Groq as openai
|
3
|
+
from groq import AsyncGroq as AsyncOpenAI
|
4
|
+
|
5
|
+
from xiaogpt.bot.chatgptapi_bot import ChatGPTBot
|
6
|
+
|
7
|
+
|
8
|
+
class LlamaBot(ChatGPTBot):
|
9
|
+
name = "llama"
|
10
|
+
default_options = {"model": "llama3-70b-8192"}
|
11
|
+
|
12
|
+
def __init__(self, llama_api_key: str) -> None:
|
13
|
+
self.llama_api_key = llama_api_key
|
14
|
+
self.history: list[tuple[str, str]] = []
|
15
|
+
|
16
|
+
def _make_openai_client(self, sess: httpx.AsyncClient) -> AsyncOpenAI:
|
17
|
+
return AsyncOpenAI(
|
18
|
+
api_key=self.llama_api_key, http_client=sess, base_url=self.api_base
|
19
|
+
)
|
20
|
+
|
21
|
+
@classmethod
|
22
|
+
def from_config(cls, config):
|
23
|
+
return cls(
|
24
|
+
llama_api_key=config.llama_api_key,
|
25
|
+
)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import httpx
|
2
|
+
import openai
|
3
|
+
|
4
|
+
from xiaogpt.bot.chatgptapi_bot import ChatGPTBot
|
5
|
+
|
6
|
+
|
7
|
+
class MoonshotBot(ChatGPTBot):
|
8
|
+
name = "Moonshot"
|
9
|
+
default_options = {"model": "moonshot-v1-8k"}
|
10
|
+
|
11
|
+
def __init__(
|
12
|
+
self, moonshot_api_key: str, api_base="https://api.moonshot.cn/v1"
|
13
|
+
) -> None:
|
14
|
+
self.moonshot_api_key = moonshot_api_key
|
15
|
+
self.api_base = api_base
|
16
|
+
self.history: list[tuple[str, str]] = []
|
17
|
+
|
18
|
+
def _make_openai_client(self, sess: httpx.AsyncClient) -> openai.AsyncOpenAI:
|
19
|
+
return openai.AsyncOpenAI(
|
20
|
+
api_key=self.moonshot_api_key, http_client=sess, base_url=self.api_base
|
21
|
+
)
|
22
|
+
|
23
|
+
@classmethod
|
24
|
+
def from_config(cls, config):
|
25
|
+
return cls(
|
26
|
+
moonshot_api_key=config.moonshot_api_key,
|
27
|
+
api_base="https://api.moonshot.cn/v1",
|
28
|
+
)
|
xiaogpt/bot/yi_bot.py
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
import httpx
|
2
|
+
import openai
|
3
|
+
|
4
|
+
from xiaogpt.bot.chatgptapi_bot import ChatGPTBot
|
5
|
+
|
6
|
+
|
7
|
+
class YiBot(ChatGPTBot):
|
8
|
+
name = "yi"
|
9
|
+
default_options = {"model": "yi-34b-chat-0205"}
|
10
|
+
|
11
|
+
def __init__(
|
12
|
+
self, yi_api_key: str, api_base="https://api.lingyiwanwu.com/v1"
|
13
|
+
) -> None:
|
14
|
+
self.yi_api_key = yi_api_key
|
15
|
+
self.api_base = api_base
|
16
|
+
self.history: list[tuple[str, str]] = []
|
17
|
+
|
18
|
+
def _make_openai_client(self, sess: httpx.AsyncClient) -> openai.AsyncOpenAI:
|
19
|
+
return openai.AsyncOpenAI(
|
20
|
+
api_key=self.yi_api_key, http_client=sess, base_url=self.api_base
|
21
|
+
)
|
22
|
+
|
23
|
+
@classmethod
|
24
|
+
def from_config(cls, config):
|
25
|
+
return cls(
|
26
|
+
yi_api_key=config.yi_api_key,
|
27
|
+
api_base="https://api.lingyiwanwu.com/v1",
|
28
|
+
)
|
xiaogpt/cli.py
CHANGED
@@ -27,6 +27,21 @@ def main():
|
|
27
27
|
dest="openai_key",
|
28
28
|
help="openai api key",
|
29
29
|
)
|
30
|
+
parser.add_argument(
|
31
|
+
"--moonshot_api_key",
|
32
|
+
dest="moonshot_api_key",
|
33
|
+
help="Moonshot api key",
|
34
|
+
)
|
35
|
+
parser.add_argument(
|
36
|
+
"--llama_api_key",
|
37
|
+
dest="llama_api_key",
|
38
|
+
help="llama(use groq) api key",
|
39
|
+
)
|
40
|
+
parser.add_argument(
|
41
|
+
"--yi_api_key",
|
42
|
+
dest="yi_api_key",
|
43
|
+
help="01wanwu api key",
|
44
|
+
)
|
30
45
|
parser.add_argument(
|
31
46
|
"--glm_key",
|
32
47
|
dest="glm_key",
|
@@ -109,6 +124,20 @@ def main():
|
|
109
124
|
const="chatgptapi",
|
110
125
|
help="if use openai chatgpt api",
|
111
126
|
)
|
127
|
+
bot_group.add_argument(
|
128
|
+
"--use_moonshot_api",
|
129
|
+
dest="bot",
|
130
|
+
action="store_const",
|
131
|
+
const="moonshot",
|
132
|
+
help="if use moonshot api",
|
133
|
+
)
|
134
|
+
bot_group.add_argument(
|
135
|
+
"--use_yi_api",
|
136
|
+
dest="bot",
|
137
|
+
action="store_const",
|
138
|
+
const="yi",
|
139
|
+
help="if use yi api",
|
140
|
+
)
|
112
141
|
bot_group.add_argument(
|
113
142
|
"--use_langchain",
|
114
143
|
dest="bot",
|
@@ -151,6 +180,13 @@ def main():
|
|
151
180
|
const="doubao",
|
152
181
|
help="if use doubao",
|
153
182
|
)
|
183
|
+
bot_group.add_argument(
|
184
|
+
"--use_llama", # use groq
|
185
|
+
dest="bot",
|
186
|
+
action="store_const",
|
187
|
+
const="llama",
|
188
|
+
help="if use groq llama3",
|
189
|
+
)
|
154
190
|
parser.add_argument(
|
155
191
|
"--bing_cookie_path",
|
156
192
|
dest="bing_cookie_path",
|
@@ -168,6 +204,9 @@ def main():
|
|
168
204
|
"langchain",
|
169
205
|
"qwen",
|
170
206
|
"doubao",
|
207
|
+
"moonshot",
|
208
|
+
"yi",
|
209
|
+
"llama",
|
171
210
|
],
|
172
211
|
)
|
173
212
|
parser.add_argument(
|
xiaogpt/config.py
CHANGED
@@ -37,7 +37,7 @@ DEFAULT_COMMAND = ("5-1", "5-5")
|
|
37
37
|
|
38
38
|
KEY_WORD = ("帮我", "请")
|
39
39
|
CHANGE_PROMPT_KEY_WORD = ("更改提示词",)
|
40
|
-
PROMPT = "以下请用
|
40
|
+
PROMPT = "以下请用300字以内回答,请只回答文字不要带链接"
|
41
41
|
# simulate_xiaoai_question
|
42
42
|
MI_ASK_SIMULATE_DATA = {
|
43
43
|
"code": 0,
|
@@ -52,6 +52,9 @@ class Config:
|
|
52
52
|
account: str = os.getenv("MI_USER", "")
|
53
53
|
password: str = os.getenv("MI_PASS", "")
|
54
54
|
openai_key: str = os.getenv("OPENAI_API_KEY", "")
|
55
|
+
moonshot_api_key: str = os.getenv("MOONSHOT_API_KEY", "")
|
56
|
+
yi_api_key: str = os.getenv("YI_API_KEY", "")
|
57
|
+
llama_api_key: str = os.getenv("GROQ_API_KEY", "") # use groq
|
55
58
|
glm_key: str = os.getenv("CHATGLM_KEY", "")
|
56
59
|
gemini_key: str = os.getenv("GEMINI_KEY", "") # keep the old rule
|
57
60
|
qwen_key: str = os.getenv("DASHSCOPE_API_KEY", "") # keep the old rule
|
@@ -76,7 +79,9 @@ class Config:
|
|
76
79
|
start_conversation: str = "开始持续对话"
|
77
80
|
end_conversation: str = "结束持续对话"
|
78
81
|
stream: bool = False
|
79
|
-
tts: Literal[
|
82
|
+
tts: Literal[
|
83
|
+
"mi", "edge", "azure", "openai", "baidu", "google", "volc", "minimax"
|
84
|
+
] = "mi"
|
80
85
|
tts_options: dict[str, Any] = field(default_factory=dict)
|
81
86
|
gpt_options: dict[str, Any] = field(default_factory=dict)
|
82
87
|
bing_cookie_path: str = ""
|
@@ -155,6 +160,12 @@ class Config:
|
|
155
160
|
key, value = "bot", "qwen"
|
156
161
|
elif key == "use_doubao":
|
157
162
|
key, value = "bot", "doubao"
|
163
|
+
elif key == "use_moonshot":
|
164
|
+
key, value = "bot", "moonshot"
|
165
|
+
elif key == "use_yi":
|
166
|
+
key, value = "bot", "yi"
|
167
|
+
elif key == "use_llama":
|
168
|
+
key, value = "bot", "llama"
|
158
169
|
elif key == "use_langchain":
|
159
170
|
key, value = "bot", "langchain"
|
160
171
|
elif key == "enable_edge_tts":
|
xiaogpt/tts/tetos.py
CHANGED
@@ -4,7 +4,6 @@ import tempfile
|
|
4
4
|
from pathlib import Path
|
5
5
|
|
6
6
|
from miservice import MiNAService
|
7
|
-
from tetos.base import Speaker
|
8
7
|
|
9
8
|
from xiaogpt.config import Config
|
10
9
|
from xiaogpt.tts.base import AudioFileTTS
|
@@ -14,39 +13,15 @@ class TetosTTS(AudioFileTTS):
|
|
14
13
|
def __init__(
|
15
14
|
self, mina_service: MiNAService, device_id: str, config: Config
|
16
15
|
) -> None:
|
17
|
-
|
18
|
-
self.speaker = self._get_speaker()
|
19
|
-
|
20
|
-
def _get_speaker(self) -> Speaker:
|
21
|
-
from tetos.azure import AzureSpeaker
|
22
|
-
from tetos.baidu import BaiduSpeaker
|
23
|
-
from tetos.edge import EdgeSpeaker
|
24
|
-
from tetos.google import GoogleSpeaker
|
25
|
-
from tetos.openai import OpenAISpeaker
|
26
|
-
from tetos.volc import VolcSpeaker
|
16
|
+
from tetos import get_speaker
|
27
17
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
GoogleSpeaker,
|
36
|
-
BaiduSpeaker,
|
37
|
-
):
|
38
|
-
if (name := speaker.__name__[:-7].lower()) == self.config.tts:
|
39
|
-
try:
|
40
|
-
return speaker(**options)
|
41
|
-
except TypeError as e:
|
42
|
-
raise ValueError(
|
43
|
-
f"{e}. Please add them via `tts_options` config"
|
44
|
-
) from e
|
45
|
-
else:
|
46
|
-
allowed_speakers.append(name)
|
47
|
-
raise ValueError(
|
48
|
-
f"Unsupported TTS: {self.config.tts}, allowed: {','.join(allowed_speakers)}"
|
49
|
-
)
|
18
|
+
super().__init__(mina_service, device_id, config)
|
19
|
+
assert config.tts and config.tts != "mi"
|
20
|
+
speaker_cls = get_speaker(config.tts)
|
21
|
+
try:
|
22
|
+
self.speaker = speaker_cls(**config.tts_options)
|
23
|
+
except TypeError as e:
|
24
|
+
raise ValueError(f"{e}. Please add them via `tts_options` config") from e
|
50
25
|
|
51
26
|
async def make_audio_file(self, lang: str, text: str) -> tuple[Path, float]:
|
52
27
|
output_file = tempfile.NamedTemporaryFile(
|
xiaogpt/xiaogpt.py
CHANGED
@@ -378,14 +378,23 @@ class MiGPT:
|
|
378
378
|
self.log.debug("No new xiao ai record")
|
379
379
|
continue
|
380
380
|
|
381
|
-
# drop
|
381
|
+
# drop key words
|
382
382
|
query = re.sub(rf"^({'|'.join(self.config.keyword)})", "", query)
|
383
|
+
# llama3 is not good at Chinese, so we need to add prompt in it.
|
384
|
+
if self.config.bot == "llama":
|
385
|
+
query = f"你是一个基于llama3 的智能助手,请你跟我对话时,一定使用中文,不要夹杂一些英文单词,甚至英语短语也不能随意使用,但类似于 llama3 这样的专属名词除外, 问题是:{query}"
|
383
386
|
|
384
387
|
print("-" * 20)
|
385
388
|
print("问题:" + query + "?")
|
386
389
|
if not self.chatbot.has_history():
|
387
390
|
query = f"{query},{self.config.prompt}"
|
388
|
-
|
391
|
+
# some model can not detect the language code, so we need to add it
|
392
|
+
|
393
|
+
if self.config.tts != "mi": # mi only say Chinese
|
394
|
+
query += (
|
395
|
+
",并用本段话的language code作为开头,用|分隔,如:en-US|你好……"
|
396
|
+
)
|
397
|
+
|
389
398
|
if self.config.mute_xiaoai:
|
390
399
|
await self.stop_if_xiaoai_is_playing()
|
391
400
|
else:
|
@@ -418,9 +427,15 @@ class MiGPT:
|
|
418
427
|
# It is not a legal language code, discard it
|
419
428
|
lang, first_chunk = "", text
|
420
429
|
|
430
|
+
lang = (
|
431
|
+
matches[0]
|
432
|
+
if (matches := re.findall(r"([a-z]{2}-[A-Z]{2})", lang))
|
433
|
+
else "zh-CN"
|
434
|
+
)
|
435
|
+
|
421
436
|
async def gen(): # reconstruct the generator
|
422
437
|
yield first_chunk
|
423
438
|
async for text in text_stream:
|
424
439
|
yield text
|
425
440
|
|
426
|
-
await self.tts.synthesize(lang
|
441
|
+
await self.tts.synthesize(lang, gen())
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: xiaogpt
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.70
|
4
4
|
Summary: Play ChatGPT or other LLM with xiaomi AI speaker
|
5
5
|
Author-Email: yihong0618 <zouzou0208@gmail.com>
|
6
6
|
License: MIT
|
@@ -22,7 +22,8 @@ Requires-Dist: google-search-results>=2.4.2
|
|
22
22
|
Requires-Dist: google-generativeai
|
23
23
|
Requires-Dist: numexpr>=2.8.6
|
24
24
|
Requires-Dist: dashscope>=1.10.0
|
25
|
-
Requires-Dist: tetos>=0.
|
25
|
+
Requires-Dist: tetos>=0.2.1
|
26
|
+
Requires-Dist: groq>=0.5.0
|
26
27
|
Requires-Dist: aiohttp==3.9.5; extra == "locked"
|
27
28
|
Requires-Dist: aiosignal==1.3.1; extra == "locked"
|
28
29
|
Requires-Dist: annotated-types==0.6.0; extra == "locked"
|
@@ -37,7 +38,7 @@ Requires-Dist: certifi==2024.2.2; extra == "locked"
|
|
37
38
|
Requires-Dist: charset-normalizer==3.3.2; extra == "locked"
|
38
39
|
Requires-Dist: click==8.1.7; extra == "locked"
|
39
40
|
Requires-Dist: colorama==0.4.6; platform_system == "Windows" and extra == "locked"
|
40
|
-
Requires-Dist: dashscope==1.
|
41
|
+
Requires-Dist: dashscope==1.18.0; extra == "locked"
|
41
42
|
Requires-Dist: dataclasses-json==0.6.3; extra == "locked"
|
42
43
|
Requires-Dist: distro==1.9.0; extra == "locked"
|
43
44
|
Requires-Dist: edge-tts==6.1.10; extra == "locked"
|
@@ -55,6 +56,7 @@ Requires-Dist: google-generativeai==0.5.2; extra == "locked"
|
|
55
56
|
Requires-Dist: google-search-results==2.4.2; extra == "locked"
|
56
57
|
Requires-Dist: googleapis-common-protos==1.62.0; extra == "locked"
|
57
58
|
Requires-Dist: greenlet==3.0.3; (platform_machine == "win32" or platform_machine == "WIN32" or platform_machine == "AMD64" or platform_machine == "amd64" or platform_machine == "x86_64" or platform_machine == "ppc64le" or platform_machine == "aarch64") and extra == "locked"
|
59
|
+
Requires-Dist: groq==0.5.0; extra == "locked"
|
58
60
|
Requires-Dist: grpcio==1.60.0; extra == "locked"
|
59
61
|
Requires-Dist: grpcio-status==1.60.0; extra == "locked"
|
60
62
|
Requires-Dist: h11==0.14.0; extra == "locked"
|
@@ -65,9 +67,9 @@ Requires-Dist: httpx[socks]==0.27.0; extra == "locked"
|
|
65
67
|
Requires-Dist: idna==3.7; extra == "locked"
|
66
68
|
Requires-Dist: jsonpatch==1.33; extra == "locked"
|
67
69
|
Requires-Dist: jsonpointer==2.4; extra == "locked"
|
68
|
-
Requires-Dist: langchain==0.1.
|
69
|
-
Requires-Dist: langchain-community==0.0.
|
70
|
-
Requires-Dist: langchain-core==0.1.
|
70
|
+
Requires-Dist: langchain==0.1.17; extra == "locked"
|
71
|
+
Requires-Dist: langchain-community==0.0.36; extra == "locked"
|
72
|
+
Requires-Dist: langchain-core==0.1.50; extra == "locked"
|
71
73
|
Requires-Dist: langchain-text-splitters==0.0.1; extra == "locked"
|
72
74
|
Requires-Dist: langsmith==0.1.45; extra == "locked"
|
73
75
|
Requires-Dist: markdown-it-py==3.0.0; extra == "locked"
|
@@ -79,7 +81,7 @@ Requires-Dist: mutagen==1.47.0; extra == "locked"
|
|
79
81
|
Requires-Dist: mypy-extensions==1.0.0; extra == "locked"
|
80
82
|
Requires-Dist: numexpr==2.10.0; extra == "locked"
|
81
83
|
Requires-Dist: numpy==1.26.3; extra == "locked"
|
82
|
-
Requires-Dist: openai==1.
|
84
|
+
Requires-Dist: openai==1.25.1; extra == "locked"
|
83
85
|
Requires-Dist: orjson==3.10.0; extra == "locked"
|
84
86
|
Requires-Dist: packaging==23.2; extra == "locked"
|
85
87
|
Requires-Dist: prompt-toolkit==3.0.43; extra == "locked"
|
@@ -102,7 +104,7 @@ Requires-Dist: socksio==1.0.0; extra == "locked"
|
|
102
104
|
Requires-Dist: soupsieve==2.5; extra == "locked"
|
103
105
|
Requires-Dist: sqlalchemy==2.0.25; extra == "locked"
|
104
106
|
Requires-Dist: tenacity==8.2.3; extra == "locked"
|
105
|
-
Requires-Dist: tetos==0.
|
107
|
+
Requires-Dist: tetos==0.2.1; extra == "locked"
|
106
108
|
Requires-Dist: tqdm==4.66.1; extra == "locked"
|
107
109
|
Requires-Dist: typing-extensions==4.9.0; extra == "locked"
|
108
110
|
Requires-Dist: typing-inspect==0.9.0; extra == "locked"
|
@@ -111,7 +113,7 @@ Requires-Dist: urllib3==2.1.0; extra == "locked"
|
|
111
113
|
Requires-Dist: wcwidth==0.2.13; extra == "locked"
|
112
114
|
Requires-Dist: websockets==12.0; extra == "locked"
|
113
115
|
Requires-Dist: yarl==1.9.4; extra == "locked"
|
114
|
-
Requires-Dist: zhipuai==2.0.1; extra == "locked"
|
116
|
+
Requires-Dist: zhipuai==2.0.1.20240423.1; extra == "locked"
|
115
117
|
Provides-Extra: locked
|
116
118
|
Description-Content-Type: text/markdown
|
117
119
|
|
@@ -120,7 +122,7 @@ Description-Content-Type: text/markdown
|
|
120
122
|
[](https://pypi.org/project/xiaogpt)
|
121
123
|
[](https://hub.docker.com/r/yihong0618/xiaogpt)
|
122
124
|
|
123
|
-
https://user-images.githubusercontent.com/15976103/226803357-72f87a41-a15b-409e-94f5-e2d262eecd53.mp4
|
125
|
+
<https://user-images.githubusercontent.com/15976103/226803357-72f87a41-a15b-409e-94f5-e2d262eecd53.mp4>
|
124
126
|
|
125
127
|
Play ChatGPT and other LLM with Xiaomi AI Speaker
|
126
128
|
|
@@ -134,11 +136,15 @@ Play ChatGPT and other LLM with Xiaomi AI Speaker
|
|
134
136
|
- [ChatGLM](http://open.bigmodel.cn/)
|
135
137
|
- [Gemini](https://makersuite.google.com/app/apikey)
|
136
138
|
- [Doubao](https://console.volcengine.com/iam/keymanage/)
|
139
|
+
- [Moonshot](https://platform.moonshot.cn/docs/api/chat#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B)
|
140
|
+
- [01](https://platform.lingyiwanwu.com/apikeys)
|
141
|
+
- [Llama3](https://console.groq.com/docs/quickstart)
|
137
142
|
- [通义千问](https://help.aliyun.com/zh/dashscope/developer-reference/api-details)
|
138
143
|
|
139
144
|
## 获取小米音响DID
|
140
|
-
|
141
|
-
|
|
145
|
+
|
146
|
+
| 系统和Shell | Linux *sh | Windows CMD用户 | Windows PowerShell用户 |
|
147
|
+
|------------|------------------------------------------------|----------------------------------------|------------------------------------------------|
|
142
148
|
| 1、安装包 | `pip install miservice_fork` | `pip install miservice_fork` | `pip install miservice_fork` |
|
143
149
|
| 2、设置变量 | `export MI_USER=xxx` <br> `export MI_PASS=xxx` | `set MI_USER=xxx`<br>`set MI_PASS=xxx` | `$env:MI_USER="xxx"` <br> `$env:MI_PASS="xxx"` |
|
144
150
|
| 3、取得MI_DID | `micli list` | `micli list` | `micli list` |
|
@@ -164,13 +170,14 @@ Play ChatGPT and other LLM with Xiaomi AI Speaker
|
|
164
170
|
- 参考我 fork 的 [MiService](https://github.com/yihong0618/MiService) 项目 README 并在本地 terminal 跑 `micli list` 拿到你音响的 DID 成功 **别忘了设置 export MI_DID=xxx** 这个 MI_DID 用
|
165
171
|
- run `xiaogpt --hardware ${your_hardware} --use_chatgpt_api` hardware 你看小爱屁股上有型号,输入进来,如果在屁股上找不到或者型号不对,可以用 `micli mina` 找到型号
|
166
172
|
- 跑起来之后就可以问小爱同学问题了,“帮我"开头的问题,会发送一份给 ChatGPT 然后小爱同学用 tts 回答
|
167
|
-
-
|
173
|
+
- 如果上面不可用,可以尝试用手机抓包,<https://userprofile.mina.mi.com/device_profile/v2/conversation> 找到 cookie 利用 `--cookie '${cookie}'` cookie 别忘了用单引号包裹
|
168
174
|
- 默认用目前 ubus, 如果你的设备不支持 ubus 可以使用 `--use_command` 来使用 command 来 tts
|
169
175
|
- 使用 `--mute_xiaoai` 选项,可以快速停掉小爱的回答
|
170
176
|
- 使用 `--account ${account} --password ${password}`
|
171
177
|
- 如果有能力可以自行替换唤醒词,也可以去掉唤醒词
|
172
178
|
- 使用 `--use_chatgpt_api` 的 api 那样可以更流畅的对话,速度特别快,达到了对话的体验, [openai api](https://platform.openai.com/account/api-keys), 命令 `--use_chatgpt_api`
|
173
179
|
- 如果你遇到了墙需要用 Cloudflare Workers 替换 api_base 请使用 `--api_base ${url}` 来替换。 **请注意,此处你输入的api应该是'`https://xxxx/v1`'的字样,域名需要用引号包裹**
|
180
|
+
- `--use_moonshot_api` and other models please refer below
|
174
181
|
- 可以跟小爱说 `开始持续对话` 自动进入持续对话状态,`结束持续对话` 结束持续对话状态。
|
175
182
|
- 可以使用 `--tts edge` 来获取更好的 tts 能力
|
176
183
|
- 可以使用 `--tts openai` 来获取 openai tts 能力
|
@@ -195,12 +202,18 @@ xiaogpt --hardware LX06 --mute_xiaoai --use_gemini --gemini_key ${gemini_key}
|
|
195
202
|
# 如果你想使用自己的 google gemini 服务
|
196
203
|
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_gemini --gemini_key ${gemini_key} --gemini_api_domain ${gemini_api_domain}
|
197
204
|
# 如果你想使用阿里的通义千问
|
198
|
-
xiaogpt --hardware LX06 --mute_xiaoai --use_qwen --
|
205
|
+
xiaogpt --hardware LX06 --mute_xiaoai --use_qwen --qwen_key ${qwen_key}
|
206
|
+
# 如果你想使用 kimi
|
207
|
+
xiaogpt --hardware LX06 --mute_xiaoai --use_moonshot_api --moonshot_api_key ${moonshot_api_key}
|
208
|
+
# 如果你想使用 llama3
|
209
|
+
xiaogpt --hardware LX06 --mute_xiaoai --use_llama --llama_api_key ${llama_api_key}
|
210
|
+
# 如果你想使用 01
|
211
|
+
xiaogpt --hardware LX06 --mute_xiaoai --use_yi_api --ti_api_key ${yi_api_key}
|
199
212
|
# 如果你想使用豆包
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
204
217
|
export OPENAI_API_KEY=${your_api_key}
|
205
218
|
export SERPAPI_API_KEY=${your_serpapi_key}
|
206
219
|
xiaogpt --hardware Lx06 --use_langchain --mute_xiaoai --stream --openai_key ${your_api_key} --serpapi_api_key ${your_serpapi_key}
|
@@ -226,9 +239,15 @@ python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_gemini --gemini_key ${ge
|
|
226
239
|
# 如果你想使用自己的 google gemini 服务
|
227
240
|
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_gemini --gemini_key ${gemini_key} --gemini_api_domain ${gemini_api_domain}
|
228
241
|
# 如果你想使用阿里的通义千问
|
229
|
-
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_qwen --
|
242
|
+
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_qwen --qwen_key ${qwen_key}
|
243
|
+
# 如果你想使用 kimi
|
244
|
+
xiaogpt --hardware LX06 --mute_xiaoai --use_moonshot_api --moonshot_api_key ${moonshot_api_key}
|
245
|
+
# 如果你想使用 01
|
246
|
+
xiaogpt --hardware LX06 --mute_xiaoai --use_yi_api --ti_api_key ${yi_api_key}
|
230
247
|
# 如果你想使用豆包
|
231
248
|
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_doubao --stream --volc_access_key xxxx --volc_secret_key xxx
|
249
|
+
# 如果你想使用 llama3
|
250
|
+
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_llama --llama_api_key ${llama_api_key}
|
232
251
|
# 如果你想使用 LangChain+SerpApi 实现上网检索或其他本地服务(目前仅支持 stream 模式)
|
233
252
|
export OPENAI_API_KEY=${your_api_key}
|
234
253
|
export SERPAPI_API_KEY=${your_serpapi_key}
|
@@ -272,47 +291,50 @@ ChatGLM [文档](http://open.bigmodel.cn/doc/api#chatglm_130b)
|
|
272
291
|
|
273
292
|
## 配置项说明
|
274
293
|
|
275
|
-
| 参数
|
276
|
-
|
277
|
-
| hardware
|
278
|
-
| account
|
279
|
-
| password
|
280
|
-
| openai_key
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
294
|
+
| 参数 | 说明 | 默认值 | 可选值 |
|
295
|
+
|------------------|-----------------------------------------------------------------------------------------------------------|--------|--------|
|
296
|
+
| hardware | 设备型号 | | |
|
297
|
+
| account | 小爱账户 | | |
|
298
|
+
| password | 小爱账户密码 | | |
|
299
|
+
| openai_key | openai的apikey | | |
|
300
|
+
| 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) | | |
|
301
|
+
| yi_api_key | 01 wanwu 的 [apikey](https://platform.lingyiwanwu.com/apikeys) | | |
|
302
|
+
| llama_api_key | groq 的 llama3 [apikey](https://console.groq.com/docs/quickstart) | | |
|
303
|
+
| serpapi_api_key | serpapi的key 参考 [SerpAPI](https://serpapi.com/) | | |
|
304
|
+
| glm_key | chatglm 的 apikey | | |
|
305
|
+
| gemini_key | gemini 的 apikey [参考](https://makersuite.google.com/app/apikey) | | |
|
306
|
+
| gemini_api_domain | gemini 的自定义域名 [参考](https://github.com/antergone/palm-netlify-proxy) | |
|
307
|
+
| qwen_key | qwen 的 apikey [参考](https://help.aliyun.com/zh/dashscope/developer-reference/api-details) | | |
|
308
|
+
| cookie | 小爱账户cookie (如果用上面密码登录可以不填) | | |
|
309
|
+
| mi_did | 设备did | | |
|
310
|
+
| use_command | 使用 MI command 与小爱交互 | `false` | |
|
311
|
+
| mute_xiaoai | 快速停掉小爱自己的回答 | `true` | |
|
312
|
+
| verbose | 是否打印详细日志 | `false` | |
|
313
|
+
| bot | 使用的 bot 类型,目前支持 chatgptapi,newbing, qwen, gemini | `chatgptapi` | |
|
314
|
+
| tts | 使用的 TTS 类型 | `mi` | `edge`、 `openai`、`azure`、`volc`、`baidu`、`google`、`minimax` |
|
315
|
+
| tts_options | TTS 参数字典,参考 [tetos](https://github.com/frostming/tetos) 获取可用参数 | | |
|
316
|
+
| prompt | 自定义prompt | `请用100字以内回答` | |
|
317
|
+
| keyword | 自定义请求词列表 | `["请"]` | |
|
318
|
+
| change_prompt_keyword | 更改提示词触发列表 | `["更改提示词"]` | |
|
319
|
+
| start_conversation | 开始持续对话关键词 | `开始持续对话` | |
|
320
|
+
| end_conversation | 结束持续对话关键词 | `结束持续对话` | |
|
321
|
+
| stream | 使用流式响应,获得更快的响应 | `false` | |
|
322
|
+
| proxy | 支持 HTTP 代理,传入 http proxy URL | "" | |
|
323
|
+
| gpt_options | OpenAI API 的参数字典 | `{}` | |
|
324
|
+
| bing_cookie_path | NewBing使用的cookie路径,参考[这里]获取 | 也可通过环境变量 `COOKIE_FILE` 设置 | |
|
325
|
+
| bing_cookies | NewBing使用的cookie字典,参考[这里]获取 | | |
|
326
|
+
| deployment_id | Azure OpenAI 服务的 deployment ID | 参考这个[如何找到deployment_id](https://github.com/yihong0618/xiaogpt/issues/347#issuecomment-1784410784) | |
|
327
|
+
| api_base | 如果需要替换默认的api,或者使用Azure OpenAI 服务 | 例如:`https://abc-def.openai.azure.com/` |
|
328
|
+
| volc_access_key | 火山引擎的 access key 请在[这里](https://console.volcengine.com/iam/keymanage/)获取 | | |
|
329
|
+
| volc_secret_key | 火山引擎的 secret key 请在[这里](https://console.volcengine.com/iam/keymanage/)获取 | | |
|
330
|
+
[这里]: <https://github.com/acheong08/EdgeGPT#getting-authentication-required>
|
309
331
|
|
310
332
|
## 注意
|
311
333
|
|
312
334
|
1. 请开启小爱同学的蓝牙
|
313
335
|
2. 如果要更改提示词和 PROMPT 在代码最上面自行更改
|
314
336
|
3. 目前已知 LX04、X10A 和 L05B L05C 可能需要使用 `--use_command`,否则可能会出现终端能输出GPT的回复但小爱同学不回答GPT的情况。这几个型号也只支持小爱原本的 tts.
|
315
|
-
4. 在wsl使用时, 需要设置代理为 http://wls的ip:port(vpn的代理端口)
|
337
|
+
4. 在wsl使用时, 需要设置代理为 <http://wls的ip:port(vpn的代理端口)>, 否则会出现连接超时的情况, 详情 [报错: Error communicating with OpenAI](https://github.com/yihong0618/xiaogpt/issues/235)
|
316
338
|
|
317
339
|
## QA
|
318
340
|
|
@@ -320,7 +342,7 @@ ChatGLM [文档](http://open.bigmodel.cn/doc/api#chatglm_130b)
|
|
320
342
|
2. 你做这玩意也没用啊?确实。。。但是挺好玩的,有用对你来说没用,对我们来说不一定呀
|
321
343
|
3. 想把它变得更好?PR Issue always welcome.
|
322
344
|
4. 还有问题?提 Issue 哈哈
|
323
|
-
5. Exception: Error https://api2.mina.mi.com/admin/v2/device_list?master=0&requestId=app_ios_xxx
|
345
|
+
5. Exception: Error <https://api2.mina.mi.com/admin/v2/device_list?master=0&requestId=app_ios_xxx>: Login failed [@KJZH001](https://github.com/KJZH001)<br>
|
324
346
|
这是由于小米风控导致,海外地区无法登录大陆的账户,请尝试cookie登录
|
325
347
|
无法抓包的可以在本地部署完毕项目后再用户文件夹`C:\Users\用户名`下面找到.mi.token,然后扔到你无法登录的服务器去<br>
|
326
348
|
若是linux则请放到当前用户的home文件夹,此时你可以重新执行先前的命令,不出意外即可正常登录(但cookie可能会过一段时间失效,需要重新获取)<br>
|
@@ -328,7 +350,7 @@ ChatGLM [文档](http://open.bigmodel.cn/doc/api#chatglm_130b)
|
|
328
350
|
|
329
351
|
## 视频教程
|
330
352
|
|
331
|
-
https://www.youtube.com/watch?v=K4YA8YwzOOA
|
353
|
+
<https://www.youtube.com/watch?v=K4YA8YwzOOA>
|
332
354
|
|
333
355
|
## Docker
|
334
356
|
|
@@ -1,20 +1,23 @@
|
|
1
|
-
xiaogpt-2.
|
2
|
-
xiaogpt-2.
|
3
|
-
xiaogpt-2.
|
4
|
-
xiaogpt-2.
|
1
|
+
xiaogpt-2.70.dist-info/METADATA,sha256=oa1OmHK7IJYoAKzKusUWWaF8ZXns1AuZMjbsZCYdHSQ,28501
|
2
|
+
xiaogpt-2.70.dist-info/WHEEL,sha256=vnE8JVcI2Wz7GRKorsPArnBdnW2SWKWGow5gu5tHlRU,90
|
3
|
+
xiaogpt-2.70.dist-info/entry_points.txt,sha256=zLFzA72qQ_eWBepdA2YU5vdXFqORH8wXhv2Ox1vnYP8,46
|
4
|
+
xiaogpt-2.70.dist-info/licenses/LICENSE,sha256=XdClh516MvlnOf9749JZHCxSB7y6_fyXcWmLDz6IkZY,1063
|
5
5
|
xiaogpt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
xiaogpt/__main__.py,sha256=MSmt_5Xg84uHqzTN38JwgseJK8rsJn_11A8WD99VtEo,61
|
7
|
-
xiaogpt/bot/__init__.py,sha256=
|
7
|
+
xiaogpt/bot/__init__.py,sha256=WeiJvhbnFb2krHZZrE_Hiy1F0gKmKr5FlVY17gW0_8I,1252
|
8
8
|
xiaogpt/bot/base_bot.py,sha256=oKn6LLFHXol4hKrSrjnxknrOqrcGICtT_GPPYRNxpkw,1467
|
9
9
|
xiaogpt/bot/chatgptapi_bot.py,sha256=JYlq1D-YZxRwAPpd5dTFSBU7h1KNdWA7FTwgyvMxr7c,3656
|
10
10
|
xiaogpt/bot/doubao_bot.py,sha256=UufQmYcPbwTLTYDZUQwRy4Hg24vgPEa3hdeZWMWw9YM,2773
|
11
11
|
xiaogpt/bot/gemini_bot.py,sha256=vX-fTWyPwdB4N0HDQ9uIRCB4KvV-YgBqXjkrqgg4WHs,2516
|
12
12
|
xiaogpt/bot/glm_bot.py,sha256=QoMJbnu5_rHDz4tzwn7gh3IoAuw7E4hZQLAfziMAvNY,1825
|
13
13
|
xiaogpt/bot/langchain_bot.py,sha256=4Uz5iOYzA2ongCklS-9zBse2fw-7kEE_9wITH7wdVCc,1944
|
14
|
+
xiaogpt/bot/llama_bot.py,sha256=HRR_ycuC6DY5MQTKauXEayQ0o_JKk9t-ea3mblscm8E,708
|
15
|
+
xiaogpt/bot/moonshot_bot.py,sha256=PrVRBskZx-U0lH_3RVe89QJa7WKHYqhpft0089pYQz0,822
|
14
16
|
xiaogpt/bot/newbing_bot.py,sha256=afUmw6tyMXbgGZvfQQWaA5h0-e0V0isFolW-WGhd0Vs,2289
|
15
17
|
xiaogpt/bot/qwen_bot.py,sha256=325lMa4Z38rRh47HDa3J4XjvSs4SWOqMVhrMWzkGNo4,3657
|
16
|
-
xiaogpt/
|
17
|
-
xiaogpt/
|
18
|
+
xiaogpt/bot/yi_bot.py,sha256=D7JEIh8KPVMvlOLaEVr9ahvyMaJLGToHP_gWU3RoYPc,784
|
19
|
+
xiaogpt/cli.py,sha256=TqxRFMS4IU7JtDAzeLe4I_eZJmUc6xI5bs7gmZdDveA,5899
|
20
|
+
xiaogpt/config.py,sha256=4MN1_pT038C-CH004cK68aCXrSWH_1Da1kGAjgew_fY,7006
|
18
21
|
xiaogpt/langchain/callbacks.py,sha256=yR9AXQt9OHVYBWC47Q1I_BUT4Xg9iM44vnW2vv0BLpE,2616
|
19
22
|
xiaogpt/langchain/chain.py,sha256=z0cqRlL0ElWnf31ByxZBN7AKOT-svXQDt5_NDft_nYc,1495
|
20
23
|
xiaogpt/langchain/examples/email/mail_box.py,sha256=xauqrjE4-G4XPQnokUPE-MZgAaHQ_VrUDLlbfYTdCoo,6372
|
@@ -22,7 +25,7 @@ xiaogpt/langchain/examples/email/mail_summary_tools.py,sha256=6cWvBJUaA7iaywcHdb
|
|
22
25
|
xiaogpt/tts/__init__.py,sha256=xasHDrmgECirf1MSyrfURSaMBqtdZBi3cQNeDvPo_cQ,145
|
23
26
|
xiaogpt/tts/base.py,sha256=fljxdXy60HXqdLXyQlsJZtzJBo5VtTwLkkWTi58tzQc,4656
|
24
27
|
xiaogpt/tts/mi.py,sha256=1MzCB27DBohPQ_4Xz4W_FV9p-chJFDavOHB89NviLcM,1095
|
25
|
-
xiaogpt/tts/tetos.py,sha256=
|
28
|
+
xiaogpt/tts/tetos.py,sha256=fkuOSYGqAfJyyPEXbsiOS--CewGf1JUiahoN33nzOAA,1058
|
26
29
|
xiaogpt/utils.py,sha256=B7NCH7g19hcwHDXsnBJPTU6UcWnXoEntKWm-pgcet2I,2072
|
27
|
-
xiaogpt/xiaogpt.py,sha256=
|
28
|
-
xiaogpt-2.
|
30
|
+
xiaogpt/xiaogpt.py,sha256=UfpKGJK95CcYSdZIgQEcyS4uwD77DcS8BAXtq_KxS8c,16525
|
31
|
+
xiaogpt-2.70.dist-info/RECORD,,
|
File without changes
|
File without changes
|