refactor: use vars(mykey) to preserve key order, fix .items() iteration

This commit is contained in:
Liang Jiaqing
2026-02-19 09:28:29 +08:00
parent e3d2b3d14c
commit 2cb7c079a7
5 changed files with 41 additions and 15 deletions

View File

@@ -17,6 +17,7 @@ class Session:
@property
def url(self): return self.info.get('url', '')
def is_active(self):
if self.type == 'http' and time.time() - self.connect_at > 60: self.mark_disconnected()
return self.disconnect_at is None
def reconnect(self, client, info):
self.info = info
@@ -63,7 +64,7 @@ class TMWebDriver:
session.disconnect_at = None
if session.type == 'http': msgQ = session.http_queue
else: return json.dumps({"id": "", "ret": "use ws"})
start_time = time.time()
session.connect_at = start_time = time.time()
while time.time() - start_time < 5:
try:
msg = msgQ.get(timeout=0.2)

View File

@@ -28,15 +28,15 @@ def get_system_prompt():
class GeneraticAgent:
def __init__(self):
if not os.path.exists('temp'): os.makedirs('temp')
from sidercall import sider_cookie, oai_configs, claude_configs, xai_api_key, proxy
from sidercall import mykeys
llm_sessions = []
for cfg in claude_configs.values():
llm_sessions += [ClaudeSession(api_key=cfg['apikey'], api_base=cfg['apibase'], model=cfg['model'])]
if sider_cookie: llm_sessions += [SiderLLMSession(default_model=x) for x in \
for k, cfg in mykeys.items():
if not any(x in k for x in ['api', 'config', 'cookie']): continue
if 'claude' in k: llm_sessions += [ClaudeSession(api_key=cfg['apikey'], api_base=cfg['apibase'], model=cfg['model'])]
if 'oai' in k: llm_sessions += [LLMSession(api_key=cfg['apikey'], api_base=cfg['apibase'], model=cfg['model'], proxy=cfg.get('proxy'))]
if 'xai' in k: llm_sessions += [XaiSession(cfg, mykeys.get('proxy', ''))]
if 'sider' in k: llm_sessions += [SiderLLMSession(cfg, default_model=x) for x in \
["gemini-3.0-flash", "claude-haiku-4.5", "kimi-k2"]]
if xai_api_key: llm_sessions += [XaiSession(xai_api_key, proxy)]
for cfg in oai_configs.values():
llm_sessions += [LLMSession(api_key=cfg['apikey'], api_base=cfg['apibase'], model=cfg['model'], proxy=cfg.get('proxy'))]
if len(llm_sessions) > 0: self.llmclient = ToolClient(llm_sessions, auto_save_tokens=True)
else: self.llmclient = None
self.lock = threading.Lock()

View File

@@ -0,0 +1,31 @@
schedule: daily 0800
prompt: 按ezgmail_sop读取所有未读邮件判断是否有重要信息紧急/截止日期/需回复的),将摘要写入执行报告。全部设为已读。
---
# 邮件检查执行报告
执行时间: 2026-02-19 08:01:14
## 统计
- 总未读邮件: 21
- 重要邮件: 3
## 重要邮件详情
### 1. EXTENDED DEADLINE: Call for Papers: TAAS Special Issue on Autonomic Approaches and Applications for the Edge-HPC/Cloud Computing Continuum
- 发件人: "Rami Bahsoon, ACM TAAS Editor-in-Chief (do not reply)" <call-for-papers@hq.acm.org>
- 日期: Wed, 18 Feb 2026 10:00:00 -0500 (EST)
- 摘要: ACM Digital Library journal banner CALL FOR PAPERS - EXTENDED DEADLINE ACM Transactions on Autonomous and Adaptive Systems Special Issue on Autonomic Approaches and Applications for the Edge-HPC/Cloud
### 2. Re: [ARR January/ACL 2026] pending review for submission 5119 please reply!
- 发件人: acl2026 <acl2026pcs@gmail.com>
- 日期: Wed, 18 Feb 2026 12:57:39 +0000
- 摘要: Hi Jiaqing I can add you as a reviewer on the system for this paper. Can you please confirm you will do the review today? Best Maria On Wed, Feb 18, 2026 at 6:47 AM Nanyun Peng &lt;violetpeng@cs.ucla.
### 3. International Conference on Artificial Intelligence in Society 2026 - CALL FOR PAPERS - Deadline for submissions (1st CFP Extension): 9 March 2026
- 发件人: "isabel.andrade@isrlab.org" <isabel.andrade@isrlab.org>
- 日期: Wed, 18 Feb 2026 12:10:38 +0000
- 摘要: Header Image International Conference on Artificial Intelligence in Society 2026 (AIS 2026) Part of the 20th Multi Conference on Computer Science and Information Systems (MCCSIS 2026) Valencia, Spain,
## 操作
- 已将所有未读邮件标记为已读

View File

@@ -5,12 +5,6 @@ try: import mykey
except: raise Exception('[ERROR] mykey.py not found, please copy mykey_template.py to mykey.py and fill your LLM backend.')
mykeys = vars(mykey)
sider_cookie = mykeys.get("sider_cookie")
oai_configs = {k: v for k, v in vars(mykey).items() if k.startswith("oai_config") and v}
claude_configs = {k: v for k, v in vars(mykey).items() if k.startswith("claude_config") and v}
google_api_key = mykeys.get("google_api_key")
xai_api_key = mykeys.get("xai_api_key")
proxy = mykeys.get("proxy", 'http://127.0.0.1:2082')
proxies = {"http": proxy, "https": proxy} if proxy else None
@@ -28,7 +22,7 @@ def compress_history_tags(messages, keep_recent=4, max_len=200):
return messages
class SiderLLMSession:
def __init__(self, default_model="gemini-3.0-flash"):
def __init__(self, sider_cookie, default_model="gemini-3.0-flash"):
from sider_ai_api import Session
self._core = Session(cookie=sider_cookie, proxies=proxies)
self.default_model = default_model