xiaogpt 3.4__tar.gz → 3.10__tar.gz
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-3.4 → xiaogpt-3.10}/PKG-INFO +1 -1
- {xiaogpt-3.4 → xiaogpt-3.10}/pyproject.toml +1 -1
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/bot/gemini_bot.py +8 -4
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/cli.py +3 -2
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/config.py +2 -1
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/tts/live.py +5 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/xiaogpt.py +16 -7
- {xiaogpt-3.4 → xiaogpt-3.10}/LICENSE +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/README.md +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/__init__.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/__main__.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/bot/__init__.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/bot/base_bot.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/bot/chatgptapi_bot.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/bot/doubao_bot.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/bot/glm_bot.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/bot/langchain_bot.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/bot/llama_bot.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/bot/moonshot_bot.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/bot/qwen_bot.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/bot/yi_bot.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/langchain/callbacks.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/langchain/chain.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/langchain/examples/email/mail_box.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/langchain/examples/email/mail_summary_tools.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/tts/__init__.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/tts/base.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/tts/file.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/tts/mi.py +0 -0
- {xiaogpt-3.4 → xiaogpt-3.10}/xiaogpt/utils.py +0 -0
@@ -32,13 +32,15 @@ safety_settings = [
|
|
32
32
|
class GeminiBot(ChatHistoryMixin, BaseBot):
|
33
33
|
name = "Gemini"
|
34
34
|
|
35
|
-
def __init__(
|
35
|
+
def __init__(
|
36
|
+
self, gemini_key: str, gemini_api_domain: str, gemini_model: str
|
37
|
+
) -> None:
|
36
38
|
import google.generativeai as genai
|
37
39
|
|
38
40
|
from google.auth import api_key
|
39
41
|
|
40
42
|
credentials = api_key.Credentials(gemini_key)
|
41
|
-
if
|
43
|
+
if gemini_api_domain:
|
42
44
|
print("Use custom gemini_api_domain: " + gemini_api_domain)
|
43
45
|
credentials._universe_domain = gemini_api_domain
|
44
46
|
genai.configure(
|
@@ -54,7 +56,7 @@ class GeminiBot(ChatHistoryMixin, BaseBot):
|
|
54
56
|
|
55
57
|
self.history = []
|
56
58
|
model = genai.GenerativeModel(
|
57
|
-
model_name="gemini-
|
59
|
+
model_name=gemini_model or "gemini-2.0-flash-lite",
|
58
60
|
generation_config=generation_config,
|
59
61
|
safety_settings=safety_settings,
|
60
62
|
)
|
@@ -63,7 +65,9 @@ class GeminiBot(ChatHistoryMixin, BaseBot):
|
|
63
65
|
@classmethod
|
64
66
|
def from_config(cls, config):
|
65
67
|
return cls(
|
66
|
-
gemini_key=config.gemini_key,
|
68
|
+
gemini_key=config.gemini_key,
|
69
|
+
gemini_api_domain=config.gemini_api_domain,
|
70
|
+
gemini_model=config.gemini_model,
|
67
71
|
)
|
68
72
|
|
69
73
|
async def ask(self, query, **options):
|
@@ -59,6 +59,7 @@ class Config:
|
|
59
59
|
llama_api_key: str = os.getenv("GROQ_API_KEY", "") # use groq
|
60
60
|
glm_key: str = os.getenv("CHATGLM_KEY", "")
|
61
61
|
gemini_key: str = os.getenv("GEMINI_KEY", "") # keep the old rule
|
62
|
+
gemini_model: str = os.getenv("GEMINI_MODEL", "") # keep the old rule
|
62
63
|
qwen_key: str = os.getenv("DASHSCOPE_API_KEY", "") # keep the old rule
|
63
64
|
serpapi_api_key: str = os.getenv("SERPAPI_API_KEY", "")
|
64
65
|
gemini_api_domain: str = os.getenv(
|
@@ -77,7 +78,7 @@ class Config:
|
|
77
78
|
api_base: str | None = None
|
78
79
|
deployment_id: str | None = None
|
79
80
|
use_command: bool = False
|
80
|
-
verbose:
|
81
|
+
verbose: int = 0
|
81
82
|
start_conversation: str = "开始持续对话"
|
82
83
|
end_conversation: str = "结束持续对话"
|
83
84
|
stream: bool = False
|
@@ -27,11 +27,15 @@ class HTTPRequestHandler(BaseHTTPRequestHandler):
|
|
27
27
|
self.end_headers()
|
28
28
|
key = self.path.split("/")[-1]
|
29
29
|
queue = get_queue(key)
|
30
|
+
chunks: list[bytes] = []
|
30
31
|
while True:
|
31
32
|
chunk = queue.get()
|
33
|
+
chunks.append(chunk)
|
32
34
|
if chunk == b"":
|
33
35
|
break
|
34
36
|
self.wfile.write(chunk)
|
37
|
+
for chunk in chunks:
|
38
|
+
queue.put_nowait(chunk)
|
35
39
|
|
36
40
|
def log_message(self, format, *args):
|
37
41
|
logger.debug(f"{self.address_string()} - {format}", *args)
|
@@ -76,6 +80,7 @@ class TetosLiveTTS(TTS):
|
|
76
80
|
|
77
81
|
while True:
|
78
82
|
if await self.get_if_xiaoai_is_playing():
|
83
|
+
logger.debug("Xiaoai is playing, waiting")
|
79
84
|
await asyncio.sleep(1)
|
80
85
|
else:
|
81
86
|
break
|
@@ -57,15 +57,20 @@ class MiGPT:
|
|
57
57
|
async def poll_latest_ask(self):
|
58
58
|
async with ClientSession() as session:
|
59
59
|
session._cookie_jar = self.cookie_jar
|
60
|
+
log_polling = int(self.config.verbose) > 1
|
60
61
|
while True:
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
if log_polling:
|
63
|
+
self.log.debug(
|
64
|
+
"Listening new message, timestamp: %s", self.last_timestamp
|
65
|
+
)
|
64
66
|
new_record = await self.get_latest_ask_from_xiaoai(session)
|
65
67
|
start = time.perf_counter()
|
66
|
-
|
67
|
-
|
68
|
-
|
68
|
+
if log_polling:
|
69
|
+
self.log.debug(
|
70
|
+
"Polling_event, timestamp: %s %s",
|
71
|
+
self.last_timestamp,
|
72
|
+
new_record,
|
73
|
+
)
|
69
74
|
await self.polling_event.wait()
|
70
75
|
if (
|
71
76
|
self.config.mute_xiaoai
|
@@ -75,7 +80,10 @@ class MiGPT:
|
|
75
80
|
await self.stop_if_xiaoai_is_playing()
|
76
81
|
if (d := time.perf_counter() - start) < 1:
|
77
82
|
# sleep to avoid too many request
|
78
|
-
|
83
|
+
if log_polling:
|
84
|
+
self.log.debug(
|
85
|
+
"Sleep %f, timestamp: %s", d, self.last_timestamp
|
86
|
+
)
|
79
87
|
# if you want force mute xiaoai, comment this line below.
|
80
88
|
await asyncio.sleep(1 - d)
|
81
89
|
|
@@ -334,6 +342,7 @@ class MiGPT:
|
|
334
342
|
async def stop_if_xiaoai_is_playing(self):
|
335
343
|
is_playing = await self.get_if_xiaoai_is_playing()
|
336
344
|
if is_playing:
|
345
|
+
self.log.debug("Muting xiaoai")
|
337
346
|
# stop it
|
338
347
|
await self.mina_service.player_pause(self.device_id)
|
339
348
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|