Initial commit: skills library
- 70 skills with code and documentation - Add .gitignore (ignore __pycache__, output/, temp/, venv/) - Clean up test intermediates and caches
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
添加新账号
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
ACCOUNTS_FILE = os.path.join(os.path.dirname(__file__), "../references/accounts.md")
|
||||
|
||||
|
||||
def add_aliyun_account(key, label=None):
|
||||
"""添加阿里云账号"""
|
||||
if not label:
|
||||
# 自动生成标签
|
||||
with open(ACCOUNTS_FILE, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
count = content.count("| 账号") - 1 # 减去表头
|
||||
label = f"账号{count + 1}"
|
||||
|
||||
# 读取现有内容
|
||||
with open(ACCOUNTS_FILE, "r", encoding="utf-8") as f:
|
||||
lines = f.readlines()
|
||||
|
||||
# 找到表格最后一行
|
||||
insert_idx = len(lines)
|
||||
for i, line in enumerate(lines):
|
||||
if line.startswith("| ---"):
|
||||
insert_idx = i
|
||||
break
|
||||
|
||||
new_row = f"| {label} | {key} | | 正常 |\n"
|
||||
lines.insert(insert_idx, new_row)
|
||||
|
||||
with open(ACCOUNTS_FILE, "w", encoding="utf-8") as f:
|
||||
f.writelines(lines)
|
||||
|
||||
print(f"已添加阿里云账号: {label}")
|
||||
print(f"API Key: {key[:10]}...")
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("用法:")
|
||||
print(" python add_account.py aliyun <api_key> [标签]")
|
||||
print(" python add_account.py openrouter <api_key>")
|
||||
print(" python add_account.py groq <api_key>")
|
||||
print(" python add_account.py deepseek <api_key>")
|
||||
return
|
||||
|
||||
platform = sys.argv[1]
|
||||
api_key = sys.argv[2] if len(sys.argv) > 2 else input("请输入API Key: ")
|
||||
label = sys.argv[3] if len(sys.argv) > 3 else None
|
||||
|
||||
if platform == "aliyun":
|
||||
add_aliyun_account(api_key, label)
|
||||
else:
|
||||
print(f"暂不支持平台: {platform}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user